Guides

What Is a CNAME Record? How DNS Aliases Work in Plain English

A CNAME record is a DNS alias: one name that points to another name instead of an IP address. Here is how it resolves, where it helps, and the rules that catch people out.

Cysoro Security TeamPublished · 9 min read
www example.com 192.0.2.1 GUIDES CNAMErecords One name, pointing at another.
Quick answer

A CNAME record, short for canonical name, is a DNS record that maps one domain name (the alias) to another domain name (the canonical name). Instead of pointing at an IP address, it tells a resolver to look up the target name instead. It is how www.example.com can follow example.com, and how a subdomain can hand traffic to a hosted service, without duplicating IP addresses.

Key takeaways

  • A CNAME points a name at another name, never at an IP address — the target's A or AAAA record supplies the address.
  • A name with a CNAME cannot have any other DNS records, and a CNAME cannot sit at the root (apex) of a domain.
  • CNAMEs are ideal for subdomains and hosted services, because changing the target's IP updates every alias at once.

You point www.example.com at your site, blog.example.com at your blog host, and shop.example.com at your store provider — all without typing a single IP address three times. That is what a CNAME record does: it turns one domain name into an alias for another.

What is a CNAME record?

A CNAME record, short for canonical name, is a DNS record that maps one domain name to another domain name. The name on the left is the alias; the name on the right is the canonical, or true, name.

When a resolver looks up an alias, it does not get an IP address back. It gets the target name, then looks that name up to find the A or AAAA record that holds the address. Cloudflare describes it as a chain of clues: each clue points to another clue, and the final clue points to the treasure, which is the IP address.

For example, if blog.example.com has a CNAME pointing to example.com, and example.com has an A record for 192.0.2.1, then a lookup for the blog ends at 192.0.2.1. The web server still sees the original hostname, so it can serve the blog page rather than the home page.

The record is defined in RFC 1034, the original DNS specification from 1987, and clarified in RFC 2181. It is one of the oldest and most widely used DNS record types, and almost every hosted service you use — email, a website builder, a CDN — asks you to create one at some point.

How does a CNAME record work?

A CNAME lookup works in two steps: the resolver finds the alias, follows it to the canonical name, and then resolves that name to an IP address. Most DNS servers return the whole chain in one response, so your browser rarely makes a second trip.

How a CNAME lookup resolves 1. You ask forblog.example.com 2. DNS answersCNAME: example.com 3. Then resolvesA: 192.0.2.1 Your browser connects to 192.0.2.1 — but still asks for blog.example.comThe server reads the hostname and serves the blog, not the home page.
A CNAME lookup follows the alias to the canonical name, then to its IP address. Illustration by Cysoro.

Here is the chain in a zone file, using the documentation addresses from RFC 5737:

NameTypeValue
example.comA192.0.2.1
www.example.comCNAMEexample.com
blog.example.comCNAMEexample.com
shop.example.comCNAMEstores.provider.com

If the host behind example.com moves to a new IP address, you update one A record. Every CNAME that points at it follows automatically. That single-update benefit is the main reason CNAMEs exist.

One warning: a CNAME that points to another CNAME adds a hop. Cloudflare notes that chaining is possible but inefficient, because each extra lookup slows the page load. Point aliases directly at the final name where you can.

CNAME vs A record: what is the difference?

An A record maps a name directly to an IPv4 address, while a CNAME maps a name to another name. The A record is the destination; the CNAME is a signpost pointing at it.

CNAME recordA recordAAAA record
Points toAnother domain nameAn IPv4 addressAn IPv6 address
Example valueexample.com192.0.2.12001:db8::1
Needs a second lookupYesNoNo
Can sit at the apexNoYesYes
Best forAliases and hosted servicesThe main host addressThe main host, IPv6

Use an A record when you control the server and know its IP address. Use a CNAME when another provider controls the destination, or when several names should always follow one host. A common pattern is one A record at the apex and CNAMEs for www, blog and other subdomains.

There is also the ALIAS record, offered by some DNS providers. It behaves like a CNAME at the apex but resolves to an IP address at query time, so it can sit where a CNAME cannot. It is a provider feature, not a standard DNS record type, so check your provider's documentation before relying on it.

What are CNAME records used for?

CNAME records are used whenever one name should follow another: the www subdomain, a blog or store hosted elsewhere, email authentication, and services that move between servers. If a provider gives you a hostname to point at, it is usually a CNAME.

  • The www subdomain. Point www.example.com at example.com so both addresses reach the same site and stay in sync.
  • Hosted services. A store, help center or landing-page tool asks you to point a subdomain at its hostname, such as shops.provider.com. When the provider moves servers, your record still works.
  • Content delivery networks. A CDN gives you a hostname to CNAME to, so traffic flows through its edge servers without you managing IPs.
  • Email authentication. DKIM and some DMARC setups ask for CNAME records that point at your email provider's keys. Our guide to what DKIM is explains how those records prove a message is genuine.
  • Verification. Google, Microsoft and other services ask you to add a CNAME to prove you own a domain before they enable a service.

They are also useful inside a company network, where an alias such as intranet.example.com can point at the real server name, so staff remember one friendly name even if the server is renamed later.

What are the rules and limits of CNAME records?

CNAME records have strict rules: a name with a CNAME cannot hold any other record, a CNAME cannot sit at the apex, and MX and NS records cannot point at a CNAME. Breaking these rules is the most common cause of mysterious DNS failures.

Three rules you cannot break 1. No siblingsA name with a CNAMEcannot also have A, MX,TXT or any other record. 2. No apex CNAMEThe root of a domainmust hold SOA and NSrecords, so no CNAME there. 3. No MX or NS targetMX and NS records mustpoint to a host with anA or AAAA record. The one exception is DNSSEC signing records, which the zone needs to sign the data.
The three hard limits on CNAME records, per RFC 1034 and RFC 2181. Illustration by Cysoro.

No other records on the same name. RFC 1034 states that if a CNAME is present at a node, no other data should be present there. That is why you cannot add a TXT record for verification on a subdomain that already has a CNAME — put the TXT record on the canonical name instead, or use a different subdomain.

No CNAME at the apex. The apex of example.com must hold SOA and NS records, which conflicts with the no-siblings rule. Some providers solve this with CNAME flattening: their resolvers follow the CNAME and serve the resulting IP as if it were an A record. All proxied CNAME records at Cloudflare behave this way.

MX and NS cannot point to a CNAME. As Cloudflare notes, mail exchange and name server records must point to a host with an A or AAAA record. Pointing an MX record at an alias can cause mail to bounce or be delayed, and many mail servers will reject it.

Can you put a CNAME at the root of a domain?

No, a standard CNAME cannot sit at the root, or apex, of a domain, because the apex must already hold SOA and NS records. A CNAME there would break the rule that a CNAME name holds no other records.

This trips up many people who want example.com itself, without www, to point at a hosted service. The provider gives them a hostname, and the DNS panel refuses the record or the domain stops resolving properly.

Your options are to use an A or AAAA record pointing at the provider's IP address, if the provider publishes a stable one, or to use your DNS provider's ALIAS or CNAME flattening feature. With flattening, you enter the hostname as usual and the provider resolves it to an address behind the scenes. Check whether your provider supports it before you switch DNS hosts for this reason alone.

How do you create a CNAME record?

You create a CNAME in your DNS provider's dashboard, not in your website or email settings. Log in to the place that holds your domain's name servers, open the DNS zone, and add a record with the alias as the name and the target hostname as the value.

  1. Find your DNS host. This is usually your domain registrar or your DNS provider. If you are unsure, check the NS records with a DNS lookup.
  2. Add a record. Choose type CNAME, enter the subdomain as the host (often just www or blog, not the full domain), and enter the target hostname.
  3. Use the full target name. Enter the target exactly as your provider gave it, usually ending with a dot in zone-file syntax, or as a plain hostname in a web panel.
  4. Set the TTL. A TTL of 3600 seconds (one hour) is a sensible default. Use a shorter TTL, such as 300 seconds, before a planned move.
  5. Save and wait. Most providers publish within minutes, but cached copies can take up to the old TTL to expire.
  6. Verify. Look the name up again and confirm the answer shows your target and the target's A record.

Double-check the spelling of the target: a single wrong letter sends visitors to a name that does not exist, and the error message will be a DNS failure rather than a helpful warning. Also confirm you have not created a second record with the same name, which most providers will reject.

How do you check a CNAME record?

You check a CNAME by querying it directly: the answer should show the target hostname, and a follow-up lookup of the target should return an IP address. If either step fails, the chain is broken.

In a terminal, run dig CNAME www.example.com or nslookup -type=CNAME www.example.com. The answer section shows the target. Then run dig A on that target to confirm it resolves. On Windows, nslookup is built in; on macOS and Linux, dig is the usual tool.

If you prefer a browser, paste the name into our free DNS lookup tool and read the CNAME and A answers. Check from more than one location if a change seems slow to appear, because different resolvers cache values for different lengths of time.

Watch for dangling CNAMEsIf you cancel a hosted service but leave its CNAME in place, the alias points at a name nobody controls. Attackers can register that name and take over your subdomain. Delete CNAMEs you no longer use.

What are the common CNAME mistakes to avoid?

The most common CNAME mistakes are pointing at an IP address, creating a loop, leaving a dangling record, and putting a CNAME where mail records belong. Each one is easy to make and easy to check for.

  • Pointing a CNAME at an IP address. A CNAME value must be a name. If you paste an IP address, the record is invalid and lookups fail.
  • CNAME loops. If a.example.com points to b.example.com and b points back to a, resolvers give up. Keep chains short and one-directional.
  • Dangling CNAMEs. A CNAME pointing at a deleted service is a subdomain takeover risk. Audit your zone at least once a year and remove dead aliases.
  • CNAMEs on mail names. Do not put a CNAME on a name that needs MX or TXT records, such as the apex or a mail subdomain. Use the canonical name for mail instead.
  • Chained CNAMEs for speed. Each hop adds a lookup. Point aliases directly at the final canonical name, and keep your TTLs sensible so changes propagate quickly.
  • Forgetting the trailing dot. In a raw zone file, a target without a trailing dot is treated as relative to your domain. Web panels usually handle this for you, but zone files do not.

A regular DNS audit also helps your email security: a stray record can break SPF or DKIM, so check your mail setup with our DMARC checker after any DNS change.

The bottom line

A CNAME record is a simple idea with strict rules: one name becomes an alias for another, and the target's address does the real work. Used well, it keeps your DNS tidy and lets hosted services move without you chasing IP addresses.

Remember the three rules — no other records on the same name, no CNAME at the apex, and no MX or NS pointing at an alias — and delete aliases you no longer use. You can verify any name in seconds with the free DNS lookup tool.

Frequently asked questions

What is a CNAME record in simple terms?

A CNAME record is a nickname for a domain name. It says this name is really just another name for that one, so a resolver follows the alias to the real name and then looks up that name's IP address.

Can a CNAME record point to an IP address?

No. A CNAME must point to another domain name. If you need to point a name directly at an IPv4 address, use an A record; for an IPv6 address, use an AAAA record.

What is the difference between a CNAME and an A record?

An A record maps a name to an IPv4 address. A CNAME maps a name to another name, which then resolves through its own A or AAAA record. Use an A record for the final destination and a CNAME when you want an alias that follows the target.

Can I put a CNAME record at the root of my domain?

No, not a standard CNAME. The root, or apex, of a domain must hold SOA and NS records, and a name with a CNAME cannot hold any other records. Some DNS providers offer a CNAME flattening or ALIAS record that behaves like an A record at the apex.

Can a CNAME point to another CNAME?

Yes, it is technically allowed, but it is inefficient because each hop adds another DNS lookup and slows loading. Point each alias directly at the final canonical name instead.

How long does a CNAME record take to work?

A new or changed CNAME usually starts working within minutes at your authoritative DNS provider, but resolvers and browsers may cache the old value until its TTL expires. Lower the TTL before a planned change if you need a fast switch.

Do CNAME records affect email?

A CNAME itself does not handle mail, and MX records cannot point to a CNAME target. Mail for a domain is delivered using MX records, which must point to a host with an A or AAAA record, so keep mail records on the canonical name.

How do I check a CNAME record?

Use a DNS lookup tool or run dig CNAME followed by the name in a terminal. The answer shows the target name the alias points to. You can also use an online DNS lookup to see the full chain, including the A record at the end.

Sources

  1. RFC Editor — RFC 1034: Domain Names, Concepts and Facilities
  2. Cloudflare — What is a DNS CNAME record?
  3. Google Workspace Help — About CNAME records
  4. Who.is — CNAME Records: How DNS Aliases Work (and Their Limits)
Written & fact-checked byCysoro Security Team

The engineers and analysts who build Cysoro's domain scanner, email-authentication checks and free security tools. We test what we write about every day — SPF, DKIM, DMARC, certificates, look-alike domains and phishing — and check each guide against the relevant standards, government guidance and vendor documentation.

  • Email authentication
  • Phishing & BEC
  • Domain & DNS security
  • Small-business security

Checked against RFC 1034, Cloudflare's CNAME documentation and Google Workspace DNS guidance.

How we write and fact-check →

Free tools for this topic

No account needed.

See where your domain stands

Free for up to 3 domains. No card, no installs.

Start free