← All chapters
Chapter 20· 9 min read · illustrated

DNS — How Resolution Works

From a name to an IP by walking the root, TLD, and authoritative servers

We meet DNS again — but this time we open it up. When you type a domain, a small chain of servers cooperates to turn that name into an IP, and caching keeps it fast. This is the application-layer protocol you rely on before every single request.

01

The internet’s phone book

Humans remember names (example.com); machines route by numbers (93.184.216.34). DNS (Domain Name System) is the distributed directory that translates one into the other, at massive scale, for the whole internet.

Tap to enlarge
02

A hierarchy of servers

DNS is organized as a tree, read right to left:

Root (.)
The top; knows where each TLD lives.
TLD (.com, .org …)
Knows which server is authoritative for each domain under it.
Authoritative
Holds the real records for example.com and gives the final answer.
Tap to enlarge
03

The recursive resolver

Your device runs a tiny stub resolver that offloads the real work to a recursive resolver — usually run by your ISP or a public one like 8.8.8.8. The recursive resolver does all the asking around and returns just the final answer.

Tap to enlarge
04

Walking the tree

To resolve www.example.com the resolver asks in turn: the root ("where is .com?"), the .com TLD ("where is example.com?"), and finally example.com’s authoritative server ("what is the IP?"). Each step narrows it down until the address is found.

Tap to enlarge
05

Caching and TTL

That full walk would be slow to repeat, so every answer carries a TTL (time to live). Resolvers cache the record for that duration and answer subsequent queries instantly from cache — which is why the first lookup of a site is slower than the rest.

Tap to enlarge
06

Recursive vs iterative

Two query styles exist. In a recursive query, you ask the resolver and it does everything, returning the final IP. In iterative queries (what the resolver itself uses upstream), each server simply replies with a referral to the next server to ask.

Tap to enlarge
07

DNS over UDP and TCP

DNS uses port 53. Most lookups go over UDP because they are small and fast — a single query and reply. But when a response is too large to fit, or for zone transfers between servers, DNS switches to TCP for reliable, larger transfers.

Modern note: Today DNS is increasingly encrypted too — DNS over HTTPS (DoH) and DNS over TLS (DoT) protect these queries from eavesdropping.

Tap to enlarge