api.example.com
curl api.internal.corp
dig api.internal.corp
getaddrinfo()
mDNSResponder
example.com
api.example.com
https://api.example.com/v1/users
api.example.com
api.example.com
/etc/resolv.conf
# /etc/resolv.conf — the file that decides where your DNS queries go
nameserver 192.168.1.1 # your router, probably
nameserver 8.8.8.8 # fallback: Google
search corp.internal # try appending this domain to short names
# /etc/resolv.conf — the file that decides where your DNS queries go
nameserver 192.168.1.1 # your router, probably
nameserver 8.8.8.8 # fallback: Google
search corp.internal # try appending this domain to short names
# /etc/resolv.conf — the file that decides where your DNS queries go
nameserver 192.168.1.1 # your router, probably
nameserver 8.8.8.8 # fallback: Google
search corp.internal # try appending this domain to short names
/etc/resolv.conf
db.corp.internal
search corp.internal
api.example.com
api.example.com
api.example.com
example.com
example.com
api.example.com
getaddrinfo()
Query trace for api.example.com: → root nameserver (hardcoded IPs) ← "ask .com TLD at 192.5.6.30" → .com TLD nameserver (192.5.6.30) ← "ask ns1.example.com at 93.184.216.10" → ns1.example.com (93.184.216.10) ← "api.example.com A 198.51.100.42 TTL 300" → your stub resolver ← 198.51.100.42
Query trace for api.example.com: → root nameserver (hardcoded IPs) ← "ask .com TLD at 192.5.6.30" → .com TLD nameserver (192.5.6.30) ← "ask ns1.example.com at 93.184.216.10" → ns1.example.com (93.184.216.10) ← "api.example.com A 198.51.100.42 TTL 300" → your stub resolver ← 198.51.100.42
Query trace for api.example.com: → root nameserver (hardcoded IPs) ← "ask .com TLD at 192.5.6.30" → .com TLD nameserver (192.5.6.30) ← "ask ns1.example.com at 93.184.216.10" → ns1.example.com (93.184.216.10) ← "api.example.com A 198.51.100.42 TTL 300" → your stub resolver ← 198.51.100.42
dig @ns1.example.com api.example.com
api.example.com CNAME loadbalancer.us-east-1.elb.amazonaws.com
api.example.com CNAME loadbalancer.us-east-1.elb.amazonaws.com
api.example.com CNAME loadbalancer.us-east-1.elb.amazonaws.com
api.example.com
loadbalancer.us-east-1.elb.amazonaws.com
example.com
example.com
example.com.cdn.cloudflare.net
dig example.com A
example.com
curl api.internal.corp
dig api.internal.corp
/etc/resolv.conf
getaddrinfo()
/etc/nsswitch.conf
# /etc/nsswitch.conf
hosts: files dns myhostname
# /etc/nsswitch.conf
hosts: files dns myhostname
# /etc/nsswitch.conf
hosts: files dns myhostname
/etc/resolv.conf
/etc/resolv.conf
dig api.internal.corp
getaddrinfo()
# What does the authoritative server say right now?
dig @ns1.example.com api.example.com A # What does your configured resolver return (including its cache)?
dig api.example.com A # What would an uncached query to a specific public resolver return?
dig @8.8.8.8 api.example.com A # Trace the full recursive delegation chain
dig +trace api.example.com A # Show what getaddrinfo() would return (follows /etc/hosts, nsswitch.conf)
# getent is part of glibc-utils on Debian/Ubuntu; not available on macOS
getent hosts api.example.com # Check your resolver configuration
cat /etc/resolv.conf
resolvectl status # systemd-resolved environments
# What does the authoritative server say right now?
dig @ns1.example.com api.example.com A # What does your configured resolver return (including its cache)?
dig api.example.com A # What would an uncached query to a specific public resolver return?
dig @8.8.8.8 api.example.com A # Trace the full recursive delegation chain
dig +trace api.example.com A # Show what getaddrinfo() would return (follows /etc/hosts, nsswitch.conf)
# getent is part of glibc-utils on Debian/Ubuntu; not available on macOS
getent hosts api.example.com # Check your resolver configuration
cat /etc/resolv.conf
resolvectl status # systemd-resolved environments
# What does the authoritative server say right now?
dig @ns1.example.com api.example.com A # What does your configured resolver return (including its cache)?
dig api.example.com A # What would an uncached query to a specific public resolver return?
dig @8.8.8.8 api.example.com A # Trace the full recursive delegation chain
dig +trace api.example.com A # Show what getaddrinfo() would return (follows /etc/hosts, nsswitch.conf)
# getent is part of glibc-utils on Debian/Ubuntu; not available on macOS
getent hosts api.example.com # Check your resolver configuration
cat /etc/resolv.conf
resolvectl status # systemd-resolved environments
dig @authoritative - man 1 dig — More flags than you'll ever need, but +trace, +short, and @server will cover 90% of debugging sessions.
- DNS and BIND, 5th ed. — The definitive reference. Dense. Worth having on a shelf.
- How DNS Works (howdns.works) — Comic-style visual walkthrough of the resolution chain. Good for sharing with someone who's new to it.
- Cloudflare's DNS Learning Center — Technically accurate, well-illustrated, and they have a vested interest in you understanding DNS.
- RFC 1034, RFC 1035 — The original 1987 DNS specs. Remarkably readable for an RFC. Much of what's described here is in those two documents.