Computer Networks

How DNS Resolution Works

Feb 15, 2026 7 min read


Understanding the dig Command and the DNS Lookup Process


What is DNS?

When you type google.com into your browser, your computer doesn't actually know where Google is. Computers communicate using IP addresses — numbers like 142.250.80.46 — not human-readable names.

DNS (Domain Name System) translates human-readable domain names into IP addresses. It's the phonebook of the internet.

But unlike a simple phonebook stored in one place, DNS is a distributed system spread across millions of servers worldwide. When you look up a domain, your computer might query several servers before finding the answer.

Understanding how this lookup process works is essential for debugging network issues, configuring domains, and designing reliable systems.


The DNS Hierarchy

DNS is organized like a tree. At the top are root servers, followed by TLD (Top-Level Domain) servers, and finally authoritative servers for specific domains.

When you look up google.com, the process works in layers:

  1. Start at the root — "Where is .com?"
  2. Ask .com servers — "Where is google.com?"
  3. Ask Google's servers — "What's the IP address?"

Each layer knows about the next layer down, but not beyond. Root servers don't know Google's IP address — they only know who to ask about .com domains.


What is the dig Command?

dig (Domain Information Groper) is a command-line tool that lets you query DNS servers directly and see exactly what they return. While your browser hides DNS lookups behind the scenes, dig exposes every detail.

dig google.com

This command asks: "What's the IP address for google.com?"

Think of dig as a diagnostic tool. When a domain isn't resolving correctly, when you've just updated DNS records and want to verify, or when you simply want to understand how DNS works — dig shows you what's actually happening.


Understanding dig . NS — Root Name Servers

Let's start at the very top of the DNS hierarchy.

dig . NS

The . represents the root of the DNS tree. Every domain technically ends with a dot (google.com.), but we usually don't type it. This command asks: "Who are the root name servers?"

Output (simplified):

.    IN    NS    a.root-servers.net.
.    IN    NS    b.root-servers.net.
.    IN    NS    c.root-servers.net.
.    IN    NS    d.root-servers.net.
...

There are 13 root server addresses (a through m), operated by different organizations around the world. These are the starting point for all DNS lookups.

What this tells us: Root servers don't know where google.com is. They don't store millions of domain records. They only know one thing — which servers are responsible for each top-level domain like .com, .org, .net, and so on.


Understanding dig com NS — TLD Name Servers

Next level down.

dig com NS

This asks: "Who manages the .com domain?"

Output (simplified):

com.    IN    NS    a.gtld-servers.net.
com.    IN    NS    b.gtld-servers.net.
com.    IN    NS    c.gtld-servers.net.
...

These are the TLD (Top-Level Domain) servers for .com. They're managed by Verisign. Every .com, .net, and several other TLDs go through their infrastructure.

What this tells us: The .com servers don't know Google's IP address either. But they know which name servers are authoritative for google.com — meaning which servers have the final answer.


Understanding dig google.com NS — Authoritative Name Servers

One more level down.

dig google.com NS

This asks: "Who is authoritative for google.com?"

Output (simplified):

google.com.    IN    NS    ns1.google.com.
google.com.    IN    NS    ns2.google.com.
google.com.    IN    NS    ns3.google.com.
google.com.    IN    NS    ns4.google.com.

These are Google's own DNS servers. They are the authoritative source for all google.com DNS records. When you need the actual IP address, these are the servers that have the definitive answer.

What this tells us: Google runs their own name servers. Other companies might use services like Cloudflare (ns1.cloudflare.com) or AWS Route 53. The NS records tell the world where to find the authoritative information.


Understanding dig google.com — The Full Resolution

Now let's get the actual IP address.

dig google.com

Output (simplified):

;; QUESTION SECTION:
;google.com.            IN    A

;; ANSWER SECTION:
google.com.        300    IN    A    142.250.80.46

Breaking this down:

QUESTION SECTION — What you asked for. You requested an A record (IPv4 address) for google.com.

ANSWER SECTION — The result. google.com resolves to 142.250.80.46.

300 — The TTL (Time To Live) in seconds. This answer can be cached for 5 minutes before asking again.


The Complete Resolution Flow

When your browser looks up google.com, here's what happens behind the scenes:

In practice, you don't query each server yourself. A recursive resolver does the work for you.

Step 1: Your computer asks the recursive resolver (often provided by your ISP, or a public one like 8.8.8.8): "What's the IP for google.com?"

Step 2: The resolver asks a root server: "Where can I find information about .com?" Root server responds with the .com TLD servers.

Step 3: The resolver asks the TLD server: "Where can I find information about google.com?" TLD server responds with Google's authoritative name servers.

Step 4: The resolver asks Google's name server: "What's the IP address for google.com?" Google's server responds with the actual IP.

Step 5: The resolver returns the answer to your computer and caches it for future requests.

The next time you (or anyone else using that resolver) looks up google.com within the TTL window, the resolver returns the cached answer instantly — no need to repeat all those queries.


Mapping dig Commands to the Lookup Process

Each dig command we ran corresponds to a stage in the resolution process:

dig . NS — Shows you the root servers. These are the entry point for all DNS queries.

dig com NS — Shows you the TLD servers for .com. These know where to find any .com domain.

dig google.com NS — Shows you Google's authoritative servers. These have the actual records.

dig google.com — Gets the final answer. The IP address.


What NS Records Represent

NS (Name Server) records answer the question: "Who is responsible for this domain?"

At each level of the hierarchy, NS records point to the next level:

Root NS records point to TLD servers. "For .com questions, ask these servers."

TLD NS records point to authoritative servers. "For google.com questions, ask these servers."

Authoritative NS records confirm who manages the domain. "We are the source of truth for google.com."

This delegation chain is what makes DNS scalable. No single server needs to know about every domain in the world. Each server only needs to know about its piece of the hierarchy and who to ask for the next level down.


Useful dig Options

See just the answer:

dig google.com +short

Output: 142.250.80.46

Query a specific DNS server:

dig @8.8.8.8 google.com

This asks Google's public DNS server directly instead of using your default resolver.

Trace the full resolution path:

dig google.com +trace

This shows every step of the resolution, from root servers down to the final answer. Extremely useful for debugging.

Check a specific record type:

dig google.com MX        # Mail servers
dig google.com AAAA      # IPv6 address
dig google.com TXT       # Text records


Connecting This to Real-World Requests

When your browser loads google.com:

  1. Browser asks the operating system to resolve google.com
  2. OS checks its local cache — is the answer already known?
  3. If not, OS asks the configured DNS resolver (often your router, which asks your ISP)
  4. The resolver follows the hierarchy we traced: root → TLD → authoritative
  5. The resolver returns the IP address and caches it
  6. Browser connects to that IP address
  7. Google's server responds with the webpage

This entire process typically takes 20-100 milliseconds for an uncached lookup. Cached lookups are nearly instant


Wrapping Up

DNS resolution is a hierarchical lookup that moves from general to specific — root servers know about TLDs, TLD servers know about domains, authoritative servers know the actual records.

The dig command lets you inspect each layer of this hierarchy. When something isn't resolving correctly, you can trace exactly where the breakdown occurs.

Understanding this flow helps with debugging connectivity issues, verifying DNS changes have propagated, designing systems that depend on DNS, and simply knowing what happens in those milliseconds between typing a URL and loading a page.

.

Resources

More in Computer Networks

View all →

0 Comments

Sign in to join the conversation

No comments yet. Be the first to comment!