Domain Names and DNS
Routers deliver to IP addresses, but nobody wants to print 203.0.113.10 on a bakery's paper bags. People remember crumbbakery.com. Something has to translate the friendly name into the number every time someone visits, and do it in a few milliseconds. That something is the Domain Name System.
The rule
DNS turns a name people remember into an address computers can route.
Reading a domain name. Read it from right to left, from the most general part to the most specific:
comis the top-level domain (TLD). Others includeorg,dev,inanduk.crumbbakeryis the name the bakery registered undercom. Together,crumbbakery.comis its domain.wwworshopin front is a subdomain, a sub-name the owner creates freely, such asshop.crumbbakery.com.
You do not buy a domain forever. You rent it, usually by the year, from a registrar, which records you as the holder.
DNS records. The domain's owner publishes records that say where things live:
| Record | Answers | Example value |
|---|---|---|
A |
the IPv4 address | 203.0.113.10 |
AAAA |
the IPv6 address | 2001:db8::10 |
CNAME |
"this name is an alias of that name" | shop → crumb.shops.example.net |
MX |
which server receives email | mail.crumbbakery.com |
The lookup. When the browser needs the address, it first checks caches (its own, then the operating system's). On a miss, it asks a recursive resolver, usually run by the internet provider or a public service. The resolver does the legwork:
- It asks a root server: "who handles
.com?" - It asks the
.comTLD server: "who handlescrumbbakery.com?" - It asks that domain's authoritative server: "what is the
Arecord forcrumbbakery.com?"
Every answer carries a TTL (time to live), the number of seconds it may be cached. Caching makes repeat lookups instant, and it is also why a changed record can take a while to reach everyone.