{"id":24123,"library":"nslookup","title":"nslookup","description":"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.","status":"active","version":"1.8.1","language":"python","source_language":"en","source_url":"https://github.com/wesinator/pynslookup","tags":["dns","lookup","nslookup","dnspython"],"install":[{"cmd":"pip install nslookup","lang":"bash","label":"Install via pip"}],"dependencies":[{"reason":"Core DNS resolution library used by nslookup.","package":"dnspython","optional":false}],"imports":[{"note":"The module doesn't expose a meaningful top-level API; you must import the class specifically.","wrong":"import nslookup","symbol":"NsLookup","correct":"from nslookup import NsLookup"}],"quickstart":{"code":"from nslookup import NsLookup\n\ndomain = \"example.com\"\ndns_query = NsLookup(dns_servers=[\"8.8.8.8\"])\nresp = dns_query.a(domain)\nprint(resp.answer)\n\n# For MX records:\nmx_resp = dns_query.mx(domain)\nprint(mx_resp.answer)","lang":"python","description":"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."},"warnings":[{"fix":"Always pass a list of DNS servers, e.g., NsLookup(dns_servers=['8.8.8.8']).","message":"The default DNS server list is empty; you must provide at least one server. Failing to do so will raise an error on query.","severity":"gotcha","affected_versions":">=1.0.0"},{"fix":"Use the new specific methods (e.g., .a(), .mx(), .aaaa(), .ns(), .txt()) instead of the generic .dns_lookup().","message":"In 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.","severity":"breaking","affected_versions":"1.8.0+"},{"fix":"Wrap calls in try/except blocks or implement retry logic with alternative servers.","message":"Some DNS server responses may be empty or cause exceptions. The library does not always handle timeouts gracefully (depends on dnspython defaults).","severity":"gotcha","affected_versions":"all"}],"env_vars":null,"last_verified":"2026-05-01T00:00:00.000Z","next_check":"2026-07-30T00:00:00.000Z","problems":[{"fix":"Use specific methods like .a(), .mx(), .aaaa() instead.","cause":"In version 1.8.0+, the generic dns_lookup method was removed.","error":"AttributeError: 'NsLookup' object has no attribute 'dns_lookup'"},{"fix":"Initialize with NsLookup(dns_servers=['8.8.8.8']).","cause":"The NsLookup class requires a list of DNS servers as argument.","error":"TypeError: __init__() missing required positional argument: 'dns_servers'"},{"fix":"Specify a longer timeout via dnspython custom resolver, or use faster DNS servers. The nslookup library does not expose timeout settings directly; consider using dnspython directly.","cause":"Default dnspython timeout may be too short for some queries.","error":"dnspython.exception.Timeout: The DNS operation timed out."}],"ecosystem":"pypi","meta_description":null,"install_score":null,"install_tag":null,"quickstart_score":null,"quickstart_tag":null}