dig Cheat Sheet

Query DNS records — A/AAAA, CNAME, MX, TXT, and the iterative trace that reveals the whole resolution path.

Networking3 sections · 18 commands
⌘K

Basic Queries

9
dig example.com

Full answer section

dig example.com +short

Just the answer values

dig A example.com

A records only

dig AAAA example.com

IPv6 records

dig CNAME www.example.com

CNAME lookup

dig MX example.com

Mail exchange records

dig NS example.com

Nameservers for the domain

dig TXT example.com

TXT records (SPF, verification)

dig ANY example.com

All records (often restricted)

Servers & Resolution

5
dig @1.1.1.1 example.com

Query a specific resolver

dig +trace example.com

Walk root → TLD → authority

dig +short -x 8.8.8.8

Reverse lookup (PTR)

dig example.com +ttlid

Include TTLs in output

dig example.com +time=5 +tries=2

Timeout and retry control

Batch & Parsing

4
dig +short example.com @127.0.0.1 -p 5353

Query a local cache (on port 5353)

for d in $(cat domains.txt); do dig +short $d; done

Loop over domains

dig example.com | grep -A5 'ANSWER SECTION'

Grep the answer section

dig ANY example.com +noall +answer

Answer only, no fluff