Windows / legacy Unix

nslookup vs dig

Use dig on Linux. nslookup example.com becomes dig example.com, and to query a specific server nslookup example.com 8.8.8.8 becomes dig @8.8.8.8 example.com. dig shows the full DNS response including which server actually answered and how long it took.
Try it in a live lab

Free interactive lab. No signup. Runs in your browser.

Command by command

Windows / legacy UnixLinuxWhat it gives you
nslookup example.comdig example.comA record lookup
nslookup example.com 8.8.8.8dig @8.8.8.8 example.comAsk a specific resolver
nslookup -type=mx example.comdig example.com MXMail records
nslookup -type=ns example.comdig example.com NSNameservers
dig +short example.comJust the answer, for scripts
dig +trace example.comFull delegation from the root — nslookup has no equivalent

What the output looks like

$ dig @10.0.1.2 web.lab +short
10.0.1.20

$ dig @10.0.1.2 web.lab
;; ANSWER SECTION:
web.lab.    0    IN  A  10.0.1.20
;; SERVER: 10.0.1.2#53(10.0.1.2) (UDP)
;; Query time: 0 msec

Why the two differ

nslookup presents a tidied summary and hides the protocol. dig prints the actual DNS message: the question, the answer, the authority and additional sections, the flags, the TTL, and crucially the SERVER: line naming which resolver replied. When you are debugging DNS, those are exactly the fields that tell you what went wrong — a stale TTL, an answer from the wrong resolver, a truncated response that forced a TCP retry.

The trap

nslookup prints "Non-authoritative answer" for almost every normal lookup, and beginners read it as an error. It only means the answer came from a server that is not authoritative for the zone — usually a recursive resolver answering from its cache — which is the expected case for essentially all internet DNS. It is not a fault.

Common questions

Is nslookup deprecated?

It was announced as deprecated years ago and that announcement was later withdrawn, so it still ships in bind-utils alongside dig. It works. It just shows you less, which matters when the reason you are running it is that something is broken.

Why does dig return nothing at all?

An empty ANSWER section with status NOERROR means the name exists but has no record of that type — asking for an A record on a name that only has AAAA, for instance. A status of NXDOMAIN means the name does not exist. Check the status: field in the header rather than judging by the empty answer.

Stop reading, start running

Open the lab, go live, and run dig against real Linux networking in your browser. No install, no signup.

Launch the lab →