cheat-sheets

dig

dig queries DNS servers and prints the full answer. Use it to check records, test a specific resolver, follow delegation from the root and see whether a zone is signed. host and nslookup are simpler alternatives, and resolvectl queries through systemd-resolved.

Documentation: dig(1) · host(1) Project: BIND 9

Verification: options were checked against the dig and host man pages in Ubuntu 24.04 (bind9-dnsutils). resolvectl rows follow the systemd documentation and were not run. Use example.com style names; output varies by resolver.

Queries #

COMMANDDESCRIPTION
dig example.comA record using the system resolver
dig example.com MXA given record type (AAAA, MX, TXT, NS, CNAME, SOA, CAA)
dig @192.0.2.53 example.comAsk a specific server
dig -x 192.0.2.10Reverse (PTR) lookup
dig -4 example.com / dig -6 example.comForce IPv4 or IPv6 transport to the server
dig -p 5353 @127.0.0.1 example.comNon-standard port
dig -f NAMES.txt +shortBatch queries from a file, one per line

Output Control #

COMMANDDESCRIPTION
dig +short example.comAnswer data only
dig +noall +answer example.comAnswer section only, with TTLs
dig +noall +answer +ttlunits example.comTTL as 1h, 5m
dig +multiline example.com SOASOA fields on separate lines
dig +nocmd +noall +stats example.comQuery time and server only

Resolver Behaviour #

COMMANDDESCRIPTION
dig +tcp example.comUse TCP instead of UDP
dig +norecurse @192.0.2.53 example.comDo not ask the server to recurse (test its cache or authoritative data)
dig +time=2 +tries=1 example.comShort timeout, one attempt
dig +search hostApply the search domains from resolv.conf
dig +trace example.comFollow delegation from the root servers
dig +nssearch example.comAsk each authoritative server for the SOA and compare serials
dig +bufsize=1232 example.comSet the EDNS buffer size

DNSSEC #

COMMANDDESCRIPTION
dig +dnssec example.comRequest signatures; the ad flag means the resolver validated
dig example.com DNSKEY +shortZone keys
dig example.com DS +shortDelegation signer at the parent
dig +cd example.comChecking disabled: see data that fails validation

Signing a zone and troubleshooting validation: DNSSEC.

Zone Transfer #

COMMANDDESCRIPTION
dig AXFR example.com @192.0.2.53Full zone transfer, if the server permits it from you
dig IXFR=<SERIAL> example.com @192.0.2.53Incremental transfer from a serial

host and nslookup #

COMMANDDESCRIPTION
host example.comA, AAAA and MX in short form
host -t TXT example.comOne record type
host 192.0.2.10Reverse lookup
host example.com 192.0.2.53Use a given server
nslookup example.com 192.0.2.53Same query with nslookup

systemd-resolved #

COMMANDDESCRIPTION
resolvectl statusPer-link DNS servers and domains
resolvectl query example.comResolve through systemd-resolved (shows which link and protocol answered)
resolvectl flush-cachesClear the local cache
resolvectl statisticsCache hits, DNSSEC counters

Reading the Answer #

FIELDMEANING
status: NOERRORThe query worked (an empty answer means no such record type)
status: NXDOMAINThe name does not exist
status: SERVFAILThe resolver could not get an answer; often a DNSSEC or upstream failure
flags: qr rd raResponse, recursion desired, recursion available
flags: aaAnswer is authoritative
flags: adAuthenticated data: DNSSEC validated
;; Query timeRound trip to the server
SERVER:The resolver that answered

See Also #

Search all sheets

Tip: / or Ctrl/Cmd+K to open, Esc to close.