4.3.23Computer Networks

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

1,961 words9 min readdifficulty · medium3 backlinks

WHY does DNS exist?


The Hierarchy (WHAT the tree looks like)

The servers, top to bottom:

  1. Root servers (.) — 13 logical root server names (a–m), massively replicated via anycast. They know where the TLD servers are.
  2. TLD servers (.com, .org, .in, .edu…) — know where each domain's authoritative name servers are.
  3. Authoritative name servers — the final word; they actually store the records (A, MX…) for that domain.
  4. Resolver / recursive resolver — your ISP's (or 8.8.8.8) server that does the legwork for you and caches answers.
Figure — DNS — recursive vs iterative query, hierarchy, record types (A, AAAA, CNAME, MX, NS)

Recursive vs Iterative Query (the heart)

HOW a lookup actually flows (www.example.com)

  1. Stub resolver → recursive resolver: recursive "what is www.example.com?"
  2. Resolver → root: iterative. Root replies "ask .com TLD at a.gtld-servers.net."
  3. Resolver → TLD .com: iterative. TLD replies "ask ns1.example.com (the authoritative NS)."
  4. Resolver → authoritative: iterative. It replies "A record = 93.184.216.34."
  5. Resolver caches the answer (for the record's TTL) and returns it to your laptop.

Record Types (WHAT is stored)

Type Maps Value Why it exists
A name → IPv4 93.184.216.34 the basic forward lookup
AAAA name → IPv6 2606:2800:220:1:248:1893:25c8:1946 same, but 128-bit IPv6 ("quad-A" = 4×A)
CNAME name → another name (alias) target.example.com. one canonical host, many aliases; change IP in one place
MX domain → mail server (+priority) 10 mail.example.com. tells senders where email goes; lowest priority number = preferred
NS zone → authoritative name server ns1.example.com. the delegation glue: how the tree links levels

Common Mistakes (Steel-manned)


Active Recall

Recall Quick self-test (cover the answers)
  • Which query type does your laptop send? → Recursive.
  • Which step does root delegate to? → TLD server.
  • AAAA maps to what? → IPv6.
  • Why is iterative used between resolver and root? → keeps big servers cheap (no work on others' behalf).
  • What lets DNS scale despite billions of names? → caching + hierarchy/delegation.
Recall Feynman: explain to a 12-year-old

Imagine you want a friend's phone number but you only know their name. You ask the school office (recursive resolver): "find me their number, I'll wait." The office doesn't have it, so it asks the city directory: "which neighborhood?" → "this one." Then asks that neighborhood's manager: "which building?" → "that one." Then the building's front desk gives the actual number. The office writes the number on a sticky note (cache) so next time it answers instantly. The office did all the running around; you only asked once.


Flashcards

What is the difference between a recursive and iterative DNS query?
Recursive: the asked server returns the final answer, doing all the work itself. Iterative: the server returns a referral (next server to ask) and the asker keeps hopping.
In a normal web lookup, which query type does the stub resolver send to the recursive resolver?
Recursive.
Which queries are iterative in DNS resolution?
Resolver→root, resolver→TLD, resolver→authoritative.
What does a root server actually know?
Only the locations of TLD servers (not individual domain IPs).
What does an A record map?
A hostname to an IPv4 address.
What does an AAAA record map?
A hostname to an IPv6 address (128-bit).
What is a CNAME record?
An alias mapping one name to another canonical name.
What does an NS record do?
Delegates a zone to its authoritative name server(s).
In an MX record, which priority value is preferred?
The lowest number is tried first (highest preference).
Why can't a CNAME exist at the zone apex?
CNAME cannot coexist with other records, but the apex already has SOA/NS records.
Why is caching critical to DNS?
It avoids repeating the full multi-hop resolution, cutting average lookup cost to ~(1-hitrate)·H·t.
What is an FQDN?
Fully Qualified Domain Name — the complete name including the trailing root dot, e.g. www.example.com.
Why is iterative resolution used by root/TLD servers?
So they only point to the next server and never do work on others' behalf, keeping them scalable.

Connections

  • IP Addressing — IPv4 vs IPv6 (A vs AAAA targets)
  • Caching and TTL (why DNS scales)
  • HTTP and the Web request lifecycle (DNS precedes the TCP connection)
  • Anycast Routing (how 13 root names serve the world)
  • SMTP and Email Delivery (MX records in action)
  • CDN and Load Balancing (CNAME/ALIAS tricks)

Concept Map

too big to scale

organized as

top

referral to

referral to

stores

recursive query

iterative queries

caches

returned to

HOSTS.TXT single file

DNS distributed database

Hierarchical namespace tree

Root servers .

TLD servers com org

Authoritative name servers

Records A AAAA CNAME MX NS

Stub resolver laptop

Recursive resolver

Final IP address

Hinglish (regional understanding)

Intuition Hinglish mein samjho

DNS ko samajh lo internet ka phonebook. Tum naam yaad rakhte ho (google.com) lekin computer ko number (IP address) chahiye hota hai. DNS yeh translation karta hai. Ek hi badi file mein sab kuch store karna impossible hai, isliye namespace ko ek tree mein tod diya gaya hai — Root, fir TLD (.com, .in), fir authoritative server jo actual records rakhta hai. Har level sirf agle level ka pata jaanta hai, poora system koi ek machine nahi jaanti — yahi delegation hai.

Ab recursive vs iterative ka funda. Tumhara laptop ek recursive query bhejta hai apne resolver ko: "bhai final answer la ke do, mujhe steps se matlab nahi." Resolver phir iterative queries karta hai — root se poochta hai, root bolta hai "TLD se poocho", TLD bolta hai "authoritative se poocho", aur finally IP mil jaata hai. Bade servers (root/TLD) sirf point karte hain, kaam nahi karte — isliye woh scale kar paate hain. Resolver answer ko cache kar leta hai (TTL tak), taaki agli baar turant de de.

Record types yaad rakho: A = IPv4 address, AAAA = IPv6 (4 'A' = 128 bit), CNAME = alias (ek naam doosre naam ko point karta hai), MX = mail server (lowest number wala pehle try hota hai — yeh ulta lagta hai par yahi rule hai), NS = delegation, kaunsa authoritative server zone ko handle karta hai.

Do common galtiyan: (1) "iterative matlab client loop karta hai" — galat, resolver loop karta hai. (2) "MX ka lower number kam important" — galat, lower number sabse pehle preferred hota hai. In dono ko exam mein zaroor pakdo.

Go deeper — visual, from zero

Test yourself — Computer Networks

Connections