LearnThatStack Ace your next interview
Networking for Developers · question
Question 2 of 51

How does DNS turn a website hostname into an IP address?

beginner
← All Networking for Developers questions
Re-explain
Visual ↓

Your machine asks a resolver, which answers from its cache or walks the DNS hierarchy down to the server that owns the name. The resolver is usually run by your ISP or a public service. DNS works like a phone book that maps names to addresses.

On a cache miss, the resolver starts at a root server, which points to the top-level domain server for .com. That server points to the authoritative server for the domain. The authoritative server returns the actual IP address, and the resolver hands it back to your program.

The lookup happens before any real request, so it sits on the critical path. A cold lookup can add tens of milliseconds. Caching along the way keeps most lookups fast.

Rewriting in plainer words…

This answer doesn't lend itself to a diagram - it reads best . No credits were charged.

Why there's no diagram: “”

The interactive diagram is below the answer - jump to diagram ↓ · Below it, the related concept . Jump to it ↓

The diagram below the answer is the concept . Jump to it ↓

Tailored explanation · switch back to · ·
What should the new diagram focus on?
Guided practice for Networking for Developers One question at a time. Answer out loud, get graded, see what you missed.
See it - interactive diagram
How a resolver walks the DNS hierarchy on a cache miss
Your machine
Resolver
Root server
.com TLD server
Authoritative
where is example.com?
where is example.com?
ask the .com servers
where is example.com?
ask example.com's server
where is example.com?
IP is 203.0.113.10
IP is 203.0.113.10
1step

Your machine asks the resolver once, then waits. It never talks to the other servers.

1 / 8

Your machine asks once. The resolver itself asks a root server, the .com top-level domain server and the domain's own server. No server passes the question on.

© LearnThatStack - diagrams may not be republished without permission.

Other questions have diagrams like this too. Sign in to ask for one where it's missing - it's free.

Create a free account
How well did you know this?
AI:

Saved in this browser - sign in to keep your review list.

How should your speech become text?

Listening… your words appear above as you speak - tap Stop when you're done.

Recording · cr - tap Stop & transcribe when you're done.

Transcribing with AI…

Voice:

Keep going - a few more words and AI can grade it.

Interview lens How interviewers actually use this question

Likely follow-ups

What you can say

  1. My machine asks a resolver, and the resolver either answers from its cache or walks the DNS hierarchy down to the server that owns the name.
  2. Your ISP or a public service usually runs that resolver, and it works like a phone book that maps names to addresses.
  3. On a cache miss, the resolver starts at a root server, which points it to the top-level domain server for .com.
  4. That server points to the domain's authoritative server, which returns the actual IP address, and the resolver hands it back to my program.
  5. All of this happens before the first real request goes out, so it sits on the critical path, and a cold lookup can add tens of milliseconds.
  6. Caching along the way keeps most lookups fast, and the cost is that a changed record takes time to reach everyone.

Weak answers to avoid

  • Has the browser walk the hierarchy itself Your machine sends one query to a resolver, and the resolver talks to the root, TLD and authoritative servers. Say who asks whom.
  • Says the root server returns the IP Root and TLD servers only point to the next server down. Only the domain's authoritative server returns the address.
  • Leaves out caching Without caches, every request would walk the whole hierarchy. Say that most lookups end at a cache and only a miss goes to the root.
  • Treats the lookup as free The lookup runs before any connection opens, so it sits on the critical path. Say that a cold lookup can add tens of milliseconds.
Interview lens

Likely follow-ups, what you can say, and the weak answers to avoid.

Sign in free to open it Free account - the lens opens as soon as you're back.

Want a quick review of the fundamentals? See the Networking for Developers cheatsheet.

← Back to all Networking for Developers questions
Pro · $10/mo

44 of 51 Networking for Developers answers are in Pro.

Full answers, code samples, and AI explanations that go simpler or deeper. Cancel anytime.

  • Full answers + code
  • AI explanations, simpler or deeper
  • 1,000 AI credits / month
  • Cancel anytime