DNS Fundamentals
The internet's global telephone book
DNS maps human names (app.example.com) to IPs through a hierarchy of resolvers. Every cloud service touchpoint — LBs, databases, endpoints — is ultimately an A/AAAA/CNAME record.
What you will learn
- Explain the resolver → root → TLD → authoritative chain
- Distinguish A, AAAA, CNAME, NS, SOA records
- Debug resolution with dig/nslookup
A recursive resolver asks the root and TLD servers for the address of the authoritative nameserver, then asks it for the record. Caches along the way make repeat lookups fast — and TTL controls how fast changes propagate.
What is this?
DNS records: A (IPv4), AAAA (IPv6), CNAME (alias), NS (nameservers), SOA, MX, TXT, SRV. Resolution: stub → recursive resolver → root (.), TLD (com.) → authoritative nameserver that holds hostnames. Record lifecycle: DNS queries cached per TTL; changes take effect only after caches expire. Cloud offerings: Route 53 (public + private hosted zones), Azure DNS, Cloud DNS.
Why do you need it?
- Changing a service endpoint (new LB IP) is a DNS edit — the front door to any migration.
- DNS is the first place 'where is this app?' is answered; slow/failing DNS stalls everything.
- Health checks + failover policies in managed DNS give simple multi-region routing.
- CNAME/alias records let you repoint a hostname to a cloud resource cleanly.
Mental model
Asking a phone operator to look up a business in a city directory
DNS resolution
Your call goes to the operator (resolver); they check the directory hierarchy (root/TLD), find the business's listed number (authoritative record), and give it to you after verifying (answer).
How it works
- The client asks a recursive resolver (usually your ISP or 8.8.8.8) for app.example.com.
- Resolver walks root → .com TLD → example.com's authoritative nameservers (NS records).
- Authoritative server answers with the current A/AAAA (or CNAME→the real host).
- The answer is cached at the resolver for the record's TTL (seconds to days).
- Mismatches/expirations cause lookup failures — the eternal 'it works locally but not here' class.
Resolution path.
Examples
Inspect DNS with dig
dig app.example.com A +shortdig +trace example.com # walk root -> TLD -> authdig example.com NS # who is authoritativedig @8.8.8.8 example.com # force a specific resolverdig shows the exact chain and TTL; +trace walks the hierarchy to prove where an answer comes from.
In production
- Route 53 public hosted zone carries the app's A record aliased to an ALB.
- Azure custom domain DNS validates with TXT + CNAME before the CDN serves it.
- Private hosted zones resolve internal service names to private LBs within a VNet.
Best practices
- Keep TTL short (30-60s) on records you may change (load balancers, failover).
- Use alias/CNAME to resources so IP changes don't require a DNS edit.
- Monitor resolution with synthetic queries from the regions that matter.
- Never point traffic to an IP that can change (EIPs are the exception, not the norm).
Common mistakes
- Long TTL on a record you'll flip at deploy → outage while caching matches it out.
- CNAME at the zone apex (invalid per RFC for many setups) instead of alias.
- Forgetting NS/RFC glue when moving hosts — delegation silently breaks.
- Relying on cached DNS instead of updating the authoritative zone to fix an outage.
Common issues
Clients in some networks see an old IPA cached TTL + those networks' resolvers
Lower TTL, wait out old caches, and confirm the new record at the authoritative server.
Zone won't update in Route 53Change batch syntax or insufficient IAM
Validate the change-batch JSON and IAM route53:ChangeResourceRecordSets permission.
Debugging tips
- dig +trace pinpoints which layer misbehaves (root/TLD/auth/resolver).
- Different answers by resolver = caching TTL or split-horizon view — compare with @target.
- 'Name not found' when the zone exists: check NS delegation and SOA.
- Record updated but clients stuck: wait TTL + retry; lower TTL next time.
Interview checkpoint
Hands-on lab
- Trace resolution with dig/nslookup
- Inspect NS/SOA/TTL of a real domain
- Diagnose slow propagation
Traverse and Debug the DNS Chain
20 min · beginner
Quick quiz
Which record type maps a hostname directly to an IPv4 address?