Infrastructure
How DNS Resolution Actually Works
From stub resolver to authoritative server: the chain of queries that turns a name into an IP address.
Introduction
Section titled “Introduction”Every web request starts with a question: what IP address does this name map to? The Domain Name System answers it billions of times a day, usually in tens of milliseconds, through a distributed hierarchy of servers. The process looks simple from the outside, but several distinct servers cooperate on every lookup.
The core concept
Section titled “The core concept”DNS is a hierarchical, distributed database. Names are organised as a tree: the root (.), top-level domains like .com, second-level domains like example.com, and subdomains below them. No single server knows the whole tree; each server is authoritative for only part of it, and resolution is the process of walking down the tree until an authoritative answer is found.
How it works
Section titled “How it works”When an application asks for www.example.com, the steps are roughly:
- Stub resolver. The operating system’s resolver (configured via
/etc/resolv.confor the system equivalent) sends the query to a recursive resolver — usually run by an ISP or a public provider. - Cache check. The recursive resolver first checks its cache. If it recently resolved the same name and the record’s TTL (time-to-live) has not expired, it answers immediately. Most lookups end here.
- Root. On a cache miss, the resolver asks one of the 13 root server identities (anycast, so there are many physical instances) which name servers handle
.com. - TLD. It asks a
.comserver (the TLD server) which name servers are authoritative forexample.com. - Authoritative. It asks the authoritative server for
example.com, which returns the actual record — anArecord with an IPv4 address, orAAAAfor IPv6. - Reply and cache. The resolver caches the answer for its TTL and returns it to the stub resolver.
The resolver’s queries to root, TLD, and authoritative servers are usually iterative — each server answers with a referral (“ask this server next”) rather than doing the work itself. The client’s single query is recursive: the resolver does all the chasing and returns one final answer.
Why it matters
Section titled “Why it matters”Two properties of this design shape the internet. First, caching makes DNS fast: TTLs mean popular names are almost always served from memory, so resolution rarely needs the full walk. Second, the hierarchy makes it scalable and decentralised: adding a subdomain requires no central coordination, only a record on the authoritative server for that zone.
It also explains common failures. A stale record after a migration is usually a cached entry whose TTL has not expired — lowering the TTL before a move is the standard fix. And because classic DNS queries are unencrypted UDP on port 53, they can be observed and spoofed; DNS over HTTPS (DoH) and DNS over TLS (DoT) exist to close that gap, and DNSSEC adds cryptographic signatures to answers.
Misconceptions
Section titled “Misconceptions”DNS is often described as “the internet’s phone book”, which suggests a single lookup. In reality it is a distributed walk with caching at every layer, and the answer you get depends on which resolver you ask and what it has cached. A name resolving for you but not for someone else is usually a cache or resolver difference, not a broken domain.