# Demystifying DNS Resolution: How It Operates

If you are a Web Developer, Backend Learner, or System Designer Beginner, you must have to understand about DNS. Most of the people just type “google.com“, and it works. But at that time full sysytem running silently behind the sence.  
First of all you have to know about “what is DNS.”

### What is DNS ? Why name Resolution Exists

DNS stands for Domain Name System. Always think DNS as phonebook of internet.

Which cotains human like names :

```bash
google.com
youtube.com
github.com
amazon.com
```

Meanwhile Computer only understand only IP addresses:

```bash
142.250.198.11
```

That’s why exist to convert domain names into IP addresses. Without DNS, every time you want to open a website, you must have to remember their IP. That is not possible for us.

That’s the reason DNS make it also solve this problem very well.

### What is the `dig` command and When it is used

dig means Domain Infromation Groper.

This is actually a DNS debugging tool, which mostly used by :

* Developers
    
* DevOps Enginners
    
* System Admins\\
    

With this dig command, you can :

* Check DNS records
    
* See which server answers what and which
    
* Understand DNS reslolution flow
    

To check if `dig` is installed on any system:

Type this command line on your terminal(For linux):

```bash
dig -v 
```

If output comes this, then you are ready to go.

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768906526983/a71a58ed-5d2d-4dc7-8b92-4bc5d9ab56a2.png align="center")

Or if not, then install dig:

```apache
sudo apt install dnsutils
```

### DNS Resolution works in different layers

DNS doesnot answer everything from one place.

It basically works on different layers :

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768914606442/9abf2dcf-0cde-406d-9753-80720a4cac57.png align="center")

Now let’s check each layers separately using `dig`.

### Understanding `dig . NS` – Root name servers

First layer is **root**.

The dot (`.`) represents the **DNS root zone**.

Run this command:

```apache
dig . NS
```

Example output (shortened):

```apache
.     518400  IN  NS  a.root-servers.net.
.     518400  IN  NS  b.root-servers.net.
.     518400  IN  NS  c.root-servers.net.
```

### What this command mean:

* Root servers are the **top of DNS hierarchy**
    
* They don’t know IP of google.com
    
* They only know **who manages each TLD**
    
* There are 13 logical root servers (A to M)
    

Root servers answer some questions like:

> “Who handles `.com` domains?”

## Understanding `dig com NS` – TLD name servers

Second layer is **TLD (Top Level Domain)**.

For `.com`, run:

```
dig com NS
```

Example output:

```apache
com.  172800  IN  NS  a.gtld-servers.net.
com.  172800  IN  NS  b.gtld-servers.net.
```

### What this means

* `.com` is managed by **TLD servers**
    
* These servers don’t know IP of google.com
    
* They know **which authoritative servers handle google.com**
    

So TLD servers answer:

> “Who is responsible for google.com?”

## Understanding `dig google.com NS` – Authoritative name servers

Third layer is **authoritative servers**.

Run:

```apache
dig google.com NS
```

Example output:

```apache
google.com.             40283   IN      NS      ns4.google.com.
google.com.             40283   IN      NS      ns2.google.com.
google.com.             40283   IN      NS      ns1.google.com.
google.com.             40283   IN      NS      ns3.google.com.
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768913842799/c53b19eb-fcfb-420f-93db-912add65be52.png align="center")

### What this means

* These servers are **final authority**
    
* They store real DNS records of google.com
    
* They know IP address, MX records, TXT records, etc
    

Authoritative servers answer:

> “What is the IP of google.com?”

## Understanding `dig google.com` – Full DNS resolution flow

Now run the full query:

```apache
dig google.com
```

Example answer section:

```apache
google.com.             262     IN      A       142.250.193.110
```

![](https://cdn.hashnode.com/res/hashnode/image/upload/v1768913774648/982e2e26-3d82-455d-ad9f-3e13b632f58a.png align="center")

### What happened behind the scenes

Your system (or DNS resolver):

1. Asked **root server** → where is `.com`
    
2. Asked **TLD server** → where is `google.com`
    
3. Asked **authoritative server** → give IP
    
4. Got the final IP address
    

Browser then uses this IP to:

* Open TCP connection
    
* Send HTTP/HTTPS request
    
* Load website
