Skip to main content

Command Palette

Search for a command to run...

How DNS Resolution Works

Published
β€’3 min read

What is DNS and Why Name Resolution Exists

Computers do not understand names like google.com.
They understand numbers (IP addresses) like 142.250.190.14.

πŸ‘‰ DNS (Domain Name System) converts:

google.com β†’ IP address

Simple analogy

Phonebook

  • Name β†’ Phone number

  • Website name β†’ IP address

Without DNS, you would have to remember IPs for every website.


What is dig and Why It Is Used

dig means Domain Information Groper.

It is a command-line tool used to:

  • check DNS records

  • see which servers answer DNS queries

  • understand how name resolution happens

πŸ‘‰ Browsers use DNS silently.
πŸ‘‰ dig lets humans see it.


DNS Works in Layers

DNS resolution happens in levels:

Root Server
   ↓
TLD Server (.com, .org)
   ↓
Authoritative Server (google.com)

Each level gives directions, not the final answer (until the end).


1️⃣ dig . NS β†’ Root Name Servers

Command:

dig . NS

What this means

  • . means root of DNS

  • NS means name servers

What you learn

πŸ‘‰ This shows root name servers
πŸ‘‰ Root servers know:

β€œWho handles .com, .org, .net?”

πŸ“Œ Root servers do not know IPs of websites
They only give directions.


2️⃣ dig com NS β†’ TLD Name Servers

Command:

dig com NS

What this means

  • Asking: β€œWho manages .com domains?”

What you learn

πŸ‘‰ These are TLD (Top Level Domain) servers
πŸ‘‰ They know:

β€œWhich name servers are responsible for google.com, amazon.com, etc.”

Still no IP yet.


3️⃣ dig google.com NS β†’ Authoritative Name Servers

Command:

dig google.com NS

What this means

  • Asking: β€œWho is the boss for google.com DNS?”

What you learn

πŸ‘‰ These servers are authoritative
πŸ‘‰ They own the DNS records for google.com

They know:

  • A record

  • MX record

  • CNAME

  • everything about google.com


4️⃣ dig google.com β†’ Final Answer (IP Address)

Command:

dig google.com

What happens internally

  1. Ask root β†’ where is .com?

  2. Ask .com β†’ where is google.com?

  3. Ask authoritative server β†’ what is IP?

  4. Get IP address βœ…

πŸ‘‰ This is the full DNS resolution flow.


How Browser Uses DNS (Real Life)

When you type:

google.com

Your browser:

  • asks a recursive resolver (ISP / Google DNS)

  • resolver does all root β†’ TLD β†’ authoritative work

  • browser gets IP

  • browser connects to server

You never see this β€” but dig shows it.


What NS Records Mean (Very Simple)

NS record = Who is responsible for this domain

Example:

google.com β†’ ns1.google.com

πŸ‘‰ It tells:

β€œAsk this server for answers about this domain.”


Mental Model :

Think of DNS like asking directions:

  • Root β†’ β€œGo to .com office”

  • TLD β†’ β€œGo to Google office”

  • Authoritative β†’ β€œHere is the exact address”


Simple Diagram

Browser
  ↓
Recursive Resolver
  ↓
Root Server
  ↓
TLD Server (.com)
  ↓
Authoritative Server (google.com)
  ↓
IP Address