~/cheat-sheets / dig
dig cheat sheet
The dig queries I actually use for DNS migrations and mail issues – searchable and copyable in one click.
30 commands
Basic lookups
Query the IPv4 address (A record)
dig example.com AQuery the IPv6 address (AAAA record)
dig example.com AAAAShow mail servers with priority
dig example.com MX +shortAll TXT records (SPF, verifications)
dig example.com TXT +shortNameservers responsible for the zone
dig example.com NS +shortSOA with serial number (check zone changes)
dig example.com SOA +shortCAA: which CAs may issue certificates
dig example.com CAA +shortShow the CNAME target of a hostname
dig www.example.com CNAME +shortPrint only the answer section incl. TTL
dig +noall +answer example.com
Resolvers & nameservers
Query through a specific resolver (Cloudflare)
dig @1.1.1.1 example.com A +shortAsk the authoritative nameserver directly (no cache)
dig @ns1.example.com example.com A +norecurseFollow the delegation from the root zone
dig +trace example.comCompare answers from several public resolvers
for r in 1.1.1.1 8.8.8.8 9.9.9.9; do echo "$r: $(dig +short @$r example.com A)"; doneCheck the remaining TTL in the resolver cache
dig @1.1.1.1 +noall +answer example.com AForce the query over TCP instead of UDP
dig +tcp example.com ASend the query over IPv6 transport
dig -6 @2606:4700:4700::1111 example.com A
Mail: SPF, DKIM, DMARC, PTR
Filter out the SPF record
dig example.com TXT +short | grep spf1Query the DMARC policy
dig _dmarc.example.com TXT +shortQuery the DKIM public key for a selector
dig SELECTOR._domainkey.example.com TXT +shortReverse lookup (PTR) of an IPv4 address
dig -x 203.0.113.10 +shortReverse lookup (PTR) of an IPv6 address
dig -x 2001:db8::1 +shortQuery an SRV record (e.g. mail autoconfig)
dig _submission._tcp.example.com SRV +short
DNSSEC
Show the answer with RRSIG signatures
dig example.com A +dnssec +multiQuery the zone's DNSKEY records
dig example.com DNSKEY +shortCheck the DS record in the parent zone
dig example.com DS +shortCheck validation: ad flag = DNSSEC valid
dig @1.1.1.1 example.com A +dnssec | grep flagsQuery with validation disabled (isolate SERVFAIL)
dig @1.1.1.1 example.com A +cd
Zones & advanced
Attempt a zone transfer (should be REFUSED for outsiders)
⚠ Careful: changes or deletes datadig @ns1.example.com example.com AXFRShow the nameserver ID (identify anycast node)
dig @ns1.example.com example.com SOA +nsidRun queries in batch from a file
dig -f hosts.txt +noall +answer
No match.
New articles by e-mail
One e-mail per new article. No tracking, unsubscribe any time. As a thank-you after confirming: my “Server operations & patching” checklist (PDF).