Skip to Content
Navigation:

A stick figure smiling

Here's a preview from my zine, How DNS Works! If you want to see more comics like this, sign up for my saturday comics newsletter or browse more comics!

Image of a comic. To read the full HTML alt text, click "read the transcript".

browse more comics! get the zine!
read the transcript!

there are 2 ways to set up DNS for a website

  1. set an A record with an IP
    www.cats.com A 1.2.3.4

  2. set a CNAME record with a domain name
    www.cats.com CNAME cats.github.io

CNAME records redirect every DNS record, not just the IP

I like to use them whenever possible so that if my web host’s IP changes, I don’t need to change anything!

what actually happens during a CNAME redirect

Illustration of a conversation between a resolver, represented by a box with a smiley face holding a magnifying glass, and an authoritative nameserver, represented by a box with a smiley face wearing a crown.

resolver: what’s the A record for www.cats.com?
authoritative nameserver: www.cats.com CNAME cats.github.io
resolver (thinking): okay, I’ll look up the A record for cats.github.io!

rules for when you can use CNAME records

  1. you can only set CNAME records on subdomains (like www.example.com), not root domains (like example.com)
  2. if you have a CNAME record for a subdomain, that subdomain can’t have any other records

(technically you can ignore these rules, but it can cause problems, the RFCs say you shouldn’t, and many DNS providers enforce these rules)

some DNS providers have workarounds to support CNAME for root domains

Look up “CNAME flattening” or “ANAME” to learn more.

Saturday Morning Comics!

Want another comic like this in your email every Saturday? Sign up here!

I'll send you one of my favourite comics from my archives every Saturday.
© Julia Evans 2024 | All rights reserved (see the FAQ for notes about licensing)