DEV Community

Cover image for How DNS Resolution Works
Abhimanyu Kumar
Abhimanyu Kumar

Posted on

How DNS Resolution Works

Introduction: DNS as the Internet’s Phonebook

Imagine you want to call a friend.
You don’t remember their phone number, but you remember their name.
So you open your phonebook, search the name, and get the number.
DNS (Domain Name System) works the same way.

  • Humans remember: google.com
  • Computers understand: 142.250.195.46 (IP address)

DNS translates human-friendly domain names into machine-friendly IP addresses.
This process is called DNS Resolution.


Why Does Name Resolution Exist?

If DNS didn’t exist:

  • You would have to type IP addresses instead of website names
  • Websites changing servers would break bookmarks
  • The internet would be unusable for humans So DNS exists to make the internet scalable, flexible, and human-friendly.

What is the dig Command?

dig stands for Domain Information Groper.
It is a DNS diagnostic tool used to:

  • Inspect DNS records
  • Understand how a domain is resolved
  • Debug DNS issues

Think of dig as an X-ray machine for DNS lookups.
dig google.com

This shows:

  • Which servers were contacted
  • What records were returned
  • How long it took

DNS Resolution Happens in Layers


DNS resolution does not happen in one step.
It happens in a hierarchy:

  1. Root Name Servers
  2. TLD Name Servers (.com, .org, .in)
  3. Authoritative Name Servers

Let’s understand each layer using dig.


Understanding dig . NS → Root Name Servers

dig . NS
What does this mean?

  • . (dot) represents the DNS root
  • This command asks: “Who manages the entire DNS system?”

Real-life example
Imagine a country:

  • The central government doesn’t know every house address
  • But it knows which state offices exist

Root servers don’t know IPs of websites
They only know where to find TLD servers


Understanding dig com NS → TLD Name Servers

dig com NS

What does this mean?

  • Asking: “Who manages all .com websites?”

Real-life example

Continuing the address analogy:

  • Country → State → City → House
  • .com is like a state
  • TLD servers know which authoritative servers manage domains

They don’t know google.com IP,
but they know who to ask next.


Understanding dig google.com NS → Authoritative Servers

dig google.com NS

What does this show?

  • The authoritative name servers for google.com
  • These servers hold the actual DNS records

Real-life example
This is like reaching the local house registry office:

  • They know the exact address
  • Final and trusted source of information

Authoritative servers give the real IP address

Understanding dig google.com → Full DNS Resolution Flow

dig google.com

This triggers the complete DNS resolution process.

Step-by-step flow (Real-life analogy)

  1. Browser asks the Recursive Resolver

    “Where is google.com?”

  2. Resolver asks Root Server

    “Who handles .com?”

  3. Root replies

    “Ask the .com TLD servers”

  4. Resolver asks TLD Server

    “Who handles google.com?”

  5. TLD replies

    “Ask Google’s authoritative servers”

  6. Resolver asks Authoritative Server

    “What is the IP of google.com?”

  7. Authoritative server replies

    “Here is the IP: 142.xxx.xxx.xxx”

  8. Resolver returns the IP to the browser

  9. Browser connects to Google’s server


What Are NS Records and Why They Matter?

NS (Name Server) records tell:

  • Which servers are responsible for a domain

Why important?

  • Load balancing
  • Fault tolerance
  • Faster resolution
  • High availability

Without NS records:

  • DNS delegation would fail
  • Websites would become unreachable

Role of Recursive Resolver (Behind the Scenes)

The recursive resolver (ISP / Google DNS / Cloudflare DNS):

  • Performs all DNS steps on your behalf
  • Caches responses for faster future access
  • Protects browsers from DNS complexity

Browsers do not talk to root servers directly.


Connecting DNS to Real Browser Requests

When you type:

https://google.com

Behind the scenes:

  • DNS resolves the domain
  • Browser gets the IP
  • TCP connection is created
  • HTTPS handshake happens
  • Webpage loads

DNS is the first and mandatory step in web communication.


Less time to coverup summary

  • DNS is the foundation of the internet
  • dig helps visualize DNS resolution
  • Resolution happens in layers
  • Recursive resolvers hide complexity
  • Every browser request starts with DNS

Top comments (0)