Skip to main content

Welcome to a Grasp lesson

Create a free account to keep studying and create your own study path.

Lesson 26

DNS Resolution: From Browser to IP

Recommended resources

Introduction

In our last lesson, we established that DNS queries are a classic use case for the UDP protocol, favoring speed and efficiency for small, transactional requests. Now, we will unpack the mechanics of that process. When you type a domain name like google.com into your browser, a sophisticated but rapid sequence of events unfolds across the internet to find the corresponding IP address.

This lesson traces that entire journey, from the initial browser query to the final IP address response. For a senior engineering manager, understanding this flow is fundamental not only for diagnosing connectivity issues but also for grasping the performance implications of web architecture and the propagation delays involved in deploying changes to your services. We will dissect the roles of the different servers involved and follow the path of a query through this distributed system.


The "Phonebook of the Internet"

At its core, the Domain Name System (DNS) serves a simple but critical function: it acts as the internet's phonebook. Humans prefer memorable names like oneuptime.com, but computers and network equipment communicate using numerical IP addresses (e.g., 93.184.216.34). DNS is the decentralized, hierarchical system that handles this translation.

Before we trace the full path, let's meet the key players in this process. A great way to think about them is using a library analogy.

What is DNS? | How DNS works

This article from Cloudflare provides an excellent introduction to DNS and the main servers involved in resolution.

Start by reading the introductory section to solidify the "phonebook" concept. Then, read the descriptions of the four key servers under the heading There are 4 DNS servers involved. Pay attention to the library analogy used: DNS Recursor: The librarian who finds the book. Root Nameserver: The library's main index. TLD Nameserver: A specific rack of books (e.g., the .com section). Authoritative Nameserver: The dictionary on that rack with the specific definition.


The End-to-End DNS Resolution Process

Now, let's walk through the full journey of a DNS query step-by-step, assuming the IP address is not already cached on your local machine. This "uncached" scenario reveals the complete, elegant hierarchy of the DNS system.

The overall flow can be visualized as a series of requests and referrals, where each server points the resolver to a more specific server, until the final answer is found.

A high-level overview of the DNS resolution flow, from the initial client request to receiving the IP address.

Here is the detailed, step-by-step process. The sequence diagram below illustrates the back-and-forth communication between the different servers.

A sequence diagram showing the query (blue) and response (green) interactions between the client, recursive resolver, and the hierarchy of DNS nameservers.

Step 1: The User's Request and Local Cache Check
You type example.com into your browser. The first thing your system does is check its local caches for the IP address. This happens in a couple of places:

  • Browser Cache: Modern browsers maintain their own DNS cache for a short period.
  • Operating System Cache: The OS (via a "stub resolver") also keeps a cache. This is where entries from your /etc/hosts file would be found.
    If the IP is found here, the process stops, and the browser can initiate a connection immediately. If not, the query moves on.

Step 2: The Query to the Recursive Resolver
The OS forwards the query to a DNS Recursive Resolver (also called a DNS recursor). This is the workhorse of the DNS lookup. Your device is typically configured to use a resolver provided by your Internet Service Provider (ISP), but you can also use public ones like Google's (8.8.8.8) or Cloudflare's (1.1.1.1). The request from your computer to the resolver is a recursive query: "Please find the IP for example.com and give me the final answer."

Step 3: The Resolver Queries the Root Server
The recursive resolver, if it doesn't have the answer in its own cache, begins a series of iterative queries to find the answer.
It starts at the top of the hierarchy by asking one of the 13 logical Root Nameservers: "I need to find example.com. Who handles the .com domain?"
The root server doesn't know the IP for example.com, but it knows who does. It responds with a referral: "I don't know, but here is a list of IP addresses for the Top-Level Domain (TLD) nameservers that manage .com."

Step 4: The Resolver Queries the TLD Nameserver
The resolver then picks one of the TLD Nameservers from the list and asks it: "I need to find example.com. Who is the authoritative nameserver for this domain?"
The TLD server for .com manages all .com domains. It doesn't have the final IP address, but it knows where to find it. It looks up the example.com domain in its database and responds with another referral: "I don't know the IP, but the Authoritative Nameserver for example.com is at ns1.example.com."

