Sensible high-level DNS lookups in Python, using DNSpython resolver
Project description
PyNslookup
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file nslookup-1.8.1.tar.gz
.
File metadata
- Download URL: nslookup-1.8.1.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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 10f695516641f3de24e03cc27ac3219433da983eb9f2bf246a44ea2e66cb85fe |
|
MD5 | 77a356597e5d9dc74636b45f88179249 |
|
BLAKE2b-256 | 802dd750f670214f96944da9953dd2524b8e4d07e8fc911145a8f149201a8a64 |
File details
Details for the file nslookup-1.8.1-py3-none-any.whl
.
File metadata
- Download URL: nslookup-1.8.1-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
Algorithm | Hash digest | |
---|---|---|
SHA256 | 4011678364c105f154bfe47954941a7c61d28f74f707ad1931918ec06300ea0f |
|
MD5 | fc618c4725d513e270555ed76ac24a45 |
|
BLAKE2b-256 | 15eec03427e2fe2ca5e676f46b761e46106950d3fa7a2b7442f61311aefd6925 |