Names and street numbers
You remember shops by name. But a letter can only be delivered to a street number. So when you want to visit www.shop.com, you ring the operator and ask for its number.
The operator doesn't have every number in the world. They know who to ask: head office knows which desk
handles names ending in .com, that desk knows where the shop's own book is, and the shop's book has the
real answer. The operator brings it back to you.
Resolving a name
Computers connect to IP addresses (93.184.216.34, or IPv6 like 2606:2800::1), not names. The Domain
Name System maps one to the other, and it is split by the dots in a name, read from the right:
- Your device asks a recursive resolver (from your ISP, or a public one like
1.1.1.1or8.8.8.8). - The resolver asks a root server, which refers it to the servers for the top-level domain (
.com). - The TLD server refers it to the authoritative nameservers for
shop.com. - The authoritative server returns the actual record.
Each step is a small UDP message on port 53. The resolver does the legwork, so your device asks one question and gets one answer.
Writing it down
Ringing around takes time, so the operator writes every answer down with a "good for one hour" note. Anyone else asking for the same shop gets the answer straight away. Your own phone keeps a little list too.
The catch: if the shop moves, people with old notes keep going to the old address until their hour is up.
Caching and TTLs
Every record carries a TTL (time to live) in seconds. Resolvers, operating systems and browsers all cache answers until the TTL runs out, which is why most lookups take a millisecond rather than tens of milliseconds.
It's also why DNS changes "propagate" slowly: nobody is told about a change, caches simply expire. Before moving a site, lower the TTL (say to 60 seconds) a day ahead, make the change, then raise it again.
Different lines in the book
The shop's book has more than one kind of line: the street number, a nickname that says "look under this other name instead", where its post should go, and a notes column.
Record types
| Type | Holds | Example |
|---|---|---|
| A / AAAA | IPv4 / IPv6 address | shop.com โ 93.184.216.34 |
| CNAME | An alias to another name | www.shop.com โ shop.cdn.net |
| MX | Mail servers, with priorities | shop.com โ 10 mail.shop.com |
| TXT | Free text: verification, SPF, DKIM, DMARC | v=spf1 include:mail.net -all |
| NS | Authoritative nameservers for a zone | shop.com โ ns1.host.net |
CDNs often use CNAMEs, and their nameservers answer with an address near the person asking, which is how one name can lead people in different countries to different servers.
Security: classic DNS is unencrypted and unauthenticated, so anyone on the network path can see or forge answers. DNSSEC signs records so resolvers can check they're genuine; DNS over HTTPS (DoH) and DNS over TLS (DoT) encrypt the questions between your device and the resolver.
Debugging: dig www.shop.com shows the answer and its TTL; dig +trace www.shop.com walks the chain from
the root, step by step.