Command by command
| Windows / legacy Unix | Linux | What it gives you |
|---|---|---|
nslookup example.com | dig example.com | A record lookup |
nslookup example.com 8.8.8.8 | dig @8.8.8.8 example.com | Ask a specific resolver |
nslookup -type=mx example.com | dig example.com MX | Mail records |
nslookup -type=ns example.com | dig example.com NS | Nameservers |
| dig +short example.com | Just the answer, for scripts |
| dig +trace example.com | Full 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.