COMPUTER NETWORKS / 4. DNS — THE INTERNET'S PHONE BOOK
DNS — Domain Name System
How google.com becomes 142.250.80.46 in milliseconds
EXPLANATION
DNS is the distributed database that maps human-readable domain names to machine-readable IP addresses. Without DNS, you'd need to memorize IP addresses for every website. DNS is hierarchical and distributed — no single server knows everything. The hierarchy: • Root nameservers (13 sets, labeled a-m.root-servers.net) — know where all TLD servers are • TLD nameservers (.com, .org, .in, .io) — know where all second-level domain servers are • Authoritative nameservers — know the actual DNS records for a specific domain • Recursive resolver (your ISP or 8.8.8.8) — does the legwork of querying the hierarchy on your behalf DNS Resolution walk-through for "google.com": ① Your browser checks its DNS cache → not found ② OS checks /etc/hosts file → not found ③ OS asks your recursive resolver (8.8.8.8) ④ Resolver checks its cache → not found ⑤ Resolver asks a Root nameserver: "Where's .com?" ⑥ Root says: "Ask ns1.verisign.net (the .com TLD server)" ⑦ Resolver asks .com TLD: "Where's google.com?" ⑧ TLD says: "Ask ns1.google.com (Google's authoritative server)" ⑨ Resolver asks Google's NS: "What's the IP for google.com?" ⑩ Google's NS responds: "142.250.80.46, TTL=300" ⑪ Resolver caches this, returns to your browser ⑫ Browser connects to 142.250.80.46 All this happens in ~50–100ms on first query. Cached queries: <1ms. DNS Record Types: • A → hostname to IPv4 address • AAAA → hostname to IPv6 address • CNAME → alias (one name points to another name) • MX → mail exchange servers (for email delivery) • TXT → arbitrary text (used for SPF, DKIM, domain verification) • NS → nameserver records (which servers are authoritative) • SOA → Start of Authority (metadata about the zone) • PTR → reverse DNS (IP to hostname) TTL (Time To Live): every DNS record has a TTL in seconds. Resolvers and browsers cache records until TTL expires. Changing DNS doesn't take effect instantly — you must wait for old TTL to expire across all caches globally. This is "DNS propagation."
DIAGRAM
DNS RESOLUTION HIERARCHY:
Root (.)
│
┌──────┴──────┐
.com .org .in ...
│
google.com ← Authoritative Nameserver
│
www.google.com → 142.250.80.46 (A record)
RESOLUTION FLOW:
Browser → OS → Recursive Resolver
│
① Root NS: "Ask .com"
│
② .com NS: "Ask google.com NS"
│
③ google NS: "IP = 142.250.80.46"
│
Browser ← OS ← Resolver (caches result for TTL seconds)
RECORD TYPES:
google.com A 142.250.80.46
google.com AAAA 2607:f8b0:4004::200e
www.google.com CNAME google.com
google.com MX 10 smtp.google.com
google.com TXT "v=spf1 include:_spf.google.com ~all"CODE