Registry / http-networking / nslookup

nslookup

JSON →
library1.9.0pypypi✓ verified 79d ago

Sensible high-level DNS lookups in Python, using DNSpython resolver. Version 1.8.1 provides an easy-to-use wrapper around dnspython for common DNS queries (A, AAAA, MX, NS, TXT, etc.). It is released under MIT license and maintained on GitHub. Release cadence is low, with occasional updates.

pip install nslookup
INSTALL
IMPORT
SIG · NSLOOKUP
N
nslookup
http-networkingpythonv1.9.0
Install
1.8s avg
Import
Disk
19MB
Pass rate
10/ 10
Env Coverage10 / 10
glibc
3.93.13
musl
3.93.13
Install & Compatibility
Where this runs
tested against v1.9.0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
py 3.103.95 runs
installs and imports cleanly · install 0.0s · import 0.000s · 20.4MB
glibc
py 3.103.95 runs
installs and imports cleanly · install 1.8s · import 0.000s · 21MB
19MB installed
● package 19MB
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

Nslookup
from nslookup import Nslookup
from nslookup import NsLookup
nslookup
from nslookup import nslookup
DNSresponse
from nslookup import DNSresponse

Initialize NsLookup with a list of DNS servers, then call methods like .a() or .mx() to perform lookups. The result object contains .answer, .response_full, etc.

from nslookup import NsLookup domain = "example.com" dns_query = NsLookup(dns_servers=["8.8.8.8"]) resp = dns_query.a(domain) print(resp.answer) # For MX records: mx_resp = dns_query.mx(domain) print(mx_resp.answer)
Debug
Known issues
gotchaThe default DNS server list is empty; you must provide at least one server. Failing to do so will raise an error on query.
fix
Always pass a list of DNS servers, e.g., NsLookup(dns_servers=['8.8.8.8']).
affects: >=1.0.0
breakingIn version 1.8.0, the module's internal API changed: previously, `ns_lookup = NsLookup()` then `ns_lookup.dns_lookup()` was used. This was removed. Now you must call specific methods like `.a()`, `.mx()`, etc.
fix
Use the new specific methods (e.g., .a(), .mx(), .aaaa(), .ns(), .txt()) instead of the generic .dns_lookup().
affects: 1.8.0+
gotchaSome DNS server responses may be empty or cause exceptions. The library does not always handle timeouts gracefully (depends on dnspython defaults).
fix
Wrap calls in try/except blocks or implement retry logic with alternative servers.
affects: all
Upgrade
Version history
1.9.0latest on PyPI · released May 3, 2026
Audit
Dependencies
dnspythonrequiredCore DNS resolution library used by nslookup.
Agent activity
14 hits · last 30 days
node
14
Resources
nslookup — pip install nslookup · libregistry