dnsdns resolverwebdevCohort2026ChaiCode

How DNS Resolution Works: The Internet's Phonebook in Action

DNS resolution transforms domain names into IP addresses hierarchically. Use tools like `dig` for in-depth understanding

Kenil Patel
Kenil PatelFull Stack Engineer
How DNS Resolution Works: The Internet's Phonebook in Action

Imagine you want to call your friend, but you only know their name, not their phone number. You would probably look up their name in your phone's contact list, which then gives you their number.

The internet works in a similar way. Websites have names (like google.com), but computers understand only numbers (IP addresses, like 172.217.160.142). The system that translates these human-readable names into machine-readable IP addresses is called DNS (Domain Name System). Think of it as the internet's phonebook.


Why DNS Exists (The "Name Resolution" Problem)

Remembering IP addresses for hundreds of websites is impossible for humans. DNS solves this "name resolution" problem by providing a distributed database that maps domain names to IP addresses. This allows us to type example.com instead of a string of numbers.


Meet dig: Your DNS Diagnostic Tool

While your browser handles DNS resolution automatically, dig (Domain Information Groper) is a powerful command-line tool that lets you manually query DNS servers. It helps you understand exactly how DNS works, diagnose problems, and inspect DNS records.

You can use dig in your terminal (macOS/Linux users usually have it pre-installed; Windows users can install it as part of BIND tools or WSL).


The Layers of DNS Resolution: A Step-by-Step Journey

DNS resolution happens in a hierarchical manner, moving from the most general to the most specific. Let's explore this using dig commands.

1. Understanding the Root Name Servers: dig . NS

Every DNS query starts at the top: the Root Name Servers. These are 13 sets of servers (globally distributed) that know where to find the "Top-Level Domain" (TLD) servers.

Type this in your terminal:

Bash

dig . NS

What you'll see: A list of 13 root name servers (e.g., a.root-servers.net, b.root-servers.net, etc.).

  • NS Record: An "NS" (Name Server) record tells you which servers are responsible for a particular domain or zone.

  • Significance: This command shows you the starting point of any domain name lookup. These servers don't know google.com's IP, but they know who to ask next for .com domains.


2. Understanding TLD Name Servers: dig com NS

Next, the DNS system queries the Top-Level Domain (TLD) Name Servers. These servers manage domains like .com, .org, .net, .in, etc.

Type this in your terminal:

Bash

dig com NS

What you'll see: A list of name servers responsible for the .com TLD (e.g., a.gtld-servers.net, b.gtld-servers.net).

  • Significance: These servers don't know google.com's IP either, but they know which specific servers (the "Authoritative Name Servers") are responsible for google.com.

3. Understanding Authoritative Name Servers: dig google.com NS

Finally, we reach the Authoritative Name Servers. These are the servers that hold the actual DNS records (including the IP address) for a specific domain like google.com. They are "authoritative" because they have the definitive answers.

Type this in your terminal:

Bash

dig google.com NS

What you'll see: A list of Google's own name servers (e.g., ns1.google.com, ns2.google.com).

  • Significance: These are the servers that will finally tell us the IP address of google.com.

4. The Full DNS Resolution Flow: dig google.com

When you type google.com into your browser, a process called Recursive DNS Resolution kicks off. Your computer's Recursive Resolver (often provided by your ISP or a public service like Google DNS 8.8.8.8) does all the heavy lifting by following the chain:

  1. Browser asks Recursive Resolver: "What's the IP for google.com?"

  2. Recursive Resolver asks Root Name Server: "Who handles .com?"

  3. Root Name Server replies: "Ask a.gtld-servers.net."

  4. Recursive Resolver asks TLD Name Server (a.gtld-servers.net): "Who handles google.com?"

  5. TLD Name Server replies: "Ask ns1.google.com."

  6. Recursive Resolver asks Authoritative Name Server (ns1.google.com): "What's the IP for google.com?"

  7. Authoritative Name Server replies: "It's 172.217.160.142 (or similar)."

  8. Recursive Resolver tells Browser: "The IP is 172.217.160.142."

  9. Browser connects to 172.217.160.142 and fetches the webpage.

Type this in your terminal to see the final IP:

Bash

dig google.com

What you'll see: The IP addresses (A records) for google.com, along with other information. This is the ultimate answer your browser needs.


Conclusion: The Invisible Engine of the Internet

DNS resolution is a complex but incredibly fast process that works silently behind every website visit. Understanding these layers – Root, TLD, and Authoritative Name Servers – and how tools like dig interact with them, gives you a deeper appreciation for how the internet connects billions of devices seamlessly. For a web developer, this knowledge is crucial for diagnosing network issues and designing robust systems.