dig DNS Queries
The primary DNS diagnostic tool. Record lookups, delegation tracing, DNSSEC validation, and scripting patterns.
Basic Queries
dig example.com
Returns QUESTION, ANSWER, AUTHORITY, and ADDITIONAL sections plus query statistics. The default record type is A.
dig example.com +short
Strips all section headers and metadata. Pipe-friendly: IP=$(dig +short example.com).
dig example.com A +noall +answer
+noall suppresses everything, +answer re-enables just the answer section. Gives you record data with field alignment but no noise.
Record Type Queries
dig example.com AAAA +short
Returns AAAA records. Empty output means no IPv6 address configured.
dig example.com MX +short
Returns priority and hostname pairs. Lower preference value means higher priority server.
dig example.com TXT +short
dig example.com NS +short
Which DNS servers are responsible for this zone.
dig example.com SOA +short
Returns primary NS, admin email, serial number, and timers (refresh/retry/expire/minimum).
dig example.com CNAME +short
Returns the canonical target name. Empty if the name is not an alias.
dig example.com ANY +noall +answer
Some servers refuse ANY queries (RFC 8482). Not reliable for enumeration.
Active Directory Service Discovery
dig _ldap._tcp.dc._msdcs.inside.domusdigitalis.dev SRV +short
Finds domain controllers via DNS. Essential for domain join, Kerberos, and LDAP client configuration.
dig _kerberos._tcp.inside.domusdigitalis.dev SRV +short
Locates Kerberos Key Distribution Centers. Linux kinit and sssd use this for authentication.
Targeting Specific Servers
dig @10.50.1.50 inside.domusdigitalis.dev A +short
Test AD DNS directly. Proves whether the record exists on that server regardless of your resolver chain.
dig @8.8.8.8 example.com A +short
Differences between local and public results reveal split-horizon configuration or cache poisoning.
Reverse Lookups
dig -x 10.50.1.20 +short
Reverse DNS. Critical for RADIUS authentication (ISE validates forward/reverse match) and SSH host verification.
dig +short example.com | while read ip; do dig -x "$ip" +short; done
RADIUS, SMTP, and Kerberos all require matching forward and PTR records. This pipeline validates both directions.
Tracing and Debugging
dig example.com +trace
Shows root → TLD → authoritative resolution path. Reveals where delegation breaks or which server returns the answer.
dig example.com +trace +nodnssec
Suppresses RRSIG and DNSKEY records from trace output. Easier to read when you only care about delegation.
dig example.com +norecurse @ns1.example.com
Asks the server what it knows directly without chasing referrals. Tests whether a server is actually authoritative.
DNSSEC Queries
dig example.com +dnssec
Shows RRSIG records. The ad flag in the response header means the resolver validated the DNSSEC chain.
dig example.com +dnssec +cd
The +cd flag tells the resolver to return the answer even if DNSSEC validation fails. Diagnostic use only.
Zone Transfer and Replication
dig -t AXFR example.com @ns1.example.com
Pulls the entire zone if the server allows it. A successful AXFR from an unauthorized client means misconfigured allow-transfer.
dig +nssearch example.com
Queries every NS record holder for the SOA. Serial number mismatches reveal replication delays or failed zone transfers.
TTL and Statistics
dig example.com +noall +answer +ttlid
The TTL column shows seconds remaining in cache. Query repeatedly to watch it decrement — useful for confirming cache behavior during migrations.
dig example.com +stats +noall
Returns query time in milliseconds, responding server, and message size. Useful for latency benchmarking across resolvers.
Batch and Scripting Patterns
dig +short -f domains.txt
Processes a file of domains. Pipe to awk for formatting or aggregation.
for ip in 10.50.1.{1..254}; do
result=$(dig -x "$ip" +short 2>/dev/null)
[[ -n "$result" ]] && printf "%-16s %s\n" "$ip" "$result"
done
Scans a subnet for PTR records. printf aligns output for readability.
Email Security Lookups
dig +short txt _dmarc.example.com
Returns the DMARC policy string (v=DMARC1; p=reject; …).
dig +short txt default._domainkey.example.com
Retrieves the public key used for email signature verification. The selector (default) varies by provider.
See Also
-
nslookup — legacy cross-platform alternative
-
Troubleshooting — systematic DNS debugging
-
DNSSEC — validation and trust chain inspection