How DNS Resolution Works
Understanding DNS with dig: From Root Servers to Google.com
Introduction: DNS – The Internet’s Phonebook
Imagine if every time you wanted to call someone, you had to remember their phone number instead of their name. The internet would be impossible to use if we had to remember IP addresses like 142.250.183.206 instead of simple names like google.com.
This is exactly why DNS (Domain Name System) exists.
DNS is a global distributed system that translates human-friendly domain names into machine-friendly IP addresses. This process is called name resolution.
When you type:
https://www.google.com
Your system must first ask:
“What is the IP address of google.com?”
Only after getting the IP can your browser connect to Google’s server.
What is dig and Why It Is Used
dig (Domain Information Groper) is a command-line tool used to query DNS servers directly.
It is mainly used for:
Debugging DNS issues
Understanding DNS resolution
Learning how DNS works internally
Checking records like A, NS, MX, TXT, CNAME
Basic syntax
dig domain_name
Example:
dig google.com
This shows:
Which server answered
What records were returned
How long it took
Whether the response was authoritative
Think of dig as a stethoscope for DNS engineers.
DNS Works in Layers
DNS resolution happens in a strict hierarchy:
Root servers → TLD servers → Authoritative servers
This layered design makes DNS:
Scalable
Fault tolerant
Decentralized
No single server knows everything.
Step 1: Understanding dig . NS – Root Name Servers
Command:
dig . NS
This asks:
“Who manages the root of the internet?”
Output concept (simplified)
. NS a.root-servers.net
. NS b.root-servers.net
...
. NS m.root-servers.net
There are 13 logical root servers (A to M), managed by organizations like:
Verisign
ICANN
NASA
RIPE
What root servers do
Root servers:
Do NOT know IPs of websites
Only know where TLD servers are
They answer:
“For
.com, ask these servers.”
Step 2: Understanding dig com NS – TLD Name Servers
Command:
dig com NS
This asks:
“Who manages the
.comzone?”
Output concept
com NS a.gtld-servers.net
com NS b.gtld-servers.net
...
These are TLD (Top Level Domain) servers.
What TLD servers do
They:
Do not know IP of google.com
Only know who is authoritative for google.com
They answer:
“For google.com, ask Google’s DNS servers.”
Step 3: Understanding dig google.com NS – Authoritative Servers
Command:
dig google.com NS
This asks:
“Who owns google.com?”
Output concept
google.com NS ns1.google.com
google.com NS ns2.google.com
google.com NS ns3.google.com
google.com NS ns4.google.com
These are authoritative name servers.
They:
Are owned by Google
Store actual records for google.com
Give final answers
Step 4: Understanding dig google.com – Full Resolution
Command:
dig google.com
This asks:
“What is the IP of google.com?”
Output concept
google.com A 142.250.183.206
This is the A record (IPv4 address).
Now your browser can finally connect.
Full DNS Resolution Flow (Behind the Scenes)
When you type google.com in your browser:
Browser
↓
OS Resolver
↓
Recursive DNS Resolver (ISP / Cloudflare / Google DNS)
↓
Root Server
↓
TLD Server (.com)
↓
Authoritative Server (google.com)
↓
IP returned
↓
Browser connects to server
This entire process usually happens in under 50 milliseconds.
How Recursive Resolvers Work
You never directly query root or TLD servers.
Instead, your system uses a recursive resolver like:
8.8.8.8 (Google)
1.1.1.1 (Cloudflare)
Your ISP DNS
Recursive resolver:
Does all the hard work
Caches results
Protects root servers from overload
Why NS Records Matter
NS (Name Server) records define:
“Who is responsible for this domain?”
They enable:
Delegation
Fault tolerance
Load balancing
DNS independence
Without NS records:
The internet cannot route DNS queries
Domains cannot exist
Mapping dig Commands to DNS Layers
| Command | Represents |
dig . NS | Root layer |
dig com NS | TLD layer |
dig google.com NS | Authoritative layer |
dig google.com | Final resolution |
This is literally how the internet finds anything.
DNS as a System Design Masterpiece
From a system design perspective, DNS is brilliant because:
1. Distributed
No central authority stores everything.
2. Cached
Resolvers store results to reduce load.
3. Hierarchical
Each layer knows only what it must.
4. Fault tolerant
If one server fails, others exist.
5. Globally scalable
Handles billions of queries per second.
Real-World Browser Connection
When Chrome loads google.com:
DNS resolves IP
TCP connection established
TLS handshake
HTTP request sent
Response received
Without DNS:
The web literally does not exist.
Visual Mental Model
DNS Hierarchy
Root (.)
|
.com
|
google.com
|
IP Address
Resolution Flow
User → Resolver → Root → TLD → Authoritative → IP
Why Every Engineer Should Understand This
Whether you are:
Web developer
DevOps engineer
Cloud architect
Security analyst
Backend developer
DNS affects:
Website downtime
API failures
Load balancing
DDoS attacks
SSL certificates
Email delivery
Most production outages start with:
“DNS is broken.”
Final Takeaway
DNS is not just a protocol.
It is the navigation system of the internet.
And dig is your X-ray machine to see how it works.
If you understand:
dig . NS
dig com NS
dig google.com NS
dig google.com
About the author
- Hi, I'm Kanishka Shashi. I'm a Computer Science (AI & ML) student passionate about building, analyzing, and explaining technology. This blog is where I simplify complex concepts into practical, beginner-friendly guides. You'll find articles on Web Development, System Design, AI & LLMs, Data Analytics, SQL, Git/GitHub, and software engineering best practices. I enjoy exploring how modern technologies work under the hood and sharing insights through real-world examples and hands-on projects. Whether you're a student, developer, or tech enthusiast, I hope these articles help you learn something new and build better software. Learning in public. Building consistently. Sharing everything I discover.
Comments
Join the discussionNo comments yet. Be the first to comment.