👈

🌐 DNS Resolution Flow (Complete Explanation)


1️⃣ What is DNS Resolution?

DNS resolution is the process of converting a human-readable domain name into an IP address.

Example:

www.google.com → 142.250.195.14

Computers understand IP addresses, not domain names.


2️⃣ Why DNS Resolution is Required

  • Humans remember names
  • Computers route using IPs
  • DNS acts like the internet’s phonebook

Without DNS:

  • You would need to remember IPs for every website

3️⃣ High-Level DNS Resolution Flow

Browser
 ↓
OS Cache
 ↓
Recursive Resolver (ISP / Public DNS)
 ↓
Root Name Server
 ↓
TLD Name Server (.com)
 ↓
Authoritative Name Server
 ↓
IP Address returned

4️⃣ Step-by-Step DNS Resolution Flow (Detailed)

Let’s assume you type:

www.example.com

🔵 Step 1: Browser Cache Check

Your browser first checks:

  • Has this domain been resolved recently?

If yes: ✔ IP returned immediately ✔ DNS process stops

If no: ➡ Move to next step


🔵 Step 2: Operating System (OS) Cache

The OS checks:

  • Local DNS cache

Command example (Linux):

nscd

If IP found: ✔ Returned to browser

If not: ➡ Next step


🔵 Step 3: Hosts File Check

The OS checks:

  • /etc/hosts (Linux/macOS)
  • C:\Windows\System32\drivers\etc\hosts (Windows)

Example entry:

127.0.0.1 mysite.local

If match found: ✔ IP returned


🔵 Step 4: Recursive DNS Resolver

If still unresolved:

  • Request goes to Recursive Resolver

Usually:

  • ISP DNS

  • Or public DNS like:

    • Google (8.8.8.8)
    • Cloudflare (1.1.1.1)

The resolver now takes responsibility to find the IP.


5️⃣ Recursive Resolver Detailed Flow

The recursive resolver performs iterative queries.


🟠 Step 5.1: Query Root Name Server

Resolver asks:

Who knows about .com?

Root server replies:

Ask .com TLD servers

📌 Root servers do NOT know IP addresses They only direct to TLD servers


🟠 Step 5.2: Query TLD Name Server (.com)

Resolver asks:

Who knows example.com?

TLD server replies:

Ask example.com authoritative server

🟠 Step 5.3: Query Authoritative Name Server

Resolver asks:

What is IP of www.example.com?

Authoritative server replies:

142.250.195.14

✔ This server is the final authority


6️⃣ Step 6: Response Sent Back

The IP address flows back:

Authoritative → TLD → Resolver → OS → Browser

7️⃣ Step 7: Caching (Very Important)

At multiple levels:

  • Recursive resolver
  • OS
  • Browser

Caching is based on:

TTL (Time To Live)

Example:

TTL = 300 seconds

After TTL expires:

  • DNS resolution happens again

8️⃣ Protocols Used in DNS Resolution

🔹 Transport Protocol

  • UDP 53 (default)
  • TCP 53 (large responses / DNSSEC)

🔹 Application Protocol

  • DNS

9️⃣ Types of DNS Queries

1️⃣ Recursive Query

  • Client → Resolver
  • Resolver does all the work

2️⃣ Iterative Query

  • Resolver → Root / TLD / Authoritative

3️⃣ Non-Recursive Query

  • Cached response

🔟 Common DNS Record Types (Exam Important)

RecordPurpose
ADomain → IPv4
AAAADomain → IPv6
CNAMEAlias
MXMail server
NSName server
TXTVerification
SOAZone info

1️⃣1️⃣ DNS Resolution in AWS (Route 53)

Example:

example.com hosted in Route 53

Flow:

  • Resolver queries Route 53 authoritative servers
  • Route 53 returns IP (EC2 / ALB / CloudFront)

Special features:

  • Latency-based routing
  • Health checks
  • Failover

1️⃣2️⃣ What Happens After DNS Resolution?

Once IP is obtained:

  1. Browser opens TCP connection
  2. HTTP / HTTPS request starts
  3. Website loads

DNS is only the first step.


1️⃣3️⃣ Common DNS Failures (Troubleshooting)

IssueCause
Website not loadingDNS not resolved
NXDOMAINDomain does not exist
Slow websiteHigh DNS latency
Works sometimesTTL caching issue

1️⃣4️⃣ Real-World Analogy

DNS is like:

  • Asking a receptionist:

    “Where does John sit?”

  • She checks:

    • Internal list
    • Department
    • Manager
  • Finally gives desk number


1️⃣5️⃣ One-Line Exam Definition

DNS resolution is the process of translating a domain name into an IP address using a hierarchical, distributed name server system.


1️⃣6️⃣ Super Short Summary

  • Browser checks cache
  • Resolver does lookup
  • Root → TLD → Authoritative
  • IP returned
  • Cached for speed