awesome-everything RU
↑ Back to the climb

Networking & Protocols

DNS: what it does and why it exists

Crux DNS turns human-friendly names into IP addresses through a hierarchy of servers — the phonebook the whole internet depends on.
Your altitude — climbing toward senior
ZeroJuniorMiddleSenior
You are at junior altitude — the surface
◷ 8 min

You type google.com into your browser. The browser does not know where Google is — it knows names, not numbers. Before it can open a TCP connection or send an HTTP request, it needs the IP address. That lookup is DNS, and it happens silently on every page load.

What DNS does in one sentence

DNS (Domain Name System) translates a human-friendly name like google.com into the numeric IP address (142.250.185.46) the network layer needs to route packets. Without DNS you would need to memorise dozens of IP addresses per service and update them every time a server moved.

The tree of servers

DNS is a global hierarchy. Three tiers handle every query:

  • Root servers — 13 named servers (A–M), each replicated to hundreds of locations via anycast. They do not store domain records; they know which TLD server to ask next.
  • TLD servers — one set per top-level domain (.com, .org, .uk, .io, etc.). They know which authoritative server owns a given domain.
  • Authoritative nameservers — own the zone files for individual domains (google.com, example.co.uk). They return the final answer.
DNS tree at a glance
Root servers (named)
13 (A–M)
Root instances (anycast)
1 000+
TLD servers
one set per TLD (.com, .org, …)
Authoritative servers
one per registered domain
DNS wire protocol
UDP/TCP port 53
Typical cold lookup latency
30–100 ms
Typical warm lookup (cached)
under 1 ms

The phonebook metaphor

Imagine you want to call a restaurant you know only by name. You call directory assistance (the recursive resolver). The operator does not know the number but knows how to find it. She calls a central office (root server), gets redirected to a regional directory (TLD server), and from there to the restaurant’s front desk (authoritative server). The front desk gives the number; the operator relays it and writes it down. The next caller asking the same question gets the cached answer instantly.

The resolution dialogue

A user’s browser sends a query to its configured recursive resolver. If the resolver has no cached answer, it walks the tree:

  1. Browser asks resolver: “What is the IP for example.com?”
  2. Resolver asks root: “Who handles .com?” Root: “Ask the .com TLD server.”
  3. Resolver asks .com TLD: “Who handles example.com?” TLD: “Ask this authoritative server.”
  4. Resolver asks authoritative: “IP for example.com?” Auth: “203.0.113.10, TTL=300.”
  5. Resolver returns IP to browser, caches the answer for 300 seconds.

On the next query within those 300 seconds the resolver skips steps 2–4 and answers from cache.

Order the steps

Order a cold lookup of example.com:

  1. 1 Browser asks recursive resolver for example.com
  2. 2 Resolver asks root: who handles .com?
  3. 3 Root replies with referral to .com TLD
  4. 4 Resolver asks .com TLD: who handles example.com?
  5. 5 TLD replies with referral to authoritative server
  6. 6 Resolver asks authoritative: IP of example.com?
  7. 7 Authoritative replies with the A record
  8. 8 Resolver caches and returns IP to browser

One scenario end to end

You click a link. Underneath, the browser does DNS first — to learn the IP. Once it has the IP it opens a TCP connection to that address, then adds TLS on top, and finally sends the HTTP request. Every new browser tab repeats the DNS step unless the answer is still cached. DNS is always the first step of an internet connection.

Quiz

What does DNS actually return for a standard domain lookup?

Quiz

Why does caching exist at every layer of DNS?

Complete the analogy

DNS is like a global _______ that translates human-readable names into IP addresses.

Why this works

Why 13 root servers, not one. DNS was designed in 1987 when the internet was tiny. The 13-server limit came from the 512-byte UDP limit — you can fit exactly 13 IPv4 addresses in one DNS response. Today each “root server” is really hundreds of machines spread across every continent via anycast: your root query reaches the nearest instance, typically under 5 ms, without you knowing which physical machine answered.

Recall before you leave
  1. 01
    Why do almost all DNS lookups feel instant after the first one?
  2. 02
    What is the role of the recursive resolver, and how does it differ from an authoritative server?
  3. 03
    Name the three tiers of the DNS hierarchy in order.
Recap

DNS is a globally distributed hierarchy that maps human-readable names to IP addresses. When a browser needs to connect to a new domain, it asks a recursive resolver. The resolver walks from root servers, to TLD servers, to the authoritative nameserver for that domain, collecting referrals at each step. The final answer — an A record with the IPv4 address and a TTL — is returned to the browser and cached at every layer. TTL governs how long caches hold the answer before re-querying. A warm cache makes DNS nearly instant; a cold walk costs 30–100 ms across three round-trips. DNS happens before TCP, before TLS, and before HTTP — it is the first step of every internet connection.

Connected lessons
appears again in152
Continue the climb ↑The resolver walk: referrals, record types, and glue
shortcuts expand
search
K
prev piece
k
next piece
j
cycle tier
t
this menu
?
sources3
expand
  1. 01
  2. 02
  3. 03

Trademarks belong to their respective owners. Editorial reference only.