dig Commands Reference
Essential dig commands for DNS lookups and troubleshooting
🔍 Basic DNS Lookups
Simple A record lookup
dig example.comPerforms a basic DNS lookup for A records of the specified domain.
Short answer format
dig example.com +shortReturns only the IP address(es), without additional details.
Query with specific nameserver
dig @8.8.8.8 example.comQuery using Google's DNS server (8.8.8.8). Replace with any nameserver IP.
Query multiple domains
dig example.com google.com cloudflare.com📝 Querying Different Record Types
A record (IPv4 address)
dig example.com AAAAA record (IPv6 address)
dig example.com AAAAMX record (mail servers)
dig example.com MXNS record (nameservers)
dig example.com NSTXT record (text records)
dig example.com TXTCommonly used for SPF, DKIM, and domain verification records.
CNAME record (canonical name)
dig www.example.com CNAMESOA record (start of authority)
dig example.com SOAPTR record (reverse DNS lookup)
dig -x 8.8.8.8Looks up the domain name associated with an IP address.
ANY record (all available records)
dig example.com ANYNote: Many DNS servers now limit or disable ANY queries for security reasons.
🔒 DNSSEC Queries
Check DNSSEC validation
dig example.com +dnssecShows DNSSEC signatures if available. Look for RRSIG records in the answer.
Query DNSKEY records
dig example.com DNSKEY +shortQuery DS records (delegation signer)
dig example.com DS +shortCheck with DNSSEC validation disabled
dig example.com +cdThe +cd flag disables DNSSEC validation checking.
🔧 Troubleshooting and Advanced Options
Trace DNS resolution path
dig example.com +traceShows the complete DNS resolution path from root servers to authoritative nameservers.
Disable recursion (query authoritative server only)
dig @ns1.example.com example.com +norecurseShow query time and statistics
dig example.com +statsSet query timeout
dig example.com +time=5Sets timeout to 5 seconds (default is 5 seconds per attempt).
Set number of retry attempts
dig example.com +tries=3Use TCP instead of UDP
dig example.com +tcpUseful for large responses or when UDP is blocked.
Show only the answer section
dig example.com +noall +answerCheck specific port
dig @8.8.8.8 -p 5353 example.comQuery DNS server on a non-standard port (default is 53).
💡 Common Use Cases
Check if domain is using Cloudflare
dig example.com NS +shortLook for nameservers ending in cloudflare.com
Verify SPF records for email
dig example.com TXT +short | grep spfCheck DKIM record
dig default._domainkey.example.com TXT +shortReplace default with your DKIM selector.
Check DMARC policy
dig _dmarc.example.com TXT +shortBatch query from file
dig -f domains.txt +shortQuery all domains listed in domains.txt (one domain per line).
Compare responses from different DNS servers
dig @8.8.8.8 example.com +short
dig @1.1.1.1 example.com +shortCompare Google DNS (8.8.8.8) with Cloudflare DNS (1.1.1.1).
🎨 Output Customization
Minimal output (question and answer only)
dig example.com +noall +answerShow question section
dig example.com +noall +question +answerInclude comments in output
dig example.com +commentsMultiline output (easier to read)
dig example.com +multilineParticularly useful for SOA and TXT records.