INHow the Internet Works · Lesson 3 of 7

DNS — The Internet's Phone Book

Computers route by number; humans remember names. DNS translates example.com into 93.184.216.34 — a distributed database queried billions of times per second, and the first step of every page load.

Text
The lookup chain for api.shop.example.com:

 1. Browser cache — seen this name recently?
 2. OS cache — anyone on this machine seen it?
 3. Resolver (your ISP's, or 1.1.1.1 / 8.8.8.8) — cached?
 4. Root servers:      "for .com, ask these servers"
 5. .com TLD servers:  "for example.com, ask these"
 6. example.com's nameservers: "api.shop = 93.184.216.34"

Answer flows back, cached at every step (per its TTL).
Cold lookup: ~50-200ms. Cached: ~0ms. This is why DNS
caching exists and why 'propagation' takes time.
Bash
dig example.com             # full lookup, all details
dig example.com +short      # just the answer
# 93.184.216.34

# Record types — DNS stores more than addresses:
dig example.com A           # name -> IPv4
dig example.com AAAA        # name -> IPv6
dig example.com MX          # who receives this domain's email
dig example.com TXT         # freeform (domain verification, SPF)
dig www.example.com CNAME   # alias -> another name
dig example.com NS          # which servers answer for this domain

# Watch the full chain yourself:
dig example.com +trace

The TTL (time-to-live) on each record says how long caches may keep it. Long TTLs (hours) mean fast lookups but slow changes; that's why DNS changes 'propagate' gradually — caches worldwide expire on their own schedules. Ops teams drop TTL to 60 seconds before a migration, move, then raise it again.

✦ Tip
DNS is also a load balancer and a failover switch: return different IPs per query (round-robin), or per requester location (CDNs steering you to a nearby server). When a site is 'down for some people but not others', stale or split DNS is suspect number one. The dev-facing rule: it's always DNS.