DNS
How human-friendly domain names get translated into the IP addresses computers use
Computers route traffic using numeric IP addresses, but humans remember names. DNS (the Domain Name System) is the web's phone book — it translates example.com into 93.184.216.34. Every page load starts with a DNS lookup.
The Phone Book of the Internet
When you visit example.com, your browser first needs its IP address. DNS provides that lookup:
example.com ──DNS──▶ 93.184.216.34
(what humans type) (what routers need)
Without DNS, you'd have to memorize IP addresses for every site. DNS also adds flexibility: a site can change servers (new IP) without changing its domain name.
How a Lookup Works
DNS is a hierarchy of servers, each responsible for part of the name. A full resolution walks down that tree:
1. Recursive resolver your ISP/router's DNS — does the legwork
2. Root servers "for .com, ask the .com TLD servers"
3. TLD servers (.com) "for example.com, ask its authoritative server"
4. Authoritative server "example.com is 93.184.216.34" ← the real answer
The recursive resolver does this walking on your behalf and hands back the final IP. You ask once; it may make several queries behind the scenes.
Domains get more specific right to left. In api.example.com:
com is the top-level domain, example is the
registered domain, and api is a subdomain. DNS resolves them in
that outermost-first order.
Common Record Types
A domain's DNS settings are a set of records, each mapping a name to something:
| Record | Maps to | Example use |
|---|---|---|
A | An IPv4 address | example.com → 93.184.216.34 |
AAAA | An IPv6 address | example.com → 2606:2800:220:1:… |
CNAME | Another domain name | www.example.com → example.com |
MX | A mail server | Where to deliver @example.com email |
TXT | Arbitrary text | Domain verification, SPF records |
CNAME is an alias: www.example.com ──▶ example.com ──▶ (A record) ──▶ IP
Caching and TTL
DNS lookups are cached at every level — your browser, OS, resolver — so the full walk doesn't happen every time. Each record carries a TTL (time to live) saying how long it may be cached:
TTL 3600 → cache this answer for 1 hour before asking again
This is why DNS changes aren't instant: after you update a record, caches around the world keep serving the old value until their TTL expires — "DNS propagation."
Planning to move servers? Drop the record's TTL (e.g. to 300s) a day ahead. Then when you switch the IP, the world picks it up in minutes instead of hours.