Knowledge Guide
HomeSystem DesignDNS

DNS Resolution Process

The DNS resolution process converts a domain name into an IP address by walking a distributed, hierarchical tree of name servers. A client's stub resolver asks a recursive resolver to do the work; the recursive resolver then walks the hierarchy — root, top-level domain (TLD), authoritative — on the client's behalf, caching results along the way to avoid repeating that walk on every request.

1. Recursive and iterative DNS queries

There are two query styles involved in a single resolution, used by different parties in the chain.

In short: the stub resolver only ever issues one recursive query; the recursive resolver issues a chain of iterative queries against the hierarchy to satisfy it.

diagram
diagram

2. A worked trace: resolving www.example.com on a cold cache

The table below is a real, verifiable trace — every IP and name server can be checked with dig against the live public DNS hierarchy.

StepWho asks whomQueryResponse
1Stub resolver → recursive resolverA? www.example.com(held open until step 5 completes)
2Recursive resolver → root server (a.root-servers.net, 198.41.0.4)A? www.example.comReferral: ask the .com TLD servers
3Recursive resolver → .com TLD server (a.gtld-servers.net, 192.5.6.30)A? www.example.comReferral: ask example.com's name servers — hera.ns.cloudflare.com, elliott.ns.cloudflare.com
4Recursive resolver → authoritative server (hera.ns.cloudflare.com, 172.64.32.162)A? www.example.comAnswer: A 172.66.147.243, A 104.20.23.154, TTL 300s
5Recursive resolver → stub resolver(delivering the answer from step 4)172.66.147.243 (client caches it for the TTL window)

Note on currency: for roughly two decades, example.com resolved to a single Verisign/Edgecast-hosted address, 93.184.216.34, with a 24-hour TTL. IANA re-platformed the reserved example domains in 2024; as of this writing they are served from Cloudflare's anycast network under different IPs and a much shorter TTL (a few hundred seconds instead of a day). The lesson generalizes beyond this one domain: DNS answers, name server assignments, and even TTL policy for a zone can all change over time, so a resolution trace is only as trustworthy as the freshness of the data behind it — treat any hard-coded IP in a write-up (including this one) as a snapshot, not a permanent fact, and re-verify with dig or nslookup before relying on it.

3. Counting the round trips

On a fully cold cache, that worked trace costs four network round trips in total: three between the recursive resolver and the DNS hierarchy — root, then .com TLD, then example.com's authoritative server — plus one between the stub resolver and the recursive resolver to carry the final answer back to the client. On a warm cache, some or all of those hierarchy round trips are skipped, because the resolver already holds a cached referral or a cached answer within its TTL window; a fully warm cache costs just the one stub-to-resolver round trip.

4. DNS caching and TTL (Time To Live)

To avoid repeating this walk for every request, resolvers and servers cache the results of previous queries. When a resolver receives a query, it first checks its cache; if the answer is already there, it returns it immediately without contacting any other server, saving both time and network traffic.

Each DNS record carries a Time To Live (TTL) value, measured in seconds, that specifies how long the record may be kept in cache. Once the TTL expires, the cached entry is discarded so that stale information isn't served — which is exactly why a zone operator who changes infrastructure (as in the example.com case above) can rely on old answers aging out of caches worldwide within one TTL window.

5. Negative caching

Negative caching stores the non-existence of a record. When a resolver queries for a domain or record type that doesn't exist, it caches that negative result (governed by its own TTL, taken from the zone's SOA record) so that repeated queries for the same non-existent resource don't hit the authoritative servers again. This reduces load on the DNS hierarchy and improves overall lookup performance, just as positive caching does for records that do exist.

Sources: RFC 1035 (Domain Names — Implementation and Specification); RFC 2308 (Negative Caching of DNS Queries); live dig queries against the public root, .com TLD, and example.com name servers, verified July 2026; Cloudflare and Google Public DNS operator documentation on resolver behavior and caching.

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

Stuck on DNS Resolution Process? Open Claude, copy a block below, and it'll teach you this exact concept — visually and interactively.

🪜 Hint ladder (no spoilers)

Progressively stronger hints — you still solve it.

I'm working on the problem **DNS Resolution Process** (System Design). Give me a HINT LADDER: start with the tiniest nudge, then wait. Only reveal the next, stronger hint when I ask. Do NOT show the full solution unless I type 'show solution'. Keep me doing the thinking. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🎨 Explain the approach visually

See the technique, not just code.

Explain the optimal approach to **DNS Resolution Process** with a VISUAL walkthrough: trace it on a small concrete example using ASCII art / a step-by-step diagram, narrate what changes each step, then give time & space complexity with a one-line derivation. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🔍 Review my solution

Catch bugs, edge cases, sub-optimality.

I'll paste my solution to **DNS Resolution Process**. Review it for correctness, missed edge cases, and time/space complexity, then coach me toward the optimal — don't just rewrite it. Ask me to paste my code now. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.
🔁 Drill the pattern

Lock in recognition with look-alikes.

Give me 2 problems that use the SAME underlying pattern as **DNS Resolution Process**. For each, let me attempt first, then review my answer and name the trigger signal that reveals the pattern. If you're unsure or a claim isn't standard, say so and reason from first principles instead of guessing.

📝 My notes