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
9dig example.comFull answer section
dig example.com +shortJust the answer values
dig A example.comA records only
dig AAAA example.comIPv6 records
dig CNAME www.example.comCNAME lookup
dig MX example.comMail exchange records
dig NS example.comNameservers for the domain
dig TXT example.comTXT records (SPF, verification)
dig ANY example.comAll records (often restricted)
Servers & Resolution
5dig @1.1.1.1 example.comQuery a specific resolver
dig +trace example.comWalk root → TLD → authority
dig +short -x 8.8.8.8Reverse lookup (PTR)
dig example.com +ttlidInclude TTLs in output
dig example.com +time=5 +tries=2Timeout and retry control
Batch & Parsing
4dig +short example.com @127.0.0.1 -p 5353Query a local cache (on port 5353)
for d in $(cat domains.txt); do dig +short $d; doneLoop over domains
dig example.com | grep -A5 'ANSWER SECTION'Grep the answer section
dig ANY example.com +noall +answerAnswer only, no fluff