All articles
Infra3 min read

What really happens when you type an address

IP addresses, domain names, DNS, free subdomains and the three roles everyone mixes up. The ground floor of my self-hosting series.

by Vidhal Elame
#DNS#Domains#Cloudflare

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:

certifstudiosubdomain — free, unlimited.terravidhalmy domain — rented yearly.meextension

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:

Browsercertifstudio.…DNS resolveryour ISP, 1.1.1.1…Root servers“who runs .me?”.me servers“who runs terravidhal.me?”Cloudflare DNS“the IP of certifstudio?”The site's serverHTTPS, the page12345 · connect to the IP, get the page
Typing an address: the resolver asks three servers in turn, then the browser connects to the IP it got back. The answer is kept in memory for a while (the TTL).
  1. "Who runs .me names?" The Internet's root servers answer.
  2. "Who runs terravidhal.me?" The .me servers answer: Cloudflare.
  3. "What is the IP of certifstudio?" Cloudflare answers with an address.
  4. 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.

→Why people tell you to “wait for propagation”

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:

example.com.NSns1.cloudflare.com.; who keeps the phone book
appA203.0.113.10; name → IPv4 address
staticAAAA2001:db8::1; name → IPv6 address
wwwCNAMEhost.example.net.; name → another name
example.com.MXmx1.mail.example.; where e-mail goes
example.com.TXT"v=spf1 include:…"; anti-spam rules
A DNS zone excerpt (example values).
  • 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:

Registrarwho I rent the name fromDNS hostwho keeps the phone bookWeb hostwhich machine sends the pageHostingerCloudflareCloudflare · VPS · VercelNSA / CNAME
Three different jobs. Moving the phone book to Cloudflare did not move the domain: it is still rented from the same registrar.
  • 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.

✓What I took away

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.