Type a branch, a subject or a topic — “round robin”, “paging”, “civil”.

DNS Resolution Walk

One name, four servers, and a cache that stops the root servers melting.

Skip to the animation

DNS turns a name into an IP address by walking a hierarchy of servers — root, then TLD, then the authoritative server for the domain — with caching at every step to make the walk rare.

Two kinds of query

Recursive query
"Give me the answer." The client asks once and waits; the resolver does all the work. This is what your machine sends.
Iterative query
"Tell me who to ask next." The server replies with a referral rather than an answer. This is what the resolver sends to root and TLD servers, and it is why those servers can serve the whole internet — they only ever refer.
Stub resolver
The trivial client in your operating system. It knows one resolver's address and nothing about the hierarchy.
Authoritative server
Holds the real records for a zone. Its answer is the answer, not a referral.

The vocabulary

Protocol data unit
What the thing is called at each layer: segment at transport, packet at network, frame at link. Different names for the same bytes with different amounts of header wrapped round them.
Encapsulation
A layer treats everything it receives from above as opaque payload and prepends its own header. It never looks inside, which is precisely what makes layers replaceable.
Peer layers
A layer only ever meaningfully talks to the same layer at the other end. TCP at one end reads the header TCP at the other end wrote, and nothing in between touches it.
Propagation vs transmission delay
Propagation is how long a bit takes to travel the distance — set by physics. Transmission is how long it takes to push all the bits out — set by bandwidth. Only the second improves when you buy a faster link.
Round-trip time (RTT)
Send to reply. Every acknowledgement-based protocol is ultimately paced by this, which is why the interesting question is always how much you can send before one arrives.

The walk

  1. 1The stub resolver asks the recursive resolver for www.example.com.
  2. 2The resolver asks a root server, whose 13 addresses it knows from a built-in hints file. The root refers it to the .com servers.
  3. 3It asks a .com TLD server, which refers it to example.com's nameservers.
  4. 4It asks the authoritative server, which returns the A record.
  5. 5The resolver caches everything it learned and returns the address.

Each server answers only for the zone it owns and delegates the rest. The root has never heard of example.com and never will.

Caching and TTL

Without caching the root servers would collapse instantly. Every record carries a TTL saying how long it may be kept, and resolvers cache both the final answer and the referrals gathered along the way — so the next lookup for anything in .com already skips two steps.

The TTL is a genuine trade. Short means changes propagate quickly at the cost of more queries; long means less traffic but a change can take a day to reach everyone. This is why administrators lower the TTL well *before* a planned migration, then raise it again afterwards.

Transport, records and security

RecordHolds
A / AAAAIPv4 / IPv6 address
NSthe authoritative nameservers for a zone
CNAMEan alias to another name
MXmail servers for the domain
SOAzone metadata, including default TTL

DNS runs over UDP port 53 — queries and answers are small, and a lost one is simply retried, so TCP's handshake would double the latency of every lookup. It falls back to TCP for large responses and zone transfers.

The original protocol had no authentication at all, which makes cache poisoning possible: convince a resolver to cache a wrong answer and every user of it goes to the wrong place. DNSSEC adds signatures so answers can be verified; DNS over HTTPS and DNS over TLS encrypt the query for privacy. All are retrofits onto a protocol designed when the network was small and trusted.

Advantages and disadvantages

Advantages

  • Distributed authority — each organisation controls its own zone, with no central bottleneck.
  • Caching means the overwhelming majority of lookups never leave the resolver.
  • The client is trivial, so every device gets a simple implementation.

Disadvantages

  • A cold lookup costs several round trips before any application data can flow.
  • No authentication by default, making cache poisoning a real attack.
  • TTLs mean changes are not immediate, however urgent.

Watch it work

loading visualisation…

Check yourself

question 1 / 4

One question at a time. Pick an answer to see why it is right or wrong, then move on — there is no score to keep and nothing is saved.

What order does an iterative resolution visit servers in?
What stops the thirteen root server addresses from being overwhelmed?
What is the difference between a recursive and an iterative query?
A record's TTL is set to 30 seconds instead of 24 hours. What is the trade?

0 / 4

4 still unanswered — the dots above jump straight to them.

 

Last topic in this subject. Back to the contents →