Skip to content

Infrastructure

How DNS Resolution Actually Works

From stub resolver to authoritative server: the chain of queries that turns a name into an IP address.

3 min read

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.

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.

When an application asks for www.example.com, the steps are roughly:

  1. Stub resolver. The operating system’s resolver (configured via /etc/resolv.conf or the system equivalent) sends the query to a recursive resolver — usually run by an ISP or a public provider.
  2. 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.
  3. 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.
  4. TLD. It asks a .com server (the TLD server) which name servers are authoritative for example.com.
  5. Authoritative. It asks the authoritative server for example.com, which returns the actual record — an A record with an IPv4 address, or AAAA for IPv6.
  6. 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.

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.

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.