| name | dns-tools |
| description | DNS query and troubleshooting using dig, nslookup, and host. Covers all record types (A, AAAA, CNAME, MX, NS, SOA, TXT, PTR, SRV, CAA), delegation tracing, DNSSEC validation, reverse lookups, zone transfer testing, TTL analysis, and split-horizon diagnosis. Use when troubleshooting DNS resolution issues, validating zone configuration, checking email/SPF/DMARC records, or confirming propagation. |
| metadata | {"author":"Ryan Loiselle","version":"1.0"} |
| compatibility | dig (BIND-utils/bind9-dnsutils), nslookup, host. macOS and Linux. Works against any recursive or authoritative resolver. |
DNS Tools Skill
DNS query, troubleshooting, and validation using dig, nslookup, and host.
dig — Core Syntax
dig [@server] [name] [type] [+options]
dig example.com
dig @8.8.8.8 example.com A
dig example.com AAAA
dig example.com MX
dig example.com NS
dig example.com SOA
dig example.com TXT
dig example.com CAA
dig _dmarc.example.com TXT
dig _smtp._tcp.example.com SRV
dig -x 142.251.41.46
dig -x 2607:f8b0:4004:c08::6a
dig Output Anatomy
; <<>> DiG 9.18 <<>> example.com A
;; QUESTION SECTION:
;example.com. IN A
;; ANSWER SECTION:
example.com. 300 IN A 93.184.216.34
;; AUTHORITY SECTION:
example.com. 3600 IN NS a.iana-servers.net.
;; ADDITIONAL SECTION:
a.iana-servers.net. 3000 IN A 199.43.135.53
;; Query time: 12 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: ...
;; MSG SIZE rcvd: 56
Flags decoded:
qr — query response
aa — authoritative answer (from authoritative NS, not cache)
rd — recursion desired (client requested recursive resolution)
ra — recursion available (server supports recursion)
ad — authenticated data (DNSSEC validated)
cd — checking disabled (DNSSEC validation disabled by client)
Useful dig Options
dig +short example.com
dig +trace example.com
dig +norec @ns1.example.com example.com
dig +noall +answer example.com MX
dig +dnssec example.com
dig +bufsize=4096 example.com DNSKEY
dig +tcp example.com ANY
dig example.com A example.com MX +noall +answer
dig -f queries.txt +short
for r in 8.8.8.8 1.1.1.1 9.9.9.9; do
echo -n "$r: "; dig @$r +stats +noall example.com | grep "Query time"
done
Record Types Reference
| Type | Description | Example value |
|---|
| A | IPv4 address | 93.184.216.34 |
| AAAA | IPv6 address | 2606:2800:220:1:248:1893:25c8:1946 |
| CNAME | Canonical name alias | example.com. |
| MX | Mail exchanger | 10 mail.example.com. |
| NS | Authoritative name server | ns1.example.com. |
| SOA | Start of Authority | Serial, refresh, retry, expire, min TTL |
| TXT | Text (SPF, DMARC, DKIM, verification) | "v=spf1 ip4:... ~all" |
| PTR | Reverse DNS | host.example.com. |
| SRV | Service locator | 10 20 443 target.example.com. |
| CAA | CA Authorization | 0 issue "letsencrypt.org" |
| DNSKEY | DNSSEC public key | Zone signing key |
| DS | Delegation Signer | Hash of child zone KSK |
| TLSA | DANE certificate association | Hash of TLS cert |
| NAPTR | Name Authority Pointer (VoIP/ENUM) | Regex-based rewrite rules |
Email DNS Records (SPF / DKIM / DMARC)
dig +short example.com TXT | grep spf
dig +short selector._domainkey.example.com TXT
dig +short _dmarc.example.com TXT
dig +short _mta-sts.example.com TXT
curl https://mta-sts.example.com/.well-known/mta-sts.txt
dig +short default._bimi.example.com TXT
DNSSEC Validation
dig +dnssec example.com | grep -E 'ad|RRSIG|DNSKEY'
dig +trace +dnssec example.com
dig +short example.com DS
unbound-host -D example.com
Zone Transfers
dig @ns1.example.com example.com AXFR
dig @ns1.example.com example.com IXFR=2024010101
dig @ns1.example.com example.com AXFR | head -20
Reverse DNS
dig -x 93.184.216.34
dig 34.216.184.93.in-addr.arpa PTR
dig -x 2606:2800:220:1:248:1893:25c8:1946
DNS Propagation and Troubleshooting
dig @ns1.example.com example.com
dig example.com
for ns in $(dig +short example.com NS); do
echo -n "$ns: "; dig @$ns +short example.com A
done
sudo dscacheutil -flushcache && sudo killall -HUP mDNSResponder
sudo systemd-resolve --flush-caches
sudo service nscd restart
for ns in $(dig +short example.com NS); do
echo -n "$ns serial: "; dig @$ns +short example.com SOA | awk '{print $3}'
done
nslookup Reference
nslookup example.com
nslookup example.com 8.8.8.8
nslookup -type=MX example.com
nslookup -type=NS example.com
nslookup -debug example.com
nslookup
> server 8.8.8.8
> set type=TXT
> _dmarc.example.com
> exit
host Reference
host example.com
host -t MX example.com
host -t NS example.com
host 93.184.216.34
host -a example.com
Common DNS Troubleshooting Patterns
| Symptom | Check | Command |
|---|
| Resolution works from some resolvers, not others | Cache poisoning / negative TTL | dig +trace example.com on failing resolver |
| NXDOMAIN unexpectedly | Typo, zone not delegated, glue missing | dig +trace example.com |
| SERVFAIL | DNSSEC failure, broken delegation | dig +dnssec example.com + dnsviz.net |
| Email delivery rejected | SPF/DKIM/DMARC misconfigured | dig +short _dmarc.example.com TXT |
| Slow resolution | High TTL on CNAME chain / resolver RTT | dig +stats example.com |
| Split-horizon mismatch | Internal vs external DNS returning different answers | Compare dig @internal-resolver vs dig @8.8.8.8 |
| PTR missing | rDNS not delegated / not configured | dig -x <ip> + dig <arpa-form> PTR |
| CAA blocking cert issuance | CAA record restricts CA | dig example.com CAA |
DNS Architecture Reference
Resolution hierarchy:
Client → Local Resolver (OS cache) → Recursive Resolver (ISP/DoH/DoT)
→ Root NS (.) → TLD NS (.com) → Authoritative NS (example.com)
Zone types:
Primary (master) — writable; single source of truth for zone
Secondary (slave) — read-only copy via AXFR/IXFR
Stub — contains NS records only; used for conditional delegation
Forward — forwards queries for a zone to another server
Hint — root hints file (named.root / db.root)
Split-horizon DNS:
Same zone name; different views per source IP
Internal view: returns RFC 1918 / private addresses
External view: returns public routable addresses
Implemented in BIND9 (view clauses), Microsoft DNS (policies), Infoblox (DNS views)
DNSSEC chain of trust:
Root (.) → TLD (.com) → Domain (example.com)
Each zone signs its records with ZSK; parent zone holds DS record for child KSK
Validation: recursive resolver checks RRSIG → DS → DNSKEY chain up to root trust anchor
DNS_TOOLS_KNOWLEDGE
Append discoveries here. Format: YYYY-MM-DD: <note>