Step 5: The Resolver Queries the Authoritative Nameserver
Finally, the resolver queries the Authoritative Nameserver for example.com. This server is the ultimate source of truth for the domain's DNS records (this is what you edit at your domain registrar like GoDaddy or a service like AWS Route 53 or Cloudflare DNS).
The resolver asks: "What is the A record (the IP address) for example.com?"
The authoritative server checks its records and responds with the final answer: "The IP address for example.com is 93.184.216.34."

Step 6: The Response is Returned and Cached
The recursive resolver now has the IP address.

  1. It stores the record in its own cache for a period of time specified by the record's Time-To-Live (TTL). This speeds up future requests for the same domain.
  2. It sends the IP address back to your computer's OS.
  3. Your OS caches the result and passes it to the browser.

Step 7: The Browser Makes the Connection
With the IP address in hand, the browser can now open a TCP connection to 93.184.216.34 and send an HTTP request to fetch the webpage.

The following video provides an excellent animated walkthrough of this entire process, which can help solidify your understanding of the flow.

Everything You Need to Know About DNS: Crash Course System Design #4

This video from ByteByteGo, framed in a system design context, visualizes the step-by-step resolution process we just discussed.

Watch the section that walks through the life of a DNS query. It clearly shows the progression from the browser to the OS, resolver, root, TLD, and authoritative nameserver.


The Importance of Caching and TTL

As you've seen, the full, uncached resolution process involves multiple round-trips across the internet. What makes DNS performant in practice is caching. Caching happens at every level: browser, OS, and recursive resolver.

The duration a record is cached is controlled by its Time-To-Live (TTL) value, which is set on the authoritative nameserver. A low TTL (e.g., 60 seconds) means resolvers will have to re-query for the record more frequently, while a high TTL (e.g., 24 hours) reduces the load on nameservers but means changes take longer to propagate across the internet.

As a manager, this is a critical operational concept. If your team needs to migrate a service to a new IP address, they must lower the TTL on the corresponding DNS record well in advance of the change. This ensures that when the IP is updated, resolvers around the world quickly discard the old, cached entry and fetch the new one.

Everything You Need to Know About DNS: Crash Course System Design #4

The same ByteByteGo video provides an excellent practical summary of this exact challenge.

Watch the final segment on DNS gotchas for a concise explanation of why you need to manage TTLs carefully before making production changes.


Tracing DNS in Practice with dig

To move from theory to practice, you can trace this entire delegation path yourself using a command-line tool. The dig (Domain Information Groper) utility is the standard for DNS troubleshooting.

Using the +trace option, dig will perform the iterative query process for you, starting from the root servers, just like a recursive resolver would. This bypasses any caches and shows you every step of the journey.

How to Understand DNS Resolution Process Step by Step

This article from OneUptime provides a hands-on guide to using dig for troubleshooting. We'll focus on the +trace command.

Read the section Trace Resolution with dig +trace. Try running the command dig +trace google.com in your terminal. You will see the output broken down into sections, showing the query to the root servers, then the TLD servers for .com, and finally the authoritative nameservers for google.com providing the final A record.

This practical exercise makes the hierarchical nature of DNS tangible and is an invaluable skill for debugging why a service might be unreachable.


Conclusion

In this lesson, we have demystified the process of DNS resolution, tracing a query from a user's browser all the way to the authoritative nameserver and back. You can now map the journey a network request takes just to find its destination.

Key Takeaways:

  • DNS is a hierarchical and distributed system for translating human-readable domain names into machine-readable IP addresses.
  • The resolution process involves four key server types: the Recursive Resolver, Root Nameserver, TLD Nameserver, and Authoritative Nameserver.
  • A query from a client to a resolver is recursive ("find the answer for me"), while the queries between resolvers and nameservers are iterative ("who should I ask next?").
  • Caching is critical for DNS performance and occurs at multiple levels (browser, OS, resolver). The TTL value on a DNS record dictates cache duration and impacts change propagation.
  • The dig +trace command is a powerful tool for visualizing the entire DNS delegation chain and bypassing caches for troubleshooting.

Now that we understand how a browser finds the correct IP address for a server, our next lesson will focus on what happens next: we will inspect the HTTP request/response cycle, examining the structure of the messages exchanged to load a webpage.