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!
read the transcript!
there are 2 ways to set up DNS for a website
set an A record with an IP
www.cats.com A 1.2.3.4
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
- you can only set CNAME records on subdomains (like
www.example.com
), not root domains (likeexample.com
) - 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!