# How DNS Resolution Works

## **What is DNS and Why Name Resolution exists**

As Our Internet works on IP Addresses , not on names .

Computers communicates using the numeric identifier like **192.145.53.14** .

We humans prefer names like **Google.com**

DNS (Domain Name System) translate the human readable domain names (Google.com) into machine readable form IP Addresses (168.123.63.21) .

DNS is like a big phonebook :

* You look for a name (facebook.com)
    
* DNS gives you corresponding IP address
    
* Browser using that IP address connects you to the server
    

Without DNS we have to memorize each an every IP addresses of every website .

---

## **What Is the dig Command and When It Is Used**

**dig** (Domain Information Groper) is a DNS analysis tool.

It allows you to

* To directly Query the DNS servers
    
* Inspect DNS records (A, NS, CNAME, AAA , etc.)
    
* Understand how name resolution works step by step
    

Why we use dig

* To Debug the DNS issues
    
* To Verify configuration of domains
    
* Learn how DNS resolution actually happens
    
* Troubleshoot latency or misrouting problems
    

Unlike a browser, dig shows you raw DNS responses.

---

## **dig . NS & Root Name servers**

**dig . NS**

* . represents the DNS root
    
* NS asks for name server **records**
    

After this command you will see a list like :

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769080165294/f84dbe43-d71e-4f40-8e2e-222d3e7b1480.png align="left")

**Root name servers**

It has no idea about IPs of websites . It only know about where to find name servers .

Root servers are the starting point they answer the questions like “*Who is responsible for .com , .in , .net , .org , etc ?*“

---

## **dig com NS & TLD Name Servers**

**dig com NS**

This means asking the root servers *“Who manages the .com Domain?“*

After this command you will see a list of servers :

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769080631937/4d0ccaf0-5bc3-4a63-abac-ccd855cbd9d5.png align="center")

**Role of TLD name Servers**

TLD Servers manages top level domains ( .org , .in , .com , .gov )

They also know which authoratative servers handle each domain .

TLD servers are like Directories they answer to *“Who is responsible(Manages) for instagram.com“*

---

## **dig google.com NS & Authoritative Name Servers**

**dig google.com NS**

It is a Query to TLS Servers ; Asking for authoratative name server of google.com

We can see servers like

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769081624924/3e8f9d4f-429d-4ecf-8ac3-74cc8b67ba5d.png align="center")

**What authoritative servers do**

They Store actual DNS records and also they Provide final answers (A, AAAA, MX, TXT) .

Authoritative servers are the source of truth .

**Why NS records matter**

NS records define:

* Who controls the domain
    
* Where updates propagate from
    
* How DNS delegation works
    

---

## **dig google.com & Full DNS Resolution flow**

**dig google.com**

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1769084692130/b17d409c-e2c0-4a13-8cb6-e91032cc32b1.png align="center")

**What happens behind the scenes**

Your recursive resolver (usually your ISP or public DNS like 8.8.8.8):

1. Queries the root servers
    
2. then gets .com TLD servers
    
3. Queries the TLD servers
    
4. then gets google.com authoritative servers
    
5. Queries the authoritative servers
    
6. then receives the A record (IP address)
    

Output section -:

```plaintext
google.com.		112	IN	A	142.261.43.164
```

This is the IP our browser will connect to.
