Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Updated
4 min read

How DNS Really Works Using dig — From Root Servers to Google.com (Simple Guide)

We already know that DNS is the phonebook of the internet. It converts domain names into IP addresses.

But have you ever wondered:

👉 How does DNS actually find the answer?
👉 Who does it ask first?
👉 How can we see this process ourselves?

That’s where the dig command comes in.

Let’s understand DNS resolution layer by layer using real commands.


What Is DNS and Why Name Resolution Exists

Computers talk using numbers (IP addresses).
Humans prefer names like google.com.

DNS exists to solve this problem.

It:

  • Converts domain names to IP addresses

  • Helps browsers locate servers

  • Keeps the internet readable for humans

Without DNS, we would be typing long numbers instead of website names.


What Is the dig Command and When Is It Used?

dig stands for Domain Information Groper.

It is a command-line tool used to:

  • Query DNS servers

  • Debug DNS issues

  • Inspect DNS records

  • Understand resolution flow

In simple terms:

👉 dig lets you directly ask DNS servers questions.

System administrators and backend engineers use it to verify DNS configurations.


How DNS Resolution Works (High-Level Flow)

DNS resolution happens in layers:

Root Servers
     ↓
TLD Servers (.com, .org)
     ↓
Authoritative Servers (domain owner)
     ↓
Final IP Address

Let’s see this step by step using dig.


Understanding dig . NS — Root Name Servers

Command:

dig . NS

This asks:

👉 Who manages the root of the internet?

Output shows a list of root name servers like:

These servers don’t know IP addresses of websites.

They only know:

👉 Which servers handle top-level domains like .com, .org, .net.

Think of root servers as the starting point of DNS navigation.


Understanding dig com NS — TLD Name Servers

Command:

dig com NS

This asks:

👉 Who manages .com domains?

The response gives TLD (Top-Level Domain) servers responsible for .com.

These servers don’t store Google’s IP address.

They only know:

👉 Which name servers manage each .com domain.


Understanding dig google.com NS — Authoritative Name Servers

Command:

dig google.com NS

This asks:

👉 Which DNS servers are responsible for google.com?

The result shows Google's authoritative name servers.

These servers contain the real DNS records like:

  • A record

  • MX record

  • TXT record

They are the final authority for that domain.


Understanding dig google.com — Full DNS Resolution

Command:

dig google.com

This gives the final answer:

👉 What is the IP address of google.com?

You will see:

  • A record (IPv4 address)

  • TTL (cache time)

  • Response status

This is the same information your browser uses before opening Google.


What Happens Behind the Scenes (Browser View)

When you type google.com in your browser:

  1. Browser asks local DNS resolver

  2. Resolver contacts root servers

  3. Root points to .com TLD servers

  4. TLD points to Google’s authoritative servers

  5. Authoritative server returns IP address

  6. Browser connects to that IP

You don’t see this process — but it happens in milliseconds.


Why NS Records Matter in DNS

NS (Name Server) records define:

👉 Who controls DNS for a domain

They create the chain of trust:

  • Root → TLD → Domain owner

Without NS records:

  • DNS delegation would not work

  • Domain ownership would not be clear

  • Resolution would fail


Why dig Is Important for Developers

Using dig helps you:

  • Debug domain issues

  • Verify DNS changes

  • Understand production infrastructure

  • Diagnose slow resolution problems

It’s especially useful when:

  • Setting up servers

  • Deploying applications

  • Configuring cloud services


How This Connects to Real Websites

When users visit your website:

  • DNS decides where traffic goes

  • Load balancers depend on DNS

  • CDN routing depends on DNS

  • Backend systems rely on correct resolution

So DNS is not just theory — it directly affects performance and availability.