How DNS Resolution Works (Step-by-Step with dig Command)
Understand Root → TLD → Authoritative DNS lookups and see how your browser finds the real IP behind a domain name.

Hi, I’m Shubham 👋 A learner sharing my journey in programming, tech, and self-growth. Learning every day and writing what I learn.
What is DNS and why does name resolution exist?
DNS (Domain Name System) is the internet’s phonebook 📖
Humans like typing simple names such as:
But computers don’t understand names — they need IP addresses like:
✅ 142.250.x.x
So DNS exists to solve one big problem:
Domain name → IP address conversion
This process is called DNS Resolution.
What is the dig command and when is it used?
dig stands for Domain Information Groper.
It’s a command-line tool used to inspect DNS records and understand how resolution works.
You use dig when you want to:
✅ check the IP of a domain
✅ check NS/MX/TXT records
✅ debug DNS issues
✅ verify DNS configuration changes
✅ understand how DNS lookup happens
Example:
dig google.com
DNS Resolution happens in layers (big picture)
DNS works like a hierarchy, layer by layer:
✅ Root Name Servers → (.)
✅ TLD Name Servers → (.com, .org, .in)
✅ Authoritative Name Servers → (the real DNS for a domain)
Easy way to remember:
Root → TLD → Authoritative → Answer
1. dig . NS — Root Name Servers
Command:
dig . NS
What does this mean?
. represents the root zone, the top of the DNS hierarchy.
What will you see?
A list of root name servers, such as:
b.root-servers.net
… and more.
What do root servers do?
Root servers don’t give you the final IP address.
They basically guide you:
✅ “If you want .com, ask these TLD name servers.”
Think of root as:
📌 the main reception desk of the internet.
2) dig com NS — TLD Name Servers (.com)
Command:
dig com NS
What does this show?
It shows the name servers responsible for the .com TLD.
What do TLD servers do?
They still don’t give the final IP address.
They guide you again:
✅ “For google.com, these are the authoritative name servers.”
Think of TLD servers as:
📌 the post office for .com domains.
3. dig google.com NS — Authoritative Name Servers
Command:
dig google.com NS
What does this show?
This shows the authoritative name servers for google.com.
These servers are responsible for storing the actual DNS records for that domain.
Example output might include:
ns2.google.com
and so on.
Why do authoritative name servers matter?
Because they hold the real answers:
✅ A record (IP address)
✅ MX record (email routing)
✅ TXT record (verification/security)
✅ CNAME records, etc.
Think of authoritative servers as:
📌 the official domain owner’s records office.
4. dig google.com — The final DNS answer
Command:
dig google.com
What happens here?
This returns the final record, usually:
✅ A record (IPv4 address)
✅ and sometimes AAAA record (IPv6 address)
Example:
So this is what your browser really needs to connect and load the website.
The full DNS resolution flow (what happens behind the scenes)
When you type google.com in your browser:
Step-by-step:
Your browser asks your OS:
“What’s the IP address ofgoogle.com?”Your device checks local cache
If not found, it asks a Recursive DNS Resolver
(like your ISP DNS, Google DNS8.8.8.8, Cloudflare DNS1.1.1.1)The recursive resolver performs the lookup in layers:
asks Root servers where
.comlivesasks TLD servers who controls
google.comasks Authoritative servers for the final IP
It returns the IP address back to your device
Your browser connects to that IP and loads the website ✅
What are NS records and why do they matter?
NS records tell the world:
✅ “These are the official DNS servers for this domain.”
If NS records are wrong:
❌ website may not open
❌ email may stop working
❌ domain resolution fails
So NS records are like:
📌 “Who is responsible for this domain?”
The role of Recursive Resolvers (the hidden hero)
Your laptop/phone does NOT usually talk directly to root or TLD servers.
That hard work is done by the recursive resolver, which:
✅ performs lookups on your behalf
✅ caches answers (based on TTL)
✅ makes browsing faster
✅ reduces load on DNS infrastructure
That’s why fast DNS services can make your internet feel faster too.
How dig commands map to DNS resolution stages
dig command | What it shows |
dig . NS | Root name servers |
dig com NS | .com TLD name servers |
dig google.com NS | Authoritative name servers |
dig google.com | Final DNS answer (A/AAAA record) |
Connecting this to real browser requests
Every time you open any website, DNS is the first step:
✅ browser needs IP
✅ DNS gives IP
✅ browser connects to server
✅ website loads
No DNS = no website.
Final takeaway (easy mental model)
DNS resolution is a layered lookup system:
Root → TLD → Authoritative → IP address → Website
And dig is your tool to see the steps clearly.




