System Atlas
the atlas

How DNS works

Turning a human name into a machine address by walking a global hierarchy.

the gist

A recursive resolver takes your query and, on a cache miss, walks the DNS hierarchy: a root nameserver points to the .com TLD server, which points to the domain's authoritative nameserver, which returns the A record (the IP). The resolver caches the answer with a TTL so the next lookup is instant.

ANALOGY // Finding an office: the root is the country's main directory that points you to the city, the TLD is the city hall that points you to the building, and the authoritative server is the building's own front desk that finally gives you the exact room number.
living diagram01 / 06
queryClientwants an IPRecursive resolvercache + legworkRoot NS→ .comTLD NS.com → authAuthoritative NSholds A record
01

Client asks the resolver

Your device sends the domain query to a recursive resolver — often run by your ISP or a public provider like 8.8.8.8 or 1.1.1.1 — and then simply waits for one final answer. This is a recursive query: the client is asking the resolver to do all the work and come back with the finished IP, not with a referral. The operating system's stub resolver handles this handoff on the app's behalf.

02

Check the cache

Before touching the network the resolver checks its own cache for a valid, unexpired record. On a hit it returns instantly, skipping every step below — which is the common case, since popular domains are almost always cached somewhere close. Caches also exist in your browser and OS, so many lookups never even reach the resolver.

03

Ask the root, get a referral

On a cache miss the resolver begins an iterative walk down the hierarchy, starting at one of the 13 root nameserver clusters. The root doesn't know the IP, but from the '.com' suffix it refers the resolver to the '.com' TLD nameservers. There are only a handful of roots, so their answers are heavily cached and rarely queried in practice.

04

Ask the TLD server

The resolver next queries the '.com' TLD nameserver, which again doesn't hold the final record but knows which authoritative nameservers were delegated the domain. It returns those nameservers' addresses — this delegation is exactly what a registrar writes when you buy a domain and set its NS records. The resolver steps one level closer.

05

Authoritative returns the IP

Finally the resolver queries the domain's authoritative nameserver — the server that genuinely owns the zone's records. It answers with the A record (an IPv4 address) or AAAA record (IPv6), and this answer is authoritative rather than a referral. The hierarchy walk ends here.

06

Cache and return

The resolver stores the answer tagged with its TTL, then returns the IP to the client, which can finally open a connection. Every future lookup of that name is served straight from cache until the TTL counts down to zero. The TTL is the dial that trades update speed against query load.

the full picture
01

The problem: names for humans, numbers for machines

People remember google.com; routers only move packets toward numeric IP addresses like 142.250.72.14. DNS — the Domain Name System — is the global directory that translates one into the other, and it runs so quietly that most people never think about it even though nearly every online action begins with a DNS lookup.

The reason DNS is interesting is scale. There is no single machine that could hold a mapping for every domain on earth and answer billions of queries per second, and even if there were, it would be a catastrophic single point of failure. So DNS is designed as a distributed, hierarchical, heavily cached database. No server knows everything; each knows only its slice and who to ask next. That structure is what lets a lookup for any of hundreds of millions of domains resolve in milliseconds, and understanding it means understanding how the hierarchy is walked and how caching keeps that walk from happening most of the time.

02

The hierarchy and the players

Domain names are read right to left as a tree. The trailing dot is the root. Below it sit the top-level domains (.com, .org, .io, country codes like .uk), and below those the individual registered domains, then subdomains. Four kinds of server cooperate to resolve a name:

  • The stub resolver on your device, which just forwards the question to a configured resolver.
  • The recursive resolver (your ISP's, or a public one like Cloudflare's 1.1.1.1 or Google's 8.8.8.8), which does the actual legwork and caches results.
  • The root nameservers — 13 named clusters, globally replicated via anycast — which know where each TLD lives.
  • The TLD nameservers, which know which authoritative servers own each domain, and the authoritative nameservers, which hold the domain's real records.

Crucially, the resolver is the one doing the work; every server above it just points one level deeper.

03

Recursive vs iterative resolution

There are two styles of query, and DNS uses both in the same lookup. When your device asks the resolver, it makes a recursive query: "give me the final answer, do whatever it takes." The resolver accepts full responsibility for producing a complete answer.

To fulfill that, the resolver makes a series of iterative queries down the hierarchy. It asks a root server, which doesn't answer the question but refers it to the .com TLD servers. It asks a TLD server, which refers it to the domain's authoritative nameservers. It asks an authoritative server, which finally returns the actual record. At each hop the resolver gets a referral ("I don't know, but ask them") rather than the answer, and it keeps walking until it reaches a server that is authoritative for the name. Then it hands the finished answer back to your device. The client sees one clean request-response; behind the scenes the resolver may have made three or four hops.

04

Record types, TTLs, and caching

A DNS zone holds several record types, each answering a different question. A maps a name to an IPv4 address and AAAA to IPv6. CNAME aliases one name to another. MX points to mail servers, NS delegates a zone to its nameservers, and TXT holds arbitrary text used for things like domain verification and email anti-spoofing (SPF, DKIM).

Every record carries a TTL — a time-to-live in seconds telling caches how long they may reuse it. Caching is what makes DNS fast: once your resolver has resolved google.com, it answers the next thousand queries from memory without touching the root at all, and browsers and operating systems cache on top of that. The TTL is a direct trade-off. A long TTL (hours or days) means fewer queries and lower load but slow propagation of changes; a short TTL (seconds or minutes) means changes take effect quickly but generates far more query traffic. This is also why DNS changes aren't instant: propagation is really just the world's caches expiring old TTLs at their own pace, so a record you update may be served stale until every cache times out.

05

Why it matters in practice

DNS is far more than address lookup in real systems. Because a name can return different answers depending on who's asking, DNS is a foundational tool for load balancing (rotating or weighting multiple A records), geo-routing (returning the nearest data center's IP), CDNs (steering users to a nearby edge via CNAME chains), and failover (dropping an unhealthy IP from the responses). Setting a service's public entry point is almost always a DNS decision.

It's also a frequent and confusing failure point: because everything else waits on name resolution, a slow or misconfigured DNS makes perfectly healthy servers look down, and the aggressive caching means fixes don't always take hold immediately. The practical guidance follows from the mechanics — lower a record's TTL *before* you plan a migration so changes propagate fast, expect old answers to linger for the length of the previous TTL, and when debugging "the site is down," check resolution first with tools like dig or nslookup before assuming the application is broken. Modern variants like DNS-over-HTTPS (DoH) additionally encrypt these lookups, which historically traveled in plaintext over UDP for anyone on the path to read.

what to remember
01

The recursive resolver does the legwork: it queries other servers on your behalf and returns a final answer.

02

It checks its cache first — a hit skips the entire hierarchy walk.

03

On a miss it walks top-down: root nameserver → TLD nameserver (.com) → authoritative nameserver.

04

The authoritative nameserver holds the actual record and returns the A record (the IP address).

05

The resolver caches the result with a TTL, so repeated lookups are served locally until it expires.

check yourself

Quick quiz

Q1

What does a root nameserver return for a lookup of example.com?

Q2

Why does DNS cache results with a TTL?

follow the thread