We're sorry but this app doesn't work properly without JavaScript enabled. Please enable it to continue.

This lesson's interactive features are locked, please to keep using them

CNAME Records

What if you want blog.boot.dev to point to the same server as www.boot.dev? You could create another A record pointing to the same IP address, but there's a better way: CNAME records.

Click to play video

A CNAME record (Canonical Name) maps one domain name to another domain name. It's kind of like a DNS-level redirect (or more accurately, an alias).

When someone looks up cats.boot.dev, the CNAME says: "Check cat-server.boot.dev instead." That domain's A record then provides the IP address.

Sometimes it'll be a pretty simple path:

cats.boot.dev → cat-server.boot.dev → 1.2.3.4
CNAME           A                     IP

Sometimes it can be a bit more complex:

cats.boot.dev → cats.east.boot.dev  → cat.east.boot.dev → 1.2.3.4
CNAME           CNAME               → cat.east.boot.dev → 1.2.3.5
                                    → cat.east.boot.dev → 1.2.3.6
                                    → cat.east.boot.dev → 1.2.3.7
                                    → cat.east.boot.dev → 1.2.3.8
                                      A records           IP

A CNAME record has two main parts:

  • Name: The subdomain you want to alias (e.g., links)
  • Value: Another (sometimes entirely different) domain name (e.g., www.shortlinks.com)

Important Rules

  • CNAME records can only point to other domain names, not directly to IP addresses.
  • CNAMEs can't overlap. You can't have two rules for the same subdomain (e.g., an A record and a CNAME record for blog.boot.dev).
  • If the target domain has multiple A records, the CNAME will point to all of them.

Technically you can't have a CNAME for the root domain (boot.dev), but many DNS providers, including Route 53, let you do essentially the same thing through special handling (ANAME or Aliases). If you're curious, you can read more here.

Assignment

PatientPing wants blog.patientping.internal to point at the same place as www.patientping.internal so they don't have to maintain two A records. Add a CNAME that aliases blog to www.

Create a CNAME record: blog.patientping.internalwww.patientping.internal.

  1. ssh patientping
    
  2. dig blog.patientping.internal
    
  3. www.patientping.internal.  15  IN  A  10.0.10.50
    

Run and submit the CLI tests from your own machine.

Tip

If you'd prefer to use the CLI:

aws route53 change-resource-record-sets --hosted-zone-id <zone-id> --change-batch '{"Changes":[{"Action":"CREATE","ResourceRecordSet":{"Name":"<record-name>","Type":"CNAME","TTL":300,"ResourceRecords":[{"Value":"<target-domain>"}]}}]}'