# Understanding DNS and Name Resolution

**What is DNS?**

DNS stands for Domain Name System. It is a system that converts website names (like [google.com](http://google.com)) into IP addresses that computers can understand. When you type [google.com](http://google.com) in your browser, your computer does not know where [google.com](http://google.com) is located. So DNS helps to find the IP address of [google.com](http://google.com) and connect you to the correct server.

**Why Name Resolution Exists?**

Computers communicate with each other using IP addresses (like 142.251.41.14), but humans cannot remember all these long numbers. So DNS was created to convert easy-to-remember domain names (like [google.com](http://google.com)) into their corresponding IP addresses. This process is called name resolution. Without DNS, you would have to type IP addresses instead of domain names every time you want to visit a website.

**What is the dig Command?**

dig stands for Domain Information Groper. It is a command-line tool that is used to query DNS servers and get information about domain names. Dig command helps us to understand how DNS works and troubleshoot DNS-related problems. When you run dig command, it shows you the complete DNS resolution process - from the root server all the way to the authoritative name server.

**When is dig Command Used?**

Dig command is used when:

*   You want to find the IP address of a website
    
*   You want to check if a domain name is working properly
    
*   You want to troubleshoot DNS issues
    
*   You want to understand the DNS resolution process step by step
    
*   Network administrators want to debug DNS problems
    

**Understanding dig . NS and Root Name Servers:**

**What is the Root Name Server?**

The root name server is the first step in DNS resolution. When you request [google.com](http://google.com), your computer first asks the root name server "Where should I go to find [google.com](http://google.com)?" The root name server does not know the IP address of [google.com](http://google.com) directly. Instead, it tells you which server can help you find [google.com](http://google.com).

**What Does dig . NS Show?**

When you run the command `dig . NS`, it shows all the root name servers in the world. These are 13 root name servers ([a.root-servers.net](http://a.root-servers.net), [b.root-servers.net](http://b.root-servers.net), [c.root-servers.net](http://c.root-servers.net), etc.). Although there are only 13 official root servers concept-wise, they have 1600+ copies (instances) distributed across the world to handle trillions of DNS queries every day. This is similar to how banks have one main office but thousands of branches.

**How Root Name Servers Work:**

Your Computer sends request → Root Name Server receives it (dig . NS)  
Root Name Server checks the domain extension (.com, .org, .edu)  
Root Name Server responds with the address of the TLD (Top Level Domain) name server  
Your Computer then knows where to go next

**Understanding dig com NS and TLD Name Servers:**

**What is a TLD Name Server?**

TLD stands for Top Level Domain. Common TLDs are .com, .org, .edu, .pk, .net, etc. When the root name server tells your computer to ask a TLD name server, your computer then asks the .com TLD name server "Where can I find [google.com](http://google.com)?"

**What Does dig com NS Show?**

When you run the command `dig com NS`, it shows all the TLD name servers for .com domains. These servers know about all .com domain names and can tell you which server is responsible for each .com domain. For example, if you ask the .com TLD server about [google.com](http://google.com), it will tell you which server manages [google.com](http://google.com)'s DNS records.

**How TLD Name Servers Work:**

Your Computer asks TLD Name Server → "Where is [google.com](http://google.com)?"  
TLD Name Server checks its database  
TLD Name Server responds with the address of [google.com](http://google.com)'s authoritative name server  
Your Computer now knows where to go to get the actual IP address

**The Flow So Far:**

Your Computer → Root Name Server (dig . NS) → TLD Name Server (dig com NS) → Authoritative Name Server (coming next)

**Understanding dig** [**google.com**](http://google.com) **NS and Authoritative Name Servers:**

**What is an Authoritative Name Server?**

The authoritative name server is the actual server that knows the IP address of [google.com](http://google.com). It is owned and managed by Google company itself. This is the final step in DNS resolution. Authoritative name servers store the actual DNS records for the domain.

**What Does dig** [**google.com**](http://google.com) **NS Show?**

When you run the command `dig` [`google.com`](http://google.com) `NS`, it shows which servers are the authoritative name servers for [google.com](http://google.com). For Google, you will see servers like [ns1.google.com](http://ns1.google.com), [ns2.google.com](http://ns2.google.com), [ns3.google.com](http://ns3.google.com), [ns4.google.com](http://ns4.google.com). These are Google's own name servers that store the IP address information for [google.com](http://google.com) and other Google domains.

**How Authoritative Name Servers Work:**

Your Computer asks Authoritative Name Server → "What is the IP address of [google.com](http://google.com)?"  
Authoritative Name Server checks its database  
Authoritative Name Server responds with the IP address: 142.251.41.14  
Your Computer receives the IP address and connects to Google's server

**Why Multiple Authoritative Servers?**

Google uses multiple authoritative name servers (ns1, ns2, ns3, ns4) for redundancy and load balancing. If one server goes down, the others can still respond to DNS queries. This ensures that the website remains accessible all the time.

**Understanding dig** [**google.com**](http://google.com) **and the Full DNS Resolution Flow:**

**What Happens When You Run dig** [**google.com**](http://google.com)**?**

When you run the command `dig` [`google.com`](http://google.com), it shows you the complete DNS resolution process. It shows you the actual IP address of [google.com](http://google.com) and how your computer found it. This is the final query after going through all the previous steps.

**The Complete DNS Resolution Flow:**

Step 1: Your Computer sends request → "I want to visit [google.com](http://google.com)"

Step 2: Root Name Server receives it (dig . NS)  
Root Name Server says "I don't know [google.com](http://google.com), but ask the .com TLD server"

Step 3: Your Computer asks TLD Name Server (dig com NS)  
TLD Name Server says "I know about .com domains, but for [google.com](http://google.com) specifically, go ask [ns1.google.com](http://ns1.google.com)"

Step 4: Your Computer asks Authoritative Name Server (dig [google.com](http://google.com) NS)  
Authoritative Name Server ([ns1.google.com](http://ns1.google.com)) responds with the IP address: 142.251.41.14

Step 5: Your Computer receives the IP address and connects to Google's server  
Your Browser displays Google homepage

**Why This Process Is Important:**

This entire process happens in milliseconds. When you type [google.com](http://google.com) in your browser, you are immediately connected to the correct server without knowing the IP address. DNS makes the Internet user-friendly and easy to use.

**What Each dig Command Shows:**

*   `dig . NS` → Shows root name servers
    
*   `dig com NS` → Shows TLD name servers for .com
    
*   `dig` [`google.com`](http://google.com) `NS` → Shows authoritative name servers for [google.com](http://google.com)
    
*   `dig` [`google.com`](http://google.com) → Shows the IP address of [google.com](http://google.com) and the complete resolution process
    

**Real-Life Example:**

Think of the DNS resolution process like finding someone's address:

You ask your friend (Root Server): "Where does Ali live?"  
Friend says: "I don't know, ask the city office (TLD Server)"

You go to City Office: "Where does Ali live in this city?"  
City Office says: "I don't know exactly, but ask his neighborhood office (Authoritative Server)"

You go to Neighborhood Office: "Where does Ali live?"  
Neighborhood Office says: "Ali lives at House 123, Block 5"

Now you know the exact address and can visit.

Same way, your computer goes from Root Server → TLD Server → Authoritative Server to find the IP address of the website you want to visit.

* * *

You can find more of my work at [abdulrdeveloper.me](https://abdulrdeveloper.me)  
Read more posts at [blog.abdulrdeveloper.me](https://blog.abdulrdeveloper.me)
