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.comPerforms multiple DNS queries in a single command, showing results for each domain.
📝 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.
CAA record (Certificate Authority Authorization)
dig example.com CAAShows which Certificate Authorities are authorized to issue certificates for the domain. CAs must check CAA records before issuance (RFC 8659).
SRV record (service location)
dig _imaps._tcp.example.com SRVLocates servers for specific services. Format is _service._proto.name.
HTTPS/SVCB record (service binding)
dig example.com HTTPSQueries HTTPS service binding records (RFC 9460). Used for ALPN hints and ECH keys.
🔐 Certificate & TLS-Related Lookups
DANE/TLSA records
dig _443._tcp.example.com TLSADANE TLSA records bind TLS certificates to DNS names via DNSSEC.
SMTP DANE records
dig _25._tcp.mail.example.com TLSACheck DANE TLSA records for SMTP servers.
ACME DNS-01 challenge verification
dig _acme-challenge.example.com TXT +shortVerify DNS-01 challenge TXT record before requesting ACME certificate.
MTA-STS policy records
dig _mta-sts.example.com TXT +short
dig _smtp._tls.example.com TXT +shortMTA-STS forces authenticated TLS for email delivery.
CAA authorization check
dig example.com CAA +shortVerify which CAs are authorized. Empty = any CA may issue.
🔄 Zone Transfers
Full zone transfer (AXFR)
dig @ns1.example.com example.com AXFRRequests complete zone file copy. Most servers restrict this.
Incremental zone transfer (IXFR)
dig @ns1.example.com example.com IXFR=2024010100Only changes since given serial.
🔒 DNSSEC Queries
Check DNSSEC validation
dig example.com +dnssecShows DNSSEC signatures if available. Look for RRSIG records in the answer and the ad (authenticated data) flag in the response header.
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 +statsDisplays query statistics including response time and message size. Statistics are shown by default; use +nostats to hide them.
Set 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).
Set EDNS buffer size
dig example.com +bufsize=1232Recommended by DNS Flag Day 2020 to avoid fragmentation.
Identify responding server
dig example.com +short +identifyShows which server responded to the query.
💡 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.