1. Home
  2. Computer Networks
  3. DNS Resolution

DNS Resolution

Follow a domain name from your browser through the resolver, root, TLD and authoritative servers until the IP address comes back.

Interactive 3DBeginner10 min readCNUpdated

Drag to rotate · Right-drag to pan · Click, then scroll to zoom · Space play · Left arrowRight arrow step

What's happening

The Domain Name System turns a name like www.example.com into an IP address. Choose a domain and press Resolve to follow the lookup.

Pseudocode

  1. 1. browser asks its recursive resolver for the IP address
  2. 2. resolver: cache hit? → return it immediately
  3. 3. resolver asks a ROOT server → referral to the TLD server
  4. 4. resolver asks the TLD server → referral to the authoritative server
  5. 5. resolver asks the authoritative server → the A record (IP)
  6. 6. resolver caches the answer for its TTL and replies to the browser
Read this model as text · 10 steps

One run of the model above, written out step by step. Useful with a screen reader, on a slow connection, or for quick revision. The values may differ from the run on your screen.

  1. The Domain Name System turns a name like www.example.com into an IP address. Choose a domain and press Resolve to follow the lookup.
  2. The browser asks its resolver: what is the IP of www.example.com? The resolver does the hard work and the browser just waits.
  3. The cache is empty, so the resolver starts at the top: it asks a root server.
  4. The root does not know the address, but it knows who runs .com. It replies with a referral to the .com TLD servers.
  5. The resolver asks the .com TLD server the same question.
  6. The TLD server refers the resolver to the name server of example.com.
  7. The resolver asks the authoritative server for example.com, the one that holds the real records.
  8. The authoritative server answers with the A record: 93.184.216.34.
  9. The resolver caches the record for its TTL and sends 93.184.216.34 to the browser. Now the browser can open a connection (see the TCP handshake).
  10. Total: 8 messages for a cold lookup. The next request for www.example.com will be answered from the resolver’s cache until the TTL expires.

Try this in the 3D model

  • Resolve www.example.com with an empty cache. Count the messages. Which server answers with the final IP?
  • Set the cache to Has the answer and resolve again. How many messages are saved?
  • Switch the domain to .in. Which step changes, and which stays the same?
  • Follow the referrals: what does the root server know, and what does it not know?

The internet’s phone book

Computers talk to each other with IP addresses like 93.184.216.34, but people remember names like www.example.com. The Domain Name System (DNS) translates names into addresses. No single server knows everything, so the work is split into a hierarchy.

The cast

Server What it knows
Recursive resolver Does the legwork for you and caches answers. Run by your ISP, school or a public service.
Root server Who runs each top-level domain (.com, .org, .in…).
TLD server Which name servers handle each domain under that TLD (example.com).
Authoritative server The real records of the domain (A, AAAA, MX, CNAME…).

A cold lookup

  1. The browser asks the resolver: IP of www.example.com?
  2. The resolver asks a root server and gets a referral to the .com servers.
  3. It asks the .com TLD server and gets a referral to example.com’s name server.
  4. It asks the authoritative server and receives the A record.
  5. The resolver caches the record and returns the IP to the browser.

That is 8 messages. The browser can now open a connection to the address using the TCP handshake.

Caching and TTL

Every record carries a TTL (time to live) in seconds. Resolvers and browsers reuse a cached answer until the TTL expires. A cached lookup needs just 2 messages (question and answer), which is why DNS rarely slows page loads. Short TTLs let a site change its servers quickly. Long TTLs reduce load.

Common record types

  • A / AAAA: name → IPv4 / IPv6 address
  • CNAME: one name is an alias of another
  • MX: mail servers for the domain
  • NS: which servers are authoritative
  • TXT: free text, often used for e-mail and domain verification

DNS usually runs over UDP on port 53, and falls back to TCP for large answers. In the OSI/TCP-IP model it is an application-layer protocol.

Code

import socket

# Ask the operating system's resolver, exactly as a browser would
print(socket.gethostbyname('www.example.com'))
print(socket.getaddrinfo('www.example.com', 443)[0][4])

Common mistakes

  • Thinking the root server knows the IP address. It only knows who to ask next.
  • Mixing up the recursive resolver (works for you) with the authoritative server (owns the data).
  • Forgetting that cached answers can be stale until the TTL runs out, which is why DNS changes take time to spread.

Complexity at a glance

Case / operationTimeWhy
Cold lookup8 messagesBrowser → resolver, then 3 query/reply pairs to root, TLD and authoritative servers, then the reply.
Cached lookup2 messagesThe resolver answers from its cache until the TTL expires.
Extra spaceOne cache entry per name and record type

Quick check

Test yourself — pick an answer to see if you got it.

1. What does the DNS root server return when asked for www.example.com?

2. Which server holds the actual A record for example.com?

3. Why is the second visit to a website usually faster to resolve?

4. Which DNS record type maps a name to an IPv4 address?

Saved in this browser.
Spotted a mistake or a bug in the 3D model?

Report a mistake

in DNS Resolution. Thank you — every report makes the lesson better for the next reader.

We'll also include a link to the step of the 3D model you're on and your browser type, so we can reproduce it.