4.3.23 · D1 · Coding › Computer Networks › DNS — recursive vs iterative query, hierarchy, record types
Humans cheezein words se name karte hain (google.com), lekin computers ek doosre ko numbers se dhundhte hain (IP addresses). DNS woh bada, shared, tree-shaped lookup service hai jo ek name ko number mein badalta hai — aur yeh kaam kai servers mein split karke karta hai taaki koi ek machine kabhi bhi sab kuch na jaane.
Isse pehle ki tum recursive vs iterative queries , record types , ya hierarchy follow kar sako, tumhe har woh word aur symbol khud se samajhna hoga jo parent note quietly assume karta hai. Yeh page har ek cheez ko zero se build karta hai, ek aisi order mein jahan har piece apne pehle wale piece pe tikki hoti hai.
Definition Hostname (ek "name")
Hostname woh human-readable label hai jo internet pe kisi machine ke liye hota hai, jaise www.example.com. Yeh sirf text hai — letters, digits, aur dots. Yeh sirf human memory ke liye exist karta hai; network hardware isse directly kuch nahi karta.
Definition IP address (ek "number")
IP address woh numeric location hai jo ek machine actually data bhejna mein use karti hai. Isse packets ki street address samajho jahan deliver hoti hain. Do flavours hain:
IPv4 — chaar numbers 0–255, jaise 93.184.216.34.
IPv6 — ek bahut lamba 128-bit form, jaise 2606:2800:220:1:248:1893:25c8:1946.
Picture yeh hai: ek phonebook imagine karo. Name hai "Annie Sharma"; number hai "555-0142". Tum naam yaad rakhte ho; phone system number dial karta hai.
Yeh topic ko kyun chahiye: DNS ka poora reason yahi name→number gap hai. Agar humans 128-bit numbers yaad rakh paate, toh DNS ka koi matlab nahi hota. (Do number formats ke baare mein zyada IP Addressing — IPv4 vs IPv6 mein.)
Definition Label aur separating dot
Ek hostname dots se labels mein kata jaata hai. www.example.com mein labels hain www, example, aur com. Sabse right wala label sabse "senior" (broadest) part hota hai; sabse left wala sabse specific machine hoti hai.
Intuition Right-to-left kyun?
Right-to-left padhna aisa hai jaise postal address country → city → street → house se padhna. com "country" hai, example "city" hai, www "house" hai. Yahi ordering hai jo ek tree ko possible banati hai — har dot ek branch neeche ki taraf hai.
Definition FQDN (Fully Qualified Domain Name)
Ek name jo poori tarah upar tak, invisible top tak likha ho woh Fully Qualified Domain Name hai, trailing dot se mark hota hai: www.example.com.. Woh final dot root hai — har earth ke naam ka silent common ancestor.
Yeh topic ko kyun chahiye: poori hierarchy (root → TLD → domain → host) literally ek name ko right-to-left, ek dot at a time padhna hai.
Definition Tree (poore system ki shape)
Tree ek aisi picture hai jahan ek top point (root ) branches mein split hota hai, har branch phir split hoti hai, aur aisa chalta rehta hai — kabhi loop back nahi karta. Har split point ek node hai.
Delegation ka matlab hai: "Main khud answer store nahi karta; main us ka address store karta hoon jo karta hai." Tree ka har level sirf next level neeche ka pointer rakhta hai. Root .com, .org, .in… ke pointers rakhta hai; .com example.com ke owner ke pointers rakhta hai; aur aisa chalta rehta hai.
Intuition Tree kyun, delegation kyun?
Ek giant file jo har name→number pair list kare woh update karna ya share karna impossible hota (yahi reason hai ki purana HOSTS.TXT khatam hua). Tree har owner ko sirf apna branch control karne deta hai. Koi machine sab kuch nahi jaanti — har ek sirf jaanti hai ki next kisse poochna hai. Yeh ek sentence DNS ki beating heart hai.
Definition Client aur server
Client woh side hai jo sawaal poochti hai. Server woh side hai jo jawaab deti hai (ya kahin aur point karti hai). Tumhara laptop client hai; DNS machines servers hain.
Stub resolver woh tiny, "dumb" DNS client hai jo tumhare laptop ya phone mein built-in hai. Yeh almost kuch nahi jaanta: bas ek sawaal poochta hai ("is naam ka IP kya hai?") aur ek jawaab ka intezaar karta hai.
Definition Recursive resolver
Recursive resolver ek powerful helper server hai (tumhare ISP ka, ya 8.8.8.8) jo tumhari taraf se saari running around karta hai aur past answers yaad rakhta hai. Yahan "Recursive" ka matlab hai "yeh answer dhundhne ki poori zimmedari leta hai."
Picture yeh hai: stub resolver woh student hai jo school office se ek sawaal poochta hai. Recursive resolver woh office clerk hai jo saare phone calls karta hai aur final number de deta hai.
Yeh topic ko kyun chahiye: recursive aur iterative queries mein farq poori tarah kaun running around karta hai — clerk (recursive resolver) ya poochne wala (stub) — iske baare mein hai. In dono roles ko samajh lo aur woh poora section obvious ho jaata hai.
Referral ek non-final reply hai jo kehta hai "Mere paas nahi hai, lekin unse poochho" — yeh ek server ka address deta hai jo answer ke ek step aur paas hai.
Definition Authoritative answer
Authoritative answer woh final, true reply hai, jo us server se milti hai jo actually record ko own aur store karta hai. Raaste mein har doosra server sirf point kar raha tha.
Intuition Recursive vs iterative ek image mein
Recursive query: "Mujhe finished answer do; main wait karoonga." (stub → recursive resolver)
Iterative query: "Bas apna best referral do; main khud hopping karta rahoonga." (recursive resolver → root → TLD → authoritative)
Bade servers (root, TLD) sirf iteratively kyun answer karte hain iska reason cost hai: woh tumhe ek pointer de dete hain aur tumhare baare mein bhool jaate hain, tumhara kaam khud karne ke bajaye. Agar woh poori duniya ke liye recursion karte, toh woh melt ho jaate.
Definition Resource Record (RR)
Record ek stored fact hai (name, type, value, TTL) form mein. Example: (www.example.com, A, 93.184.216.34, 3600). Type kehta hai kiska fact hai (ek IPv4 address? ek mail server? ek alias?).
Definition TTL (Time To Live)
TTL seconds ki ek number hai jo kehti hai ek cached copy of a record kitni der fresh rehti hai dobaara look up kiye jaane se pehle. 3600 ka TTL matlab hai "ek ghante tak isse trust karo."
Cache recent answers ki short-term memory hai. Jab resolver ek baar IP seekh leta hai, woh ise ek mental sticky-note pe likhta hai (TTL tak valid) taaki agli identical question pe poora tree walk skip ho jaye aur instantly answer mile.
Definition Priority number
Priority number kuch records (khaaskar mail servers) ke saath attached ek rank hota hai. Rule counterintuitive hai: sabse chhota number pehle try hota hai . Isse "distance" ya "rank #1" padho, na ki "importance." 10 mail1 beats 20 mail2.
Yeh topic ko kyun chahiye: MX records mein yeh numbers hote hain, aur classic mistake yeh sochna hai ki bada number zyada important server hai. Yeh ulta hai.
Root TLD Authoritative hierarchy
Client server resolver roles
Recursive vs Iterative query
Query referral authoritative answer
A AAAA CNAME MX NS records
Right side cover karo aur khud test karo. Agar koi line shaky hai, uska section upar se dobara padho.
Hostname hota hai machine ka human-readable naam, jaise www.example.com — sirf text, human memory ke liye.
IP address hota hai woh numeric location jahan packets actually deliver hoti hain (IPv4 93.184.216.34, ya lamba 128-bit IPv6).
Hum domain name padhte hain right-to-left, sabse-senior (broadest) label pehle — jaise country → city → street.
FQDN hota hai ek naam poori tarah root tak likha, trailing dot se mark kiya: www.example.com..
Delegation ka matlab hai har level sirf next level ka pointer store karta hai, kabhi poora answer nahi.
Stub resolver hai tumhare laptop ka dumb DNS client jo ek sawaal poochta hai aur wait karta hai.
Recursive resolver hai woh helper server jo saari running around karta hai aur answers cache karta hai.
Recursive query maangti hai final finished answer ("Main wait karoonga").
Iterative query return karta hai ek referral — next server ka address jo poochha jaaye.
Authoritative answer hai woh final true reply jo us server se aati hai jo actually record store karta hai.
Ek record ki form hoti hai (name, type, value, TTL).
TTL ka matlab hai kitne seconds ek cached record fresh rehta hai dobara look-up se pehle.
Cache hai recent answers ki short-term memory, TTL tak valid, jo tree walk skip karti hai.
MX priority mein preferred server ka hota hai sabse chhota number (pehle try hota hai).
Main topic par wapas: parent note . Related foundations: IP Addressing — IPv4 vs IPv6 · Caching and TTL · HTTP and the Web request lifecycle .