DNS In Depth
Networking Fundamentals
Chapter 9 · DNS In Depth
host1 already covers DNS practically — adding records at a registrar, moving DNS to Cloudflare. This chapter doesn't repeat that; it goes underneath it, to the actual protocol-level mechanics host1 never needed to explain.
What host1 Already Covered (And What This Chapter Adds)
host1 is about managing DNS records — creating an A record, pointing a domain at a new host. This chapter assumes that part is already familiar and instead explains what actually happens, step by step, the moment a DNS query gets made — a resolution process host1 never walked through.
The DNS Hierarchy — Root, TLD, Authoritative
DNS is a hierarchical, distributed database, not one central lookup table anywhere. Three tiers matter: root servers (13 logical root server clusters worldwide, knowing only where to find TLD servers), TLD servers (one set per top-level domain — .com, .org, .net — knowing where to find authoritative servers for domains under that TLD), and authoritative servers (holding the actual records for one specific domain — e.g. the nameservers a domain's own registrar or Cloudflare setup in host1 points to).
The Resolution Process, Step by Step
Resolving www.example.com from scratch, assuming nothing is cached anywhere:
- The application asks the operating system's own stub resolver.
- The stub resolver asks a recursive resolver — the ISP's own DNS server, or a public one like
8.8.8.8or1.1.1.1. - The recursive resolver asks a root server: "who handles
.com?" - The root server responds with the address of a
.comTLD server. - The recursive resolver asks that TLD server: "who is authoritative for
example.com?" - The TLD server responds with
example.com's own authoritative nameservers. - The recursive resolver asks that authoritative nameserver directly: "what is the A record for
www.example.com?" - The authoritative server responds with the actual IP address.
- The recursive resolver caches the answer and returns it up the chain to the stub resolver, and finally to the application.
This full chain usually takes only milliseconds, and is almost always shortened dramatically by caching at multiple levels along the way — covered next.
Caching and TTL
Every DNS record carries a TTL (time to live) — how long a resolver is allowed to cache the answer before it has to ask again. This is exactly why a DNS change (updating an A record after moving hosts, per host1's own material) doesn't take effect everywhere instantly — cached copies at resolvers scattered around the world keep serving the old answer until their own individual TTL expires. This is the concrete mechanism behind a genuinely common source of confusion: "I changed my DNS and nothing happened."
Record Types, Beyond A
| Record | Purpose | Example |
|---|---|---|
| A | Maps a name to an IPv4 address | example.com → 203.0.113.10 |
| AAAA | Maps a name to an IPv6 address | example.com → 2001:db8::1 |
| CNAME | Alias pointing to another name | www.example.com → example.com |
| MX | Identifies the mail server for a domain | example.com → mail.example.com |
| TXT | Arbitrary text, often for verification/SPF/DKIM | "v=spf1 include:_spf.example.com ~all" |
| NS | Delegates a domain to specific nameservers | example.com → ns1.registrar.com |
host1 already covers using several of these practically — this table is the formal, precise reference definition underneath that practical usage.
Why DNS Mostly Uses UDP
Revisiting net1-7's own closing note directly: a typical DNS query and response is small, and UDP's complete lack of handshake overhead (no three-way handshake, per net1-7) makes a single query dramatically faster than establishing a full TCP connection just to ask one small question. TCP fallback happens specifically when a response is too large for a single UDP packet (historically capped at 512 bytes, extended by EDNS0) or during zone transfers between authoritative servers themselves.
dig example.com or nslookup example.com trace a real DNS query directly, showing which server actually answered and what TTL came back with it — net1-10 covers both alongside the rest of this course's diagnostic toolkit.
Hands-On Exercises
Using this chapter's own step-by-step resolution process, explain what a root server does and does not know about www.example.com specifically.
📄 View solutionA site owner updates their A record to point at a new server, then reports the site is still loading from the old server 20 minutes later. Using this chapter's own TTL/caching material, explain the most likely cause.
📄 View solutionA team lowers their DNS record's TTL to 60 seconds on the same day they plan to migrate servers, assuming this guarantees a fast, clean cutover. Using this chapter's own warn-box, explain the flaw in their timing.
📄 View solutionChapter 9 Quick Reference
- DNS is hierarchical: root → TLD → authoritative servers, not one central database
- Full resolution: stub resolver → recursive resolver → root → TLD → authoritative → answer cached back up the chain
- TTL — how long a resolver may cache an answer before asking again; the real reason DNS changes propagate gradually
- A, AAAA, CNAME, MX, TXT, NS — the core record types, formally defined here beyond host1's own practical usage
- DNS mostly runs over UDP for speed (net1-7); TCP fallback for large responses or zone transfers
- Lower a TTL well before a migration, not at the same time — the change itself is bound by the old TTL