GuidesChapter 6 · Hosting & Domains

Hosting & Domains

CNAME for Domain Names: How Aliases Work

A CNAME for a domain points an alias to its real address. See how DNS lookups work, which rules apply, and how to set one up with your registrar.

A woman smiles at a directional arrow on a post outside a cream townhouse, preparing to enter.

In short

A CNAME record is a DNS entry that makes one hostname an alias for another hostname, rather than pointing directly to an IP address. Resolvers follow the alias to find the final address, and unlike a web redirect, a CNAME does not change the name shown in the browser; it also cannot share its name with most other DNS records or be used at the domain root. Use one for provider-managed hostnames when you want aliases to follow target changes, and check the exact target and DNS settings before saving.

Imagine a nickname that always leads back to your real home address. Friends can use it, the mail still arrives, and when you move, you only update one thing. A CNAME record works the same way for a domain name.

A CNAME record (short for canonical name) is an entry in the DNS, or Domain Name System, which acts as the internet’s address book. It says one name is simply an alias for another.

In this post, we’ll cover how that lookup works, the rules that limit where CNAMEs can go, and how to set one up with your registrar.

What a CNAME for Domain Names Does

A CNAME (short for canonical name) is a small record in the Domain Name System (DNS), the internet’s address book, and it’s easy to misread.

How a CNAME acts as a nickname

A CNAME is an alias. It points one name, like shop.yourdomain.com, to another name, the canonical (official) one. The value is a hostname, not an Internet Protocol (IP) address: it points a name at another name, not at a number.

A resolver, the lookup tool in your visitor’s device, follows the alias and hands the rest to the target.

Think of it as a nickname for an address. If your phone saves your sister’s house as “Lisa’s place,” that label doesn’t hold the street address; it points to the one that does.

Why a CNAME is not a web redirect

Many people mix it up with a redirect, but a CNAME works at lookup time, not page time.

  • Timing. It’s resolved during the DNS lookup, before the browser requests a page.
  • Address bar. It stays put. Visitors still see the name they typed.
  • Layer. A redirect is a web server instruction at the HyperText Transfer Protocol (HTTP) level, and the address bar changes when it runs.

The fields and format of a CNAME

Every CNAME has four fields:

  • Name: the alias, such as shop.yourdomain.com.
  • Type: CNAME, marking the record type.
  • Value: the hostname it points to.
  • TTL: time to live, the cache lifetime in seconds (3600 is one hour).

In a zone file (the plain-text list of DNS records), it looks like this: shop.yourdomain.com. 3600 CNAME hosting.example.net.

The trailing dot marks a fully qualified domain name (FQDN), a complete name that DNS won’t add your domain to. Check whether your DNS panel expects it.

Why people rely on CNAMEs

Three reasons stand out:

  • Decoupling the domain from IP. Your domain never needs to know the server’s address.
  • Target changes propagate automatically. Change the target once, and every alias follows once caches expire.
  • Avoiding edits to many records. Many aliases can share one target, so you update one record.

Take Maria, a cake seller with four subdomains (order, gifts, catering, blog), all pointing to one hosting hostname. When her host moves the store to new servers, it updates one hostname and all four aliases follow. Maria doesn’t touch a thing.

How a CNAME Lookup Actually Works

Here’s the path a name takes from the moment you type it to the server that answers, and where a CNAME fits in.

Tracing the lookup from alias to IP

When someone types your address, a resolver (the DNS server doing the lookup for their device) asks for the record. If it finds a CNAME (canonical name record), it’s an alias, so the resolver follows it to the target and asks again.

A CNAME is a pointer rather than an address. The target’s A record (IPv4 address) or AAAA record (IPv6 address) supplies the final IP address.

The server may also return the whole chain in one reply.

See a CNAME lookup in action

Take a freelance consultant, Dana, setting up email on her domain. Her provider asks for a CNAME named selector1._domainkey.dana.example pointing to the provider’s host.

When a receiving server checks her DKIM (DomainKeys Identified Mail) signature, it follows that alias to the public key.

Her storefront uses a CNAME too. Running dig (a command-line lookup tool) on it returns:

;; ANSWER SECTION:
shop.dana.example.    3600  IN  CNAME  shops.host.example.
shops.host.example.   300   IN  A      192.0.2.10

