A friend once asked me: "How does your site know it should show up when I type its address?" I started answering, then realised I was mixing up three different things. This post is the answer I wish I had given, and the ground floor of this whole series.
In the next parts I explain how I moved my apps from Vercel to Cloudflare and to my own server. None of it makes sense until you know what happens between typing an address and seeing the page.
The IP address: a machine's phone number
Every machine on the Internet has an IP address. It is its number, the only thing computers really understand. It comes in two formats:
- IPv4, four numbers separated by dots:
203.0.113.10; - IPv6, much longer, created because we ran out of IPv4 addresses:
2001:db8::1.
Nobody remembers those. That is why we invented names.
The domain name: the name in the phone book
You don't buy a domain name: you rent it, yearly, from a registrar. Mine is rented from Hostinger. And you read it from right to left:
This is the detail that changed everything for me: a subdomain costs nothing. Once terravidhal.me is mine, I can create certifstudio., cvmalin., logoforge.… as many as I like. I plan about forty projects: they won't cost me forty domain names.
DNS: the Internet's phone book
DNS (Domain Name System) is the phone book that turns a name into an IP address. When you type an address, your browser has no idea where to go. It asks a resolver (your ISP's, or a public one like 1.1.1.1), which travels the world on your behalf:
- "Who runs
.menames?" The Internet's root servers answer. - "Who runs
terravidhal.me?" The.meservers answer: Cloudflare. - "What is the IP of
certifstudio?" Cloudflare answers with an address. - The browser connects to that address over HTTPS, and the page arrives.
All of that takes a few dozen milliseconds. The resolver then keeps the answer in memory for a while, the TTL (time to live). That is why a DNS change isn't visible everywhere instantly: some resolvers still remember the old answer.
Nothing actually "propagates". Resolvers around the world keep the old answer until its TTL runs out, then ask again. Lowering the TTL a few hours before a change makes the switch almost instant.
The lines of the phone book
A domain's phone book is called a zone. Each line has a type, and a handful of types cover almost everything:
- A and AAAA link a name to an IPv4 or IPv6 address;
- CNAME makes a name an alias of another name (handy when the host changes its addresses for you);
- MX says where incoming e-mail goes;
- TXT proves you own the domain and publishes anti-spam rules (SPF, DKIM, DMARC);
- NS says who keeps the phone book. It's the most important line, more on it right now.
The three roles everyone mixes up
This is what I was mixing up with my friend. Behind "my site" there are three jobs, often done by three different companies:
- the registrar: who I pay to rent the name;
- the DNS host: who keeps the phone book;
- the web host: which machine actually sends the page.
The registrar tells the world: "for this domain, ask that phone book". That's the NS line (nameservers). Changing nameservers means changing phone books without changing owners.
When I wanted to move to Cloudflare, I thought I had to "transfer my domain". Wrong: I only changed the phone book. The domain is still rented from the same place, and going back is a single change.
What's next
With these three roles in mind, everything else reads easily. In part 2 I explain why I left Vercel for most of my projects, and how Cloudflare became my phone book, my shield and the host of my static sites, without the domain moving an inch.
