How DNS Resolution Works
Discover the Process Behind DNS Resolution

Hi, I’m Abdul Samad. A web development learner and tech enthusiast. I write about what I learn, share practical coding tips, and publish in-depth blogs on programming and modern web development.
Check out my full collection of blogs on Hashnode: https://abdulsamad30.hashnode.dev/
Connect with me on X for quick updates and insights: @abdul_sama60108
How DNS Works : From Domain Name to IP Address
When you want to visit a website like youtube.com, you just type the name in your browser. This name is easy for humans to remember, but computers don’t understand it. Computers need the IP address of the website to connect, something like 207.223.160.0.
So the domain name (youtube.com) is for humans, while the IP address (207.223.160.0) is what computers use to actually find the website.
You might wonder: “I don’t type any IP address, so how does my computer find it?”
This is where DNS comes in.
DNS stands for Domain Name System. It’s like the internet’s phone book.
You give it a domain name like
youtube.com.DNS finds the corresponding IP address and gives it to your browser.
Your browser then uses the IP to connect to the website.
Think of it like your mobile phone contacts:
You save your friend’s name along with their phone number.
You search by name because it’s easy to remember, but your phone uses the number to actually make the call.
Similarly, DNS lets you search websites by name while the computer connects using the IP address. From a top-level view, DNS is essentially a phone book for the internet.
Example: Domain Names and IP Addresses
| Domain Name | IP Address |
| youtube.com | 207.223.160.0 |
| google.com | 142.250.190.78 |
| facebook.com | 157.240.22.35 |
| twitter.com | 104.244.42.1 |
Understand the flow of DNS through Diagram

Now it’s time to deepen more in DNS and understand how it works internally.
Inside flow of DNS : How it works internally
From a top-level view, we know that DNS is like a phone book for the internet. But when we dig deeper, we see that DNS does not directly give your computer the IP address in one step. It tells your computer "whom to talk to next" until it finds the answer.
At first, this may sound confusing, but let us break it down with a simple analogy.
DNS as a Big Organized Phone Book
Imagine DNS as a massive phone book for the whole country, for example, India. This phone book is divided into sections to make it easier to find people:
Country Section – The main book for India
State or City Section – Inside India, there are sections for Mumbai, Delhi, Bangalore, etc.
Local Area Section – Inside Mumbai, there are sections for Andheri, Bandra, Colaba, etc.
Individual Names – Finally, you find the person you are looking for along with their phone number
How DNS Uses This Concept
Here is what happens step by step :
Your browser asks the recursive DNS server for YouTube’s IP
The recursive server asks the root server
"Where can I find
.comdomains?"Root server points to the .com TLD server (like pointing to Mumbai in our phone book)
The recursive server asks the TLD server
"Where is
youtube.com?"TLD server points to the authoritative server for YouTube (like finding the exact Andheri section)
The recursive server asks the authoritative server
"What is the IP of
youtube.com?"Authoritative server gives the exact IP address (
142.250.190.78)
Finally, the recursive server gives this final IP back to your browser, which can now connect to YouTube.
But remember ;
When you type a website like youtube.com into your browser, your browser does not talk to all the DNS servers directly. Instead, it asks a recursive DNS server to do all the work and then at the end recursive DNS server gives the final IP to browser.
Why DNS Works This Way
Breaking it into steps has two advantages:
Efficiency: Each server only needs to know its "section" of the internet, not every website
Scalability: The system can handle billions of requests without one server being overloaded
Browser simplicity: Your browser does not need to contact multiple servers; the recursive DNS server handles everything
Simplified Table
| Step | DNS Server Type | Analogy in Phone Book | What It Provides / Gives |
| 1 | Root Server | Main India phone book | Tells which TLD server to ask (like .com, .in) |
| 2 | TLD Server | City section (Mumbai, Delhi) | Tells which authoritative server to ask for the domain |
| 3 | Authoritative Server | Local area section (Andheri) | Gives the exact IP address of the domain |
| 4 | Your Browser | You dialing the number | Receives the final IP and connects to the website |
This is the internal flow of DNS, from the top-level root down to the exact IP, with the recursive DNS server acting on behalf of your browser to find the answer.
Here’s the diagram of this whole process :

