Knowledge Guide
HomeSystem DesignDNS

DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive)

DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC

The core DNS pages cover the resolution walk and DNS-based load balancing. This page fills the senior gaps: why the hierarchy exists at all, the glue-record chicken-and-egg, the UDP wire substrate and its limits, the record-type vocabulary, the security story (Kaminsky poisoning → DNSSEC) that a senior always probes, client-side failover, and the back-of-envelope numbers.

1. Why a hierarchy — from first principles

DNS is a hierarchy for three compounding reasons: delegation of administrative authority (the .com registry delegates bank.com to the bank, who runs their own zone — no central authority edits everyone's records); bounded knowledge per node (a root server knows only the TLD name servers, not billions of hostnames — each tier knows just enough to point one level down); and caching that collapses read load (TTLs let resolvers answer ~80–90%+ of queries locally, so the roots see a tiny fraction of real traffic). Miss any one and the design looks arbitrary; together they force the tree.

2. Resolution and the glue-record chicken-and-egg

The naive trace says "ask the bank.com name server" — but that NS is itself named ns1.bank.com, whose address is inside the very zone you're trying to resolve. To break the loop, the parent (.com) returns the NS's A/AAAA record directly in the ADDITIONAL section — a glue record. Glue is required whenever a name server is in-domain (in-bailiwick); without it resolution can't bootstrap. This is a favourite "walk me through it exactly" follow-up.

3. The wire substrate: UDP, 512 bytes, TC, EDNS0

DNS is UDP-first on port 53 — one datagram out, one back, no handshake (that's what makes resolution fast, and also what makes it forgeable, see §5). Classic DNS caps a UDP response at 512 bytes; if the answer is larger the server sets the TC (truncated) bit and the client retries over TCP. EDNS0 negotiates larger UDP payloads (e.g. 4096 B) and carries extensions — DNSSEC signatures, and EDNS Client Subnet (lets the resolver hint the client's network so a CDN/GeoDNS answers with a nearby edge). Modern privacy variants wrap it in TLS: DoT (port 853) and DoH (over HTTPS).

4. Record-type vocabulary

5. Security: why plain DNS is forgeable, and the Kaminsky attack

Unauthenticated UDP DNS has no proof of who answered — the resolver accepts the first reply that matches the query's 16-bit transaction ID and the (source IP, port) tuple. An off-path attacker can flood forged replies guessing the txn ID. Kaminsky's insight (2008): query a random subdomain (rnd123.bank.com) so the answer is never cached — the attacker can retry the race indefinitely — and stuff the forged reply's authority/additional section with bank.com NS = attacker-IP, poisoning the entire domain, not one record.

Mitigations: randomize the source port as well as the txn ID (adds ~16 bits → ~2³² guesses, making blind spoofing infeasible), plus 0x20 case randomization for a few more bits. The real integrity fix is DNSSEC: each zone signs its records (RRSIG) and the parent signs the child's key (DS), forming a chain of trust from the root — so a resolver can cryptographically verify the answer wasn't forged. (DNSSEC gives integrity/authenticity, not confidentiality; DoT/DoH give confidentiality.)

6. Redundancy and client-side failover

Every tier is replicated: 13 root letters are thousands of anycast instances; a zone must have ≥2 NS; a resolver retries the next server on timeout. Distinguish failure kinds: SERVFAIL (transient — retry another server) vs NXDOMAIN (authoritative "no such name" — cached negatively per the SOA minimum TTL, so you don't re-ask). On the client, getaddrinfo returns all A/AAAA records; the OS/browser tries the next address if one is dead, and Happy Eyeballs (RFC 8305) races IPv4 and IPv6 in parallel so a broken IPv6 path doesn't stall the connection. This client resilience means a stale/dead A record degrades gracefully rather than hard-failing — the base pages slightly overstate the single-IP failure risk.

7. Back-of-envelope

Judgment layer & pitfalls

Takeaways


Re-authored/Deepened for this guide.

🤖 Don't fully get this? Learn it with Claude

Stuck on DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive)? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🎨 Explain it visually

Build the mental picture, not memorization.

I just read a lesson on **DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive)** (System Design) and want to truly understand it. Explain DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive) from first principles using ONE vivid real-world analogy and a visual mental model — draw it as ASCII art or a clear step-by-step diagram — with a concrete example using real numbers. Then ask me one question to check I got the mental picture, and wait for my reply. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🤔 Walk me through it (interactive)

Socratic — adapts to where you're stuck.

Teach me **DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive)** interactively. Ask me ONE guiding question at a time, wait for my answer, and adapt to my confusion — build the idea with me step by step instead of explaining it all at once. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧪 Quiz me & fix my gaps

Active recall exposes what you missed.

Quiz me on **DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive)** with 5 questions, easy to tricky, ONE at a time. Tell me if each answer is right; at the end, explain clearly what I got wrong and why. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🧠 Make it stick

Intuition + hook + flashcards for long-term memory.

Help me remember **DNS — Hierarchy, Glue, Transport, Records, Poisoning & DNSSEC (Deep Dive)** for the long term: give the one-sentence intuition, a memorable hook/mnemonic, a tiny worked example, and 3 active-recall flashcards (Q -> A). If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes