4.3.23 · D2 · HinglishComputer Networks

Visual walkthroughDNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

2,459 words11 min read↑ Read in English

4.3.23 · D2 · Coding › Computer Networks › DNS — recursive vs iterative query, hierarchy, record types


Step 0 — Woh ek cheez jo computer bilkul nahi kar sakta

Upar kuch bhi baad mein assume nahi kiya gaya hai. Is page ka har symbol in paanch words se trace hota hai.


Step 1 — Players, ek map pe laid out

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Picture dekho: tumhara laptop (violet) ekdum left mein baitha hai. Recursive resolver (magenta) woh akela hai jisse tumhara laptop baat karta hai. Teen tiers (orange) right mein stack hain — root sabse upar, phir TLD .com, phir example.com ka authoritative server. Abhi ek bhi arrow draw nahi kiya gaya; hum bas board ke pieces naam kar rahe hain.


Step 2 — Pehla arrow: recursive ask

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Ek magenta arrow laptop se resolver ki taraf fly karta hai, recursive label ke saath. Dhyaan do resolver pe ek chhota notepad drawn hai — woh cache hai, abhi ke liye empty. Hum isse Step 7 mein fill karenge.

Message mein ek field hai jo matter karta hai:

  • QNAME — woh naam jiske baare mein pooch rahe hain, hamare quest ka star.
  • QTYPE = A — hum specifically IPv4 mapping chahte hain (woh A record). Agar IPv6 chahiye hota toh AAAA likhte.

Step 3 — Resolver root pe knock karta hai

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Orange arrow upar jaana sawaal hai; violet arrow neeche reply hai. Root naam ko right-to-left padhta hai, dekhta hai rightmost meaningful part com hai, aur ek NS referral ke saath jawab deta hai:

  • com. — zone jo delegate ho raha hai (poori .com branch).
  • NS — record type jiska matlab hai "is zone ka authoritative name server yeh hai…". NS records woh glue hain jo tree ke ek tier ko next se link karte hain.
  • a.gtld-servers.net — TLD server ka naam jo aage visit karna hai.

Root ko example.com ka IP nahi pata tha — aur yeh sahi hai. Root sirf next level down jaanta hai.


Step 4 — Resolver .com TLD pe knock karta hai

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

www.example.com ko ek level aur gehri padh ke, TLD com ke neeche example dekhta hai aur ek aur NS referral return karta hai:

  • example.com. — ab delegated zone ek step zyada specific hai.
  • ns1.example.comauthoritative name server, woh machine jo actually answer store karti hai.

Hum tree mein exactly ek level per hop neeche aaye hain: .comexample.com. Woh descent hi motion mein DNS ki poori structure hai.


Step 5 — Authoritative server: final word

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Violet reply arrow ab ek actual A record carry karta hai:

  • A — record type jiska matlab hai naam → IPv4 address. Yeh basic forward lookup hai, woh cheez jo hum Step 0 se chase kar rahe the.
  • 93.184.216.34 — value: woh number jis par packets route hote hain.
  • TTL = 300 — yeh answer 300 seconds tak yaad rakha ja sakta hai. Yeh number Step 7 ke liye yaad rakho.

Quest answer ho gayi. Lekin do aur steps isse scale karte hain.


Step 6 — Edge case: naam ek CNAME hai, A nahi

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Picture mein fork dikhta hai: ftp maanga, server CNAME return karta hai (magenta), aur ek loop-back arrow resolver ko www ke liye phir se poochhne bhejta hai, jo finally A record deta hai (orange).


Step 7 — Doosra lookup almost free kyun hota hai (caching)

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Bar chart tall uncached bar () ko tiny cached average () se contrast karta hai. Resolver pe notepad, Step 2 mein jo empty tha, ab mapping hold karta hai ek ticking TTL countdown ke saath.


Ek-picture summary

Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Ek diagram, poori journey: ek recursive arrow (laptop → resolver, magenta), phir teen iterative hops tree ke neeche (resolver → root → TLD → authoritative, orange), answer wapas aata hai, aur resolver ka cache sabhi future asks ko short-circuit karta hai (dashed violet). Yahi sabse pehli cheez hai jo kisi bhi web page load hone se pehle hoti hai; MX records ke zariye mail servers dhundhhne ke liye bhi yahi tree walk hoti hai aur CDN and Load Balancing mein nearby edge tak pahunchne ke liye bhi.

Recall Feynman retelling — poori walk kisi 12-saal ke bacche ko explain karo

Tumhare dost ka phone number chahiye lekin sirf naam pata hai. Tum school office se ek baar poochhhte ho aur kehte ho "bas le aao, main wait karunga" — yeh recursive ask hai; tum khud kabhi nahi bhagte. Office ko nahi pata, toh office city directory se poochhhti hai: "kaun sa neighbourhood?" → woh point karta hai. Phir office us neighbourhood manager se poochhhti hai: "kaun sa ghar?" → woh point karta hai. Phir office ghar ke front desk se poochhhti hai, jo finally number bolta hai — woh authoritative answer hai, real cheez. Agar naam ek nickname nikla (ek CNAME), toh office real naam ke liye phir se start karti hai. Har "kaun sa…?" answer sirf ek pointer tha, kabhi number nahi — isliye bade directories kabhi thakte nahi. Finally office number ek sticky note (cache) pe likhti hai ek expiry time (TTL) ke saath, toh agle bacche ko jo poochhta hai woh ek second mein milta hai. Tumne sabse kam kaam kiya; office ne daudha; bade servers ne sirf point kiya. Yahi DNS hai.

Recall Self-test (answers dhak ke karo)
  • Ek lookup ke liye tumhare laptop se kitne arrows nikkte hain? → Ek (recursive).
  • Kya root www.example.com ka IP jaanta hai? → Nahi, sirf .com TLD ki location.
  • IPv4 kaunsa record type deta hai? → A.
  • Beech mein poori walk kya restart karta hai? → CNAME milna.
  • ke saath, ke multiple mein average cost? → .