NETWORK INCIDENTS

dig Explained for Beginners: How to Read a DNS Answer

Network+ 3.4 Name resolution: DNSNetwork+ 5.5 Command-line tools: dig

Every time you open a website, your computer first asks a DNS server what address that name belongs to. dig lets you ask that question yourself, and shows you the whole answer. Here's how to read it.

A small home network to try dig on: a PC, a switch, the homelab's DNS server (CoreDNS, serving homelab.test) and a web server. Open a shell on the PC and ask DNS questions.

The lab

This is the lab: one small home network. A PC, the homelab's DNS server at 10.0.10.53, and a web server at 10.0.10.80. The DNS server knows the homelab's names, like web dot homelab dot test. The PC will do all the asking.

Where the question goes

on pc
cat /etc/resolv.conf
nameserver 10.0.10.53
search homelab.test
What this shows

First, where does a question go? On Linux, the answer is in this file. nameserver 10.0.10.53: that's the DNS server this PC uses, usually handed out by your router. Unless you tell dig otherwise, that's who it asks.

Reading the answer

on pc
dig web.homelab.test
; <<>> DiG 9.20.23 <<>> web.homelab.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 20714
;; flags: qr aa rd; QUERY: 1, ANSWER: 1, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: 336facfeee6fc07f (echoed)
;; QUESTION SECTION:
;web.homelab.test.              IN      A

;; ANSWER SECTION:
web.homelab.test.       3600    IN      A       10.0.10.80

;; AUTHORITY SECTION:
homelab.test.           3600    IN      NS      dns.homelab.test.

;; Query time: 0 msec
;; SERVER: 10.0.10.53#53(10.0.10.53) (UDP)
;; WHEN: Fri Oct 23 15:52:05 UTC 2026
;; MSG SIZE  rcvd: 131
What this shows

Ask for web dot homelab dot test. There's a lot here, but you only need four lines. Near the top, status: NOERROR. The question was understood and answered. The question section repeats what we asked. The answer section is the part you came for: web dot homelab dot test is at 10.0.10.80. The 3600 is how many seconds the answer may be kept in a cache. And at the bottom, the SERVER line shows who answered: 10.0.10.53, the server from resolv.conf. The warning near the top just says this server won't look up names outside the homelab. You can ignore the rest for now.

on pc
dig +short web.homelab.test
10.0.10.80
What this shows

Most days you only want the address. Add plus short, and dig prints just the answer: 10.0.10.80.

on pc
dig +short nas.homelab.test
10.0.10.30
What this shows

The same for the NAS: 10.0.10.30.

When the answer is no

on pc
dig nope.homelab.test
; <<>> DiG 9.20.23 <<>> nope.homelab.test
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 65228
;; flags: qr aa rd; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1
;; WARNING: recursion requested but not available

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 1232
; COOKIE: bd87dc798870ddff (echoed)
;; QUESTION SECTION:
;nope.homelab.test.             IN      A

;; AUTHORITY SECTION:
homelab.test.           3600    IN      SOA     dns.homelab.test. admin.homelab.test. 2026102301 7200 3600 1209600 3600

;; Query time: 0 msec
;; SERVER: 10.0.10.53#53(10.0.10.53) (UDP)
;; WHEN: Fri Oct 23 15:52:16 UTC 2026
;; MSG SIZE  rcvd: 140
What this shows

Now a name that doesn't exist. The status changes to NXDOMAIN, and the header says ANSWER: 0. This matters: the server did answer. The SERVER line is there, from 10.0.10.53. Its answer is that no such name exists. If a name gives you NXDOMAIN, check the spelling, or check that the name was ever added to your DNS server.

on pc
dig @10.0.10.80 web.homelab.test
;; communications error to 10.0.10.80#53: connection refused
;; communications error to 10.0.10.80#53: connection refused
;; communications error to 10.0.10.80#53: connection refused

; <<>> DiG 9.20.23 <<>> @10.0.10.80 web.homelab.test
; (1 server found)
;; global options: +cmd
;; no servers could be reached
What this shows

The at sign tells dig which server to ask. Here, it asks the web server, which isn't a DNS server. dig tries three times, and each time the reply is connection refused: nothing there handles DNS. Then the line to remember: no servers could be reached. This is different from NXDOMAIN. Nobody answered at all. That's the message from our first incident episode, where the homelab's DNS service had stopped.

on pc
dig @10.0.10.53 +short web.homelab.test
10.0.10.80
What this shows

Ask the real DNS server by its address, and the answer comes straight back. Using at with an address is the quickest way to test one particular DNS server, whatever your computer is set to use.

Recap

So dig gives you one of three results. NOERROR with an answer: DNS works. NXDOMAIN: the server answered, and that name doesn't exist. No servers could be reached: nobody answered, so look at the DNS server itself, or the way to it. Each one points at a different problem, and that's why it's worth reading.

On Windows and Mac

Not on Linux? On a Mac, dig is usually already installed: open Terminal and type the same commands. Windows doesn't come with dig. Use nslookup instead, in Command Prompt or PowerShell, or Resolve-DnsName in PowerShell. They ask the same question, but the answer looks different. The Learn page on networkincidents.ca shows how to read each one.

Macdig web.homelab.testin Terminal: usually built in, the same command
Windowsnslookup web.homelab.testin Command Prompt or PowerShell
PowerShellResolve-DnsName web.homelab.testWindows: the PowerShell way to ask
dig: one question, the whole answer

When a name doesn't work, run dig. Check the status, the answer, and the SERVER line, and you'll know whether the server said no, or never answered.

Try it yourself

The whole lab runs on your own computer with Docker and containerlab: get it on GitHub, then ./lab.sh up and ./lab.sh break. Setup steps are on Run the labs.