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.
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← → keys
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.
What's the difference between the query your machine sends and the queries the resolver makes on a miss?Your machine asks the resolver to do the whole job. The resolver asks root and TLD servers, and each returns a referral, not the final answer.
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.
Your ISP or a public service usually runs that resolver, and it works like a phone book that maps names to addresses.
On a cache miss, the resolver starts at a root server, which points it to the top-level domain server for .com.
That server points to the domain's authoritative server, which returns the actual IP address, and the resolver hands it back to my program.
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.
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 itselfYour 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 IPRoot and TLD servers only point to the next server down. Only the domain's authoritative server returns the address.
Leaves out cachingWithout 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 freeThe 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.