nslookup and dig
nslookup ships on Windows. dig ships with the
[BIND 9 utilities][isc-dig].
Asks for the default type, which is A, in dig's full layout.
dig @1.1.1.1 isitdns.netGO NOERROR and the A records, with the header and flags nslookup hides
NO GO SERVFAIL
Task by task#
| Task | dig | nslookup |
|---|---|---|
| Quick A lookup | dig @1.1.1.1 isitdns.net | nslookup isitdns.net 1.1.1.1 |
| A and AAAA together | two lookups (A, then AAAA) | default behavior |
| One record type | dig @1.1.1.1 isitdns.net MX | nslookup -type=MX isitdns.net 1.1.1.1 |
| Reverse (PTR) lookup | dig -x 1.1.1.2 | nslookup 1.1.1.2 |
| Answer only, no header | dig @1.1.1.1 +short isitdns.net | not available |
| No recursion (RD=0) | dig @158.101.0.110 probe.isitdns.net SOA +norec | nslookup -norecurse -type=SOA probe.isitdns.net 158.101.0.110 |
| Skip dnssec validation | dig @1.1.1.1 +cd isitdns.net | not available |
| Request DNSSEC signatures | dig @1.1.1.1 isitdns.net +dnssec | not available |
| Walk the hierarchy from root | dig +trace isitdns.net | not available |
| Force the literal name, no search suffix | default behavior | nslookup webmail. (trailing dot) |
| Apply the search suffix | dig webmail +search | default behavior |
See header flags (aa ad ra rd) | default output | nslookup -debug NAME, or set debug in interactive mode |
Where they differ#
- Search suffix.
nslookupappends the resolver's configured search domain to a bare name before querying;dignever does unless you pass+search. A trailing dot forces the literal name in both. Source: [BIND 9nslookupmanpage][isc-nslookup] (search/nosearch,srchlist). - A and AAAA together. With no
-typegiven,nslookupqueriesAand thenAAAAand prints both;digwith no type asks onlyA. Source: [BIND 9nslookupmanpage][isc-nslookup]: "The defaults are A and then AAAA... only the default behavior looks up both." - No flags line.
dig's default output prints the full header (qr aa rd ra ad, RCODE, section counts).nslookupshows none of that unless debug is on:-debugon the command line orset debugin interactive mode; it is off by default. Source: [BIND 9nslookupmanpage][isc-nslookup] (nodebugkeyword, defaultnodebug; "Options can also be specified on the command line if they precede the arguments and are prefixed with a hyphen"). - DNSSEC / AD visibility.
digsets the AD (authentic data) bit on its own queries by default, so a validating resolver'sadflag shows up on a plain lookup (RFC 6840 §5.8);+dnssecalso requests the RRSIGs.nslookuphas no DNSSEC option: it cannot setDOor displayAD. Source: [BIND 9nslookupmanpage][isc-nslookup] (no DNSSEC keyword in the option list).
$ nslookup isitdns.net 1.1.1.1
Server: 1.1.1.1
Address: 1.1.1.1#53
Non-authoritative answer:
Name: isitdns.net
Address: 104.21.56.211
Name: isitdns.net
Address: 172.67.155.242
Name: isitdns.net
Address: 2606:4700:3032::6815:38d3
Name: isitdns.net
Address: 2606:4700:3036::ac43:9bf2Non-authoritative answer: labels any response with the Authoritative Answer bit clear, which is every answer relayed by a recursive resolver, cache hit or not (RFC 1035 §4.1.1, the AA bit). nslookup shows the label; it does not show the bit itself. dig's flags line shows aa directly.
[isc-nslookup]: https://bind9.readthedocs.io/en/latest/manpages.html#std-iscman-nslookup [ms-nslookup]: https://learn.microsoft.com/en-us/windows-server/administration/windows-commands/nslookup [isc-dig]: https://bind9.readthedocs.io/en/latest/manpages.html#dig-dns-lookup-utility
See also#
- dig-tool: the in-browser dig on the isitdns front page, which emits
dig,kdig, andnslookupequivalents for every query - dig-along: every common record type, live, hands-on
- dig-flags: the dig flags this wiki uses
- anatomy-of-a-query: what happens between the time you hit Enter and the answer arrives
- query-types: record types and rcodes explained
- dnssec-troubleshooting: where
delvcomes in - dot-doh: DoT, DoH, and DoQ for encrypted DNS queries
- ptr: reverse DNS and the in-addr.arpa zone
- [Microsoft Learn:
nslookupreference][ms-nslookup] - [ISC BIND 9:
nslookupmanpage][isc-nslookup] - [ISC BIND 9:
digmanpage][isc-dig]