Computers find each other by IP address. People remember names. The Domain Name System
(DNS) bridges the two: it turns a name like shop.example.com into an address like
203.0.113.7, on demand, for billions of names run by millions of different owners.
The lookup
No single server knows every name. DNS is a tree, and a resolver (usually run by your internet provider, or a public one like 1.1.1.1 or 8.8.8.8) walks it for you:
- Your browser asks the resolver: "Where is
shop.example.com?" - The resolver asks a root server: "Who handles
.com?" The root points to the.comservers. - It asks the
.comservers: "Who handlesexample.com?" They point to that domain's authoritative server. - It asks the authoritative server, which gives the actual address.
- The resolver hands the address to your browser, which connects to it.
Caching makes it fast
Walking the tree every time would be slow, so every answer comes with a TTL (time to live), say 300 seconds. Your browser, your operating system and the resolver all cache the answer until the TTL runs out. Most lookups are answered from a cache in a millisecond or two.
The catch: if you change where a name points, people with a cached answer keep going to the old address until their TTL expires. Before a planned move, teams lower the TTL ahead of time (at least one old TTL before the move), so the switch takes effect in minutes instead of hours.
Record types worth knowing
| Record | Maps a name to... |
|---|---|
| A | an IPv4 address |
| AAAA | an IPv6 address |
| CNAME | another name (an alias), e.g. www.example.com → example.com |
| MX | the mail servers for a domain |
| NS | the authoritative name servers for a domain |
DNS can also do simple load spreading: return several addresses, or different answers depending on where the user is (that's how many CDNs send you to a nearby server).
Key idea: a resolver walks root → top-level domain → authoritative server to find an address, and everyone caches the answer for its TTL. Short TTLs mean faster changes; long TTLs mean fewer lookups.