Skip to main content

Sensible high-level DNS lookups in Python, using DNSpython resolver

Project description

PyNslookup

PyPi package

Simple, sensible high-level DNS lookups in Python (on top of dnspython dns.resolver).

Purpose and scope

This library is a simple wrapper around dnspython, to provide high level functions with good error/exception handling, for the most common basic DNS lookup cases.

  • A, AAAA record lookups (typical DNS queries)
  • SOA lookups

This is not intended to be a complete wrapper around dnspython library or to handle uncommon edge cases. Features like DoH are out of scope, and should be done using other libraries or dnspython directly.

Usage

Returns an object containing two arrays:

  • response_full: the full DNS response string(s)
  • answer: the parsed DNS answer (list of IPs or SOA string)
from nslookup import Nslookup

domain = "example.com"

# Initialize Nslookup
dns_query = Nslookup()
# Alternatively, the Nslookup constructor supports optional
# arguments for setting custom dns servers (defaults to system DNS),
# verbosity (default: True) and using TCP instead of UDP (default: False)
dns_query = Nslookup(dns_servers=["1.1.1.1"], verbose=False, tcp=False)

ips_record = dns_query.dns_lookup(domain)
print(ips_record.response_full, ips_record.answer)

soa_record = dns_query.soa_lookup(domain)
print(soa_record.response_full, soa_record.answer)

Note

This library is oriented around regular UDP DNS.

Using TCP modes in this simple library will create a separate TCP session for each query, which can be resource intensive for a large number of queries. For this it is recommended to use the more granular dnspython API directly.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nslookup-1.9.0.tar.gz (9.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nslookup-1.9.0-py3-none-any.whl (9.5 kB view details)

Uploaded Python 3

File details

Details for the file nslookup-1.9.0.tar.gz.

File metadata

  • Download URL: nslookup-1.9.0.tar.gz
  • Upload date:
  • Size: 9.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for nslookup-1.9.0.tar.gz
Algorithm Hash digest
SHA256 8e660032fe1afcf16750e82e47f43f13548f9ff3228a580bf730df5585f02820
MD5 59e53369ed08d15cb7b0a899c41fbf40
BLAKE2b-256 e1791fe730c666eb089703b30a274c0763ee1529f1dcedd6baaed31bc889cbb8

See more details on using hashes here.

File details

Details for the file nslookup-1.9.0-py3-none-any.whl.

File metadata

  • Download URL: nslookup-1.9.0-py3-none-any.whl
  • Upload date:
  • Size: 9.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.0 CPython/3.10.12

File hashes

Hashes for nslookup-1.9.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c904118862ec71ec9bdd8d9988792d3ed1fe11ab84d3e5a17fdc8deca8224c8b
MD5 d1b580a9283351df393428d1925f1217
BLAKE2b-256 83adbc7a3ce91ccf5984c0e85074e007cfadbc97cbdfe75b7fb70e1d4c829054

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page