But Remember ;
When we say :
"Recursive DNS sequentially asks root → TLD → authoritative, then finally returns the IP to the browser"
Here’s what it really means :
Recursive DNS asks root first:
Your browser wants the IP for
youtube.com.The recursive DNS server starts by asking the root server: “Where can I find
.comdomains?”Root server does not know the IP, it only points to the
.comTLD server.
Then recursive DNS asks the TLD server:
Recursive DNS now asks the
.comTLD server: “Where isyoutube.com?”TLD server does not know the IP either, it only points to the authoritative server for
youtube.com.
Then recursive DNS asks the authoritative server:
Recursive DNS asks the authoritative server: “What is the IP of
youtube.com?”This server finally knows the IP and responds with it.
Recursive DNS returns the IP to your browser:
The recursive DNS server takes the IP from the authoritative server and gives it to your browser.
Now your browser can connect to the website using the IP.
Now you might be wondering… where are these servers, who owns them, and how many exist?
DNS Servers: Ownership, Providers, and Global Distribution
1. Root Servers
Role: Top-level guide for all DNS requests. Tells recursive DNS servers where to find TLD servers like
.com,.org,.in.Ownership:
There are 13 root server “letters”:
AthroughM.They are operated by different organizations worldwide, including:
ICANN (
Aroot)Verisign (
Broot)University of Maryland, USC, NASA, RIPE NCC, etc.
Number of servers:
- 13 logical servers, but each has hundreds of physical copies worldwide using Anycast.
Platform / Provider: Operated by a mix of government, academic, and private organizations.
Fun fact: These servers are distributed globally so even if one fails, DNS still works.
2. TLD Servers
Role: Manage top-level domains like
.com,.org,.net,.in,.uk.Ownership:
Each TLD has its own set of authoritative servers.
Example:
.comand.netare managed by Verisign.Country-code TLDs (ccTLDs) like
.in(India),.uk(UK) are managed by their national organizations.
Number of servers:
- Depends on the TLD, but usually multiple servers per TLD for redundancy.
Platform / Provider: Managed by registries for each TLD, sometimes with multiple operators.
3. Authoritative Servers
Role: Hold the final IP addresses for a domain.
Ownership:
Usually owned by the company or organization that owns the domain.
Example: YouTube’s authoritative servers are owned by Google.
Number of servers:
- Depends on the domain. Big companies often have multiple servers globally for speed and reliability.
Platform / Provider:
Large companies host their own (Google, Microsoft, Amazon)
Small websites may use DNS providers like Cloudflare, GoDaddy, AWS Route 53, or Namecheap.
Recursive DNS / Resolver Servers
Role:
Recursive DNS servers do all the asking and collecting of IP addresses for your browser. They communicate with root servers, TLD servers, and authoritative servers to find the final IP.
Ownership:
Recursive DNS servers are usually provided by Internet Service Providers (ISPs) and public DNS providers.
Examples of ISPs:
Pakistan : PTCL, Jazz, Telenor
India : Reliance Jio, Airtel, BSNL
United States : Comcast, AT&T, Verizon
Public DNS providers: Google DNS, Cloudflare, OpenDNS
Number of servers:
There are thousands of recursive DNS servers worldwide. Every ISP has multiple servers, and public DNS providers like Google have servers distributed globally for speed and reliability.
Platform / Provider Examples:
Google DNS: 8.8.8.8 and 8.8.4.4
Cloudflare DNS: 1.1.1.1
OpenDNS / Cisco: 208.67.222.222
Now go one step further and understand What is NS ( Name server ) ?
What is an NS Record?
NS stands for Name Server.
A Name Server is a server that knows where the authoritative information for a domain is stored.
An NS Record is a DNS record that points to the authoritative server for a domain.
It does not contain the IP address itself.
It tells the DNS system: “If you want to know the IP for this domain, go ask this server.”
Why NS Records Matter
Point to the Right Authoritative Server
When your browser wants to reach
example.com, the recursive DNS server needs to know which server actually holds the IP. The NS record provides that information.Organize DNS Queries
The internet has millions of domains. NS records divide responsibility, so recursive DNS servers know exactly which authoritative server to ask instead of searching blindly.
Provide Redundancy
Domains often have multiple NS records. If one server fails, the others can respond, keeping the domain reachable.
Essential for Domain Resolution
Without NS records, recursive DNS servers would not know where to find the authoritative server, so your browser could never get the IP.
Technical Analogy Using Actual DNS
You want to visit
youtube.com.Your recursive DNS server asks the
.comTLD server: “Who is authoritative foryoutube.com?”The TLD server responds with the NS records for YouTube:
ns1.google.comns2.google.com
The recursive DNS server then asks
ns1.google.com, which responds with the IP address ofyoutube.com.Your browser receives the IP and connects.
Key point: NS records are like a directory pointer inside the DNS system that tells recursive servers which authoritative server to ask.
Example of NS Records
| Domain | NS Record |
| youtube.com | ns1.google.com |
| youtube.com | ns2.google.com |
| example.com | ns1.examplehost.com |
| example.com | ns2.examplehost.com |
- Large domains often have multiple NS records for reliability.
In short:
An NS record does not store the IP itself. It points to the authoritative name server for a domain. Recursive DNS servers use this to get the actual IP and deliver it to your browser.

Understanding the dig Command and DNS Resolution
If you are learning about networking or DNS, one tool you will often see is the dig command. In this blog, we will explain what dig is, how it works, and how it helps us understand the DNS resolution process using real examples.
What is the dig Command?
dig stands for Domain Information Groper. It is a command-line tool used to query Domain Name System (DNS) servers and get information about domain names.
You can use dig to find:
IP addresses of a domain
Name servers for a domain
Mail servers
DNS records like A, AAAA, MX, NS, TXT, and more
It is mostly used by network engineers, system administrators, and anyone who wants to debug DNS problems.
Use dig when you want to debug DNS issues, check domain configuration, or verify which servers are authoritative for a domain.
Understanding Root Name Servers with dig . NS
Every DNS query starts from the root servers. Root servers are the top-level DNS servers that know where to find Top-Level Domain (TLD) servers like .com, .org, or .net.
You can check the root name servers using the command:
dig . NS
Here is the output:
;;ANSWERSECTION:
.518400INNSa.root-servers.net.
.518400INNSb.root-servers.net.
.518400INNSc.root-servers.net.
.518400INNSd.root-servers.net.
.518400INNSe.root-servers.net.
.518400INNSf.root-servers.net.
.518400INNSg.root-servers.net.
.518400INNSh.root-servers.net.
.518400INNSi.root-servers.net.
.518400INNSj.root-servers.net.
.518400INNSk.root-servers.net.
.518400INNSl.root-servers.net.
.518400INNSm.root-servers.net.
These are the 13 root servers that form the starting point of DNS queries worldwide. The number 518400 is the Time To Live (TTL),
TTL shows how long other servers can remember this information before asking again.
Understanding TLD Name Servers with dig com NS
Once the root server is contacted, it directs us to the Top-Level Domain (TLD) servers for the domain we want. For example, if we want a .com domain, we check the .com TLD servers.
The command to see TLD servers for .com is:
dig com NS
Output:
;;ANSWERSECTION:
com.172800INNSa.gtld-servers.net.
com.172800INNSb.gtld-servers.net.
com.172800INNSc.gtld-servers.net.
com.172800INNSd.gtld-servers.net.
com.172800INNSe.gtld-servers.net.
com.172800INNSf.gtld-servers.net.
com.172800INNSg.gtld-servers.net.
com.172800INNSh.gtld-servers.net.
com.172800INNSi.gtld-servers.net.
com.172800INNSj.gtld-servers.net.
com.172800INNSk.gtld-servers.net.
com.172800INNSl.gtld-servers.net.
com.172800INNSm.gtld-servers.net.
The TLD servers know the authoritative servers for every domain under .com.
Finding Authoritative Name Servers with dig google.com NS
The next step in DNS resolution is to find the authoritative name servers for a specific domain. These servers have the final answer about a domain’s records.
For example, for google.com, we can run:
dig google.com NS
Output:
;;ANSWERSECTION:
google.com.221INNSns4.google.com.
google.com.221INNSns1.google.com.
google.com.221INNSns3.google.com.
google.com.221INNSns2.google.com.
;;ADDITIONALSECTION:
ns1.google.com.280INA216.239.32.10
ns2.google.com.280INA216.239.34.10
These are the authoritative name servers for google.com. They store the actual DNS records, including IP addresses.

Resolving a Domain Name to IP Address
Finally, if you want to get the IP address of a domain, you can simply run:
dig google.com
Example output:
;;ANSWERSECTION:
google.com.88INA142.250.200.174
Here, 142.250.200.174 is the IPv4 address of google.com.

How the Full DNS Resolution Works
When your computer wants to find the IP address of a domain like google.com, it goes through multiple layers of DNS servers. Each layer answers a different part of the question.
Diagram of the whole flow :

Step 1: Root Servers
Command:
dig . NS
Your computer first asks root servers for the next step in the DNS path.
Root servers don’t know the IP of
google.comdirectly. They only know where to find the .com TLD servers.Example root server:
a.root-servers.net.
Step 2: TLD Servers
Command:
dig com NS
Your computer then asks the
.comTLD servers wheregoogle.com’s authoritative name servers are.TLD servers manage all domains under their top-level domain.
Example TLD server:
a.gtld-servers.net.
Step 3: Authoritative Name Servers
Command:
dig google.com NS
Authoritative name servers store the actual DNS records for the domain.
They provide the definitive answer for
google.com.Example authoritative server:
ns1.google.com.
Step 4: Getting the IP Address
Command:
dig google.com
Finally, your computer asks the authoritative server for the A record (IP address) of
google.com.The server responds with the IP address, for example,
142.250.200.174.
Summary of Layers and Commands
| Layer | Command | Purpose |
| Root Servers | dig . NS | Get TLD server addresses |
| TLD Servers (.com) | dig com NS | Get authoritative servers for the domain |
| Authoritative Name Server | dig google.com NS | Get DNS records stored for the domain |
| Domain IP Resolution | dig google.com | Get the IP address |
Conclusion
The dig command is a simple but powerful tool to explore DNS. By using dig, you can see how DNS queries move from root servers to TLD servers, then to authoritative servers, and finally resolve the IP address of a website.
This tool is very useful for debugging DNS problems and understanding how the internet works behind the scenes.




