tips
36 tips Dig
One command, setting or habit at a time about Dig: what it does, the line to copy and a caveat or two.
dig 15
-
Compare the DS record at the parent with your DNSKEY key tags before and after a key change.
dig +noall +answer DS example.com -
Read whether a name does not exist or just lacks that record type, and how long resolvers cache the miss.
dig nope.iana.org @9.9.9.9 | grep -E 'status|SOA' -
Look up SRV records for services like XMPP, IMAP or Minecraft to see which host and port clients use.
dig +short SRV _imaps._tcp.gmail.com -
Query the CHAOS class to see which software and version a DNS server reports.
dig @a.iana-servers.net CH TXT version.bind +short -
Why ANY queries return HINFO or nothing, and what to ask instead.
dig ANY cloudflare.com @ns3.cloudflare.com +noall +answer -
Requests every record of a DNS zone from a server you run.
dig @192.168.1.2 example.com AXFR -
Lists the certificate authorities that a domain's CAA records allow to issue certificates.
dig CAA example.com +short -
Tests whether a DNS server answers over encrypted DoT or DoH.
dig +tls @dns.quad9.net example.com -
Prints DNS record TTLs as minutes, hours or days instead of raw seconds.
dig +noall +answer +ttlunits example.com -
Shows only the answer section of a DNS lookup, so you can read the TTL.
dig +noall +answer example.com -
Looks up the hostname that belongs to an IP address (reverse DNS).
dig -x 9.9.9.9 +short -
Prints only the answer data from a DNS lookup, without headers or statistics.
dig +short example.com -
Looks up SPF, DKIM and DMARC settings, which are stored as TXT records.
dig +short TXT example.com -
Shows RRSIG records and whether the resolver validated the answer.
dig +dnssec example.com A -
Asks a DNS server to report which anycast node or instance gave the answer.
dig @1.1.1.1 example.com +nsid
Query options 10
-
Make dig resolve a short host name the way your system does, through the search list.
dig +search nas -
Send an EDNS client subnet with a query to see which servers a CDN picks for another network.
dig @8.8.8.8 www.google.com +subnet=203.0.113.0/24 -
Ask for A, MX, NS and other records of several names in a single dig call.
dig +noall +answer example.com A example.org MX example.net NS -
Tell an authoritative answer from a cached one by reading the flags line.
dig +short NS example.com -
Forces dig to reach the resolver over IPv4 or IPv6, independent of the record type asked.
dig -6 example.com A -
Queries the HTTPS record type that tells browsers how a site can be reached.
dig HTTPS example.com +short -
Sends a dig query from a chosen local address instead of the default one.
dig -b 192.168.1.20 @192.168.1.53 example.com -
Sets a short timeout and a single try so failures show up fast.
dig +timeout=2 +tries=1 @10.0.0.53 example.com -
Asks a resolver for cached data only, without letting it query upstream.
dig @192.168.1.1 example.com +norecurse -
Queries a DNS server that runs on a port other than 53.
dig -p 5335 @127.0.0.1 example.com +short
Output control 7
-
Get dig's full answer as YAML, so a script can read fields instead of scraping text.
dig +yaml example.com A -
Keep the short output but see the server address and response time on every line.
dig +short +identify example.com @9.9.9.9 -
Stop dig from breaking base64 keys and hashes into chunks with spaces, so you can copy them.
dig DNSKEY example.com +noall +answer +split=0 -
See the exact flags and EDNS options of your outgoing query, next to the reply.
dig +qr example.com @9.9.9.9 -
Keeps your favourite dig options in a dotfile that is read on every run.
echo '+noall +answer' > ~/.digrc -
Prints SOA and key records over several lines with a label per field.
dig +multiline SOA example.com -
Prints full record lines without the header, question and statistics blocks.
dig +noall +answer example.com A
DNS and Pi-hole 4
-
Check from any machine whether Pi-hole blocks a domain, and what the client really receives.
dig @192.0.2.53 doubleclick.net A +noall +answer -
Queries every authoritative name server and prints each one's SOA serial.
dig +nssearch example.com -
Forces a DNS query over TCP to check that the firewall allows it.
dig +tcp @192.168.1.1 example.com -
Runs many DNS lookups from one file in a single dig call.
dig -f names.txt +noall +answer
Nothing in this filter yet.