Read it top to bottom: alias, then final address.

How caching keeps CNAME lookups fast

A CNAME adds one extra lookup hop, but caching (a resolver saving answers for reuse) keeps that overhead small. The answer is reused rather than looked up again for later visitors.

Each record’s TTL (time to live, in seconds) sets how long a saved answer stays valid. In the sample, the alias lasts an hour and the address five minutes. Change a record, and the old answer lingers until its TTL runs out. Plan for that wait.

A hand writes on a card beside a wooden box of time-tracking notes and a sand timer.

Comparing CNAME with a, ALIAS and ANAME

DNS (Domain Name System, the internet’s address book) uses record types, such as A, CNAME (short for canonical name), ALIAS and ANAME. The A record holds an Internet Protocol (IP) address, and the CNAME record holds another hostname.

Picking A or CNAME for your setup

An A record suits a known IP address that won’t change, since it stores that address directly, and a stable, simple setup needs only that. A CNAME suits a hostname your provider manages, since the provider can swap servers freely.

At the apex (your bare domain, like example.com), you’ll usually need an A record, since a CNAME isn’t allowed there. Strict rule, simple fix.

Think of a bakery owner whose website builder gives her a hostname. A CNAME points her domain there, so it keeps working when the builder moves servers.

Quick record-choice checklist:

  • fixed IP, use an A;
  • provider hostname, use a CNAME;
  • bare domain, use an A or a workaround below.

Workarounds for the root domain

The apex can’t hold a CNAME, so providers offer workarounds:

  • ALIAS and ANAME records: act like a CNAME at the root, with the provider doing the lookup.
  • CNAME flattening: the provider follows the CNAME chain and serves the final IP addresses at the root.
  • Provider answers with A/AAAA: the provider returns A and AAAA address records (AAAA is the newer, longer address format), so your root looks like a normal record.
  • Non-standard, provider-specific: none are part of the official DNS standard, so each depends on its provider.

Side-by-side differences at a glance

Feature A CNAME ALIAS / ANAME
Stores IP address Another hostname Name, resolved by provider
Allowed at root Yes No Yes, if provider supports it
Other records on same name Allowed Not allowed Depends on provider
Standards status Standard Standard Non-standard, provider-specific

An A stores an address, and a CNAME points to a name. Match the record to what your host gave you.

Rules That Limit How CNAMEs Are Used

Every CNAME follows a few firm rules that catch first-timers off guard, so we’ll walk through each one.

Why a name can’t share other records

A CNAME (canonical name record) makes one name an alias for another. Once a name is an alias, it can’t hold other records beside it: no A record (an IP address), no MX (mail exchange) record, and no TXT (text) record.

The name borrows its answer instead of keeping its own, and the DNS (Domain Name System) specification itself rules this out.

The one exception is DNSSEC (DNS Security Extensions, a signing add-on), whose records can sit alongside a CNAME.

If you need both on one name, move the alias to its own subdomain (the part before your main domain). Picture a local bakery pointing shop.example.com at its ordering site while the main name keeps its mail records, so customer emails keep arriving.

Why the root domain rejects a CNAME

The bare domain, like example.com, is the apex, and it can’t hold a CNAME. It must keep its SOA (start of authority) and NS (name server) records, the ones that run your domain, and an alias would clash with both.

A CNAME there would also break your MX record and your SPF (Sender Policy Framework) record. Use the apex alias feature many DNS hosts offer instead.

Mail servers and nameservers can’t be aliases

The same rule covers mail servers and nameservers. RFC (Request for Comments) 2181 says the name used as the value of an NS record, or part of an MX record’s value, “must not be an alias.”

RFC 5321, the standard for sending email, sets the same expectation. So point your MX at a host with its own A record, not at an alias.

A postal carrier stands by a mailbox with a crossed-out sign, looking toward house number 12 down the street.

Why alias chains and loops break things

A CNAME can point at another CNAME, forming a chain. Chains work, but every extra hop slows things down, so keep it to one hop.

Loops are worse: if name A points to B and B points back to A, nothing ever resolves. Broken links are just as bad: delete or misspell the final name and every alias upstream fails too. One break takes the whole chain down.

Where CNAMEs Get Used Most Often

A CNAME makes one name an alias for another, so it fits any name that leads to someone else’s service. Here are three common cases.

Pointing subdomains at CDNs and cloud hosts

Say a bakery’s shop.yourbakery.com runs on a CDN (content delivery network), keeping copies close to visitors. Its CNAME points to the provider’s hostname.

Cloud hosts keep one hostname steady even when the numeric Internet Protocol (IP) addresses behind it change. Your CNAME points at a name, not a number, so nothing on your side needs updating.

Keeping www and extra domains in sync

Visitors still type www out of habit. A CNAME pointing www at the main domain (the apex) means www follows whatever that domain serves.

A freelance photographer who also owns her name as a .net and a .org can point each one’s www name at her main domain, since a CNAME can’t sit on the bare domain (the name with nothing in front). Each one’s www name lands on her portfolio.

Change the main domain’s A record (the record that points a name at an IP address) and every www name follows along. You edit one record instead of many.

Many platforms won’t connect a domain until you prove you control it. They’ll give you a name and value to add as a CNAME. Once it’s live, they confirm you own it. That’s domain ownership verification.

A newsletter tool may route links through its own servers to count clicks. A CNAME lets those branded click-tracking links use a name like links.yourbakery.com, so readers see your brand.

The target (the value on the record’s right side) comes from the platform. Copy it exactly. One wrong character is easy to miss.

Setting up, Fixing and Checking CNAMEs

Creating the record is quick. Getting it right and checking it takes a bit more care.

How do you create a CNAME record?

Edit DNS (the system that maps names to addresses) wherever your domain’s nameservers point, or nothing changes. Then:

  1. Add a record in your DNS panel and choose CNAME, which points one name at another.
  2. Enter just the subdomain in the Name (or Host) field, such as gallery, not the full address.
  3. Paste the target address into the Value field.
  4. Save, then check your provider’s dashboard that it shows as active.

A wedding photographer adds gallery this way, so her clients see her own name in the address bar. In Namecheap, click Manage on your domain, open Advanced DNS, and add a CNAME record with the subdomain in Host and the target in Value.

Avoid these common CNAME mistakes

  • Doubled domain. Typing gallery.yourdomain.com into the Name field creates gallery.yourdomain.com.yourdomain.com, which won’t work.
  • Cloudflare proxy left on. Cloudflare’s proxy (the orange cloud) can hide your target, so switch that record to DNS only.
  • Stray spaces or dots. An extra space or dot can break the record, so paste carefully.
  • Old TXT key conflict. A CNAME can’t share a name with another record, so remove any old TXT (text) record on that host.
  • Dangling CNAME risk. Cancel a service but keep its CNAME, and the subdomain points at an address anyone can claim. That’s subdomain takeover. Delete the record when you cancel.

Confirming records with lookup tools

Lookup commands show what the internet actually sees:

  • dig gallery.yourdomain.com CNAME on Mac or Linux
  • nslookup -type=CNAME gallery.yourdomain.com on Windows

Browser-based DNS checkers work too. Check the full record set for that name, since a CNAME can’t sit alongside mail (MX) or text (TXT) records. For email authentication, once the lookup returns your target, test it with your provider’s verification.

Why changes take time to show up

Your change is saved right away, but it’s seen gradually.

  • TTL (time to live): how long other servers remember an answer, so old targets linger until it expires.
  • Negative caching: servers also remember a ‘no record found’ answer, so an old empty result can stick around.
  • Provider recheck schedule: your provider checks on its own timetable, so verification can pass later.

Give it time, but if nothing changes after a reasonable wait, recheck your Name and Value fields. Waiting won’t fix a typo.

A magnifying glass highlights a detail on a fresh white card resting on a desk near an hourglass and fading mail slots.

Using CNAMEs for Email Sending and Delivery

Most mail goes out through a service, not your own server. A few CNAME records (DNS entries, the internet’s address book, that point one name at another) connect it to yours.

Letting your mail provider host DKIM keys

Your provider signs each message with a DKIM (DomainKeys Identified Mail) key. Instead of copying that key, point a CNAME at the copy your provider hosts. A wedding photographer who does this never touches DNS when her provider rotates keys.

The CNAME’s name includes a selector, a label telling receivers which key to check. Names differ by provider, so copy yours exactly; expect two or three. The CNAME is a pointer, not the key itself.

A bounce domain is a subdomain that handles returned mail. Its CNAME points to your provider, which lines up the SPF check (Sender Policy Framework, a DNS list of approved senders) with the address people see.

A branded tracking domain puts your name on links, so a bakery’s pickup alerts show the bakery, not the provider. Some providers use a shared tracking host, so your links carry the reputation of everyone on it, not just yours.

SendGrid, Mailchimp, Amazon SES (Simple Email Service), Microsoft 365 and Klaviyo each list their own records on a setup screen, so copy them exactly.

A florist on Klaviyo copies them before her Mother’s Day campaign, so it goes out with checks already passing.

Some services also host MTA-STS (a policy requiring encrypted delivery to your domain) and DMARC (a policy telling receivers how to handle failing mail). Point a CNAME at the mta-sts or _dmarc name, and the host serves the file or record.

How a misplaced CNAME breaks email

A name holding a CNAME generally can’t hold other records. Misplace one and you’ll usually see:

  • Hidden SPF or DKIM records: the CNAME hides the DNS record checkers need.
  • DMARC misalignment: the domain passing SPF or DKIM no longer matches the sender people see, so DMARC fails.
  • Spam placement or rejection: receivers may send failing mail to spam or refuse it.
  • A CNAME alone doesn’t authenticate mail: the record it points to does the checking.

Check every record before you send.

Common Questions People Ask About CNAMEs

Once you start editing records, the same few questions keep coming up. Here are the ones that matter most.

What a CNAME means for search rankings

Adding a canonical name (CNAME) record won’t hurt your search rankings. It’s a Domain Name System (DNS) setting that makes one name an alias for another, and there’s no negative SEO (search engine optimization) effect from using one.

Search engines see the final content, the page visitors actually land on. Think of a wedding photographer who points gallery.her-studio.com at her gallery host: her clients get a link with her name on it, and her rankings still depend on her pages.

The pointer itself doesn’t count against you.

Can a CNAME point to a different domain?

Yes. A CNAME can point to a name on a completely different domain. Take a bakery that runs online orders through a booking service: it can point order.sweetcrumb.com at that service, so customers never leave the bakery’s name.

The target has to be a name, not a raw Internet Protocol (IP) address, the numbered address of a server, so a CNAME can’t point straight to a number. It can point to another CNAME too, but each hop adds a lookup.

A single pointer is rarely noticeable, but long chains add delay, so keep them short.

A redirect moves visitors to a new address, and the address bar changes to show it. A CNAME keeps the name they typed and quietly pulls the content from the target.

Use a redirect when people should land somewhere new, and a CNAME when the same site should answer to another name. Copy the exact target your service gives you, because a one-letter typo is enough to break the link.

A CNAME is a small record with a big job: it lets one name follow another, so you’re not keeping two copies of the same answer. Keep the limits in mind, too.

The bare root of your domain can’t take a CNAME, and one name can’t hold a CNAME alongside other records.

Before you edit anything, confirm which DNS panel controls your domain, then give changes time to spread and test from a second device. Set the alias right once, and the name quietly does the rest.

References

  1. DNAME Redirection in the DNS — doi.org (2012)

Questions

What is CNAME in DNS?

A CNAME, or canonical name record, is a DNS record that makes one hostname an alias for another hostname. DNS resolvers follow the alias to find the target’s address. A CNAME points to a name, not directly to an IP address.

What are the DNS record types?

Common DNS record types include A and AAAA for IP addresses, CNAME for aliases, MX for mail servers, TXT for text and verification data, NS for nameservers, and SOA for zone information. Other types include PTR, SRV, CAA, and DNSSEC records such as DS and DNSKEY.

How to create a CNAME in Namecheap?

In Namecheap, open your domain’s **Manage** page, select **Advanced DNS**, and add a **CNAME Record**. Enter the subdomain in **Host** and the destination hostname in **Value**, then save; make sure the name does not already have another record, since a CNAME cannot share its name with other records.

Can a CNAME record point to a different domain?

Yes. A CNAME can point to a hostname on a different domain, but it cannot point directly to an IP address. The target must be a hostname, and long chains of CNAMEs can add lookup delays.

Sources

  1. DNAME Redirection in the DNS, doi.org,
Share