Skip to main content

Command Palette

Search for a command to run...

Understanding How DNS Resolution Works Step-by-Step

Understanding the Internet’s Phonebook Through dig

Published
4 min read
Understanding How DNS Resolution Works Step-by-Step

🧐 Overview

If the internet were a city, DNS would be the address book that ensures you reach the right house instead of wandering aimlessly.

You type google.com.
Your browser finds the correct server among billions of machines worldwide.
That "somehow" is DNS resolution.

📖 What Is DNS and Why Name Resolution Exists

Computers do not understand names.
They understand IP addresses (numbers).

DNS (Domain Name System) exists to translate names → numbers.

Real-life example 🏠

Think of DNS like asking for an address:

You say:

“Take me to Rahul’s house.”

The system figures out:

  • Which city

  • Which area

  • Which exact house

You don’t care how — you just want to arrive.


🛠️ What Is the dig Command and When It Is Used

Browsers hide DNS completely.
dig removes the curtain 🎭.

dig (Domain Information Groper) is a diagnostic tool that lets you:

  • Inspect DNS resolution

  • Debug DNS problems

  • See which servers are involved

  • Understand why a domain resolves the way it does

Think of dig as:

🩻 An X-ray for DNS


🧱 DNS Resolution Happens in Layers

DNS is not one big database.
It’s hierarchical.

The three layers 🪜

  1. Root name servers (.)

  2. TLD name servers (.com, .org, .in)

  3. Authoritative name servers (domain owners)

Each layer answers only one question:

“Who should I ask next?”


🌍 Understanding dig . NS — Root Name Servers

dig . NS

This asks:

“Who manages the root of the internet?”

What root servers do

  • They do not know IP addresses

  • They do not know websites

  • They only know where TLDs live

🧠 Mental model:

Root servers are the index page of the internet.

They simply say:

“If you’re looking for .com, go there.”


🏷️ Understanding dig com NS — TLD Name Servers

dig com NS

This asks:

“Who manages all .com domains?”

What TLD servers do

  • Handle millions of domains

  • Still don’t know Google’s IP

  • Know who owns each domain

Their answer is basically:

“For google.com, ask Google’s name servers.”


🏠 Understanding dig google.com NS — Authoritative Servers

dig google.com NS

This is the most important step.

These servers are authoritative because:

  • They own the DNS records

  • They store the final truth

They manage:

  • IP addresses (A/AAAA records)

  • Mail routing (MX)

  • Verification & security (TXT)

🚨 If these servers go down → the site goes down.


🎯 Understanding dig google.com — Full DNS Resolution

dig google.com
google.com → 142.250.xxx.xxx

This is the only thing the browser actually needs.

Everything before this was just:

Finding the right person to ask.

🔄 What Really Happens When You Type a Website

Behind the scenes:

  1. Browser asks a recursive resolver

  2. Resolver asks root servers

  3. Root points to .com

  4. .com points to Google’s authoritative servers

  5. Google returns the IP

  6. Resolver caches the result 🧠

  7. Browser connects to the IP 🌐

You only see:

“The page loaded.”


🧑‍🔧 Recursive Resolvers: The Hidden Workers

Your browser never talks to root servers directly ❌.

A recursive resolver does the heavy lifting.

What it does:

  • Walks the DNS hierarchy

  • Caches responses

  • Reduces global DNS load

That’s why:

  • First visit = slower 🐢

  • Next visit = instant ⚡


🧠 What NS Records Represent (and Why They Matter)

NS records answer one question:

“Who is allowed to speak for this domain?”

From a system-design perspective:

  • NS records define trust

  • Enable scalability

  • Allow failover

  • Power CDNs and geo-routing

💡 Control NS records = control traffic.


🗺️ Mapping dig Commands to DNS Stages

dig commandDNS layerWhat it shows
dig . NSRootWho runs DNS
dig com NSTLDWho runs .com
dig google.com NSAuthoritativeWho owns Google
dig google.comFinalIP address

🌐 Connecting DNS to Real Browsers

Before:

  • HTTP

  • HTTPS

  • APIs

  • Load balancers

  • Microservices

There is always:

DNS first

No DNS ❌
No connection ❌
No internet ❌


🧩 Final Mental Model (Keep This Forever)

  • DNS is layered, not magical ✨

  • Each server knows just enough

  • Recursive resolvers glue everything together

  • dig exposes reality

  • Browsers hide complexity

Once DNS clicks, the internet stops feeling mysterious - and starts feeling engineered