Vol. I · No. 46The command line sectionSat, 10 Oct 2026
Linux · names

dig

asking the DNS directly

dig builds one DNS query, sends it, and shows everything that came back — header flags, the question, the answer records and how long it took. Because it talks to the resolver itself and ignores the host's own lookup rules, it tells you what the DNS says rather than what the machine concluded.

When a name will not resolve, dig separates what the DNS answered from what the host did with the answer.

Speaks
DNS
UDP 53, TCP when asked
Default record
A
name the type to change it
Short output
+short
just the answer
Bypasses
/etc/hosts
and nsswitch entirely

At the terminal

Read the session first, then the notes: each numbered line in the output is answered by the note with the same number.

user@netflow — bashbind9-dnsutils
$ dig example.com
; <<>> DiG 9.18.28 <<>> example.com
;; Got answer:
1;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 41207
2;; flags: qr rd ra; QUERY: 1, ANSWER: 1, AUTHORITY: 0, ADDITIONAL: 1
 
;; QUESTION SECTION:
;example.com. IN A
 
;; ANSWER SECTION:
3example.com. 3600 IN A 192.0.2.10
 
4;; Query time: 18 msec
5;; SERVER: 127.0.0.53#53(127.0.0.53) (UDP)
;; MSG SIZE rcvd: 56
Illustrative session · names, sizes and dates are examples, and every address is from a documentation or private range
Reading the output

What the numbered lines are telling you

1
status is the verdict

NOERROR means the query was answered. NXDOMAIN means the name does not exist; SERVFAIL means the resolver could not get an answer at all.

2
The flags say who did the work

qr marks this as a response, rd that recursion was requested, ra that the server offers it. An "aa" flag would mean the answer came from the authoritative server itself.

3
The answer record, left to right

Name, time-to-live in seconds, class, type, value. 3600 is how long any resolver may cache this before asking again.

4
Query time exposes caching

Run it twice: a second answer in 0 msec came from the resolver's cache, and its TTL will have counted down.

5
SERVER is who actually answered

127.0.0.53 is the local systemd-resolved stub, not the upstream resolver. Add @server to ask a specific one.

Switches

A switch changes how the command behaves. These are the ones used day to day; man dig lists the rest. Single-letter switches can usually be joined, so -l -a may be written -la.

+short
Print only the answer — the address or name — and nothing else.
+trace
Follow the delegation from the root servers down, one step at a time.
-x ADDR
Reverse lookup: find the name for an IP address.
@SERVER
Ask this DNS server instead of the system’s configured one.
-t TYPE
Ask for a record type: A, AAAA, MX, NS, TXT. The type can also be given bare.
+noall +answer
Hide every section except the answer.
+tcp
Use TCP instead of UDP for the query.

Variations worth knowing

The same tool, pointed at a narrower question. These four cover most of what it is reached for day to day.

dig +short example.com AAAA

Just the IPv6 addresses, one per line — the form for scripts.

dig @192.0.2.53 example.com MX

Asks a named resolver for the mail exchangers, bypassing the one the host is configured with.

dig +trace example.com

Walks the delegation from the root servers down, showing which server handed off to which.

dig -x 192.0.2.10

A reverse lookup: the PTR record that maps an address back to a name.

In cybersecurity

DNS decides where every connection goes, and by default nothing in the answer is authenticated. dig is the tool for checking whether the answer you received is the one that was published.

Compare resolvers

Ask the local resolver and an independent one. Different answers for the same name mean something is rewriting DNS.

DNSSEC

"dig +dnssec" returns the signatures. An "ad" flag in the response means a validating resolver checked them.

Zone transfers

"dig axfr" against a misconfigured server returns the whole zone — every hostname the organisation has.

TTL as evidence

A very short TTL on a record that should be stable is a mark of fast-flux hosting and of hijacked records.

TXT as a channel

Data can be smuggled out in DNS queries and replies. Unusual TXT volume to one domain deserves a look.

Reconnaissance

MX, NS, TXT and SPF records describe an organisation's mail and hosting to anyone who asks. Publish only what must be public.

Protocols it shows

DNSUDPTCPmDNS

Read alongside