Networking & DNS

DNS CNAME record explained: aliases, rules and common mistakes

What a CNAME record is, how alias resolution works, why the root domain can't be a CNAME, CNAME vs A vs ALIAS, using CNAMEs for CDNs and SaaS, and common errors.

BeginnerDNS3 min read

A CNAME (canonical name) record makes one domain name an alias of another. When a resolver looks up the alias, DNS tells it to look up the target name instead and use its records. CNAMEs are perfect for pointing subdomains at services whose IP addresses may change. This guide explains the DNS CNAME record and its rules.

Before you start

You need access to the DNS zone for your domain, for example cPanel → Domains → Zone Editor.

How a CNAME works

www.example.com.   3600  IN  CNAME  example.com.
example.com.       3600  IN  A      203.0.113.50
  1. A browser asks for www.example.com.
  2. DNS answers: it is an alias of example.com.
  3. The resolver looks up example.com and gets 203.0.113.50.

If the A record of example.com changes, www follows automatically.

The rules of CNAME records

  • No other records with the same name. A name with a CNAME cannot also have A, MX, TXT or any other record.
  • Not at the zone root. example.com itself needs SOA and NS records, so it cannot be a CNAME.
  • Target must be a hostname, never an IP address.
  • Don't point MX or NS records at a CNAME – they must point to names with A/AAAA records.
  • Avoid long chains of CNAME to CNAME; each hop adds lookup time.

CNAME vs A vs ALIAS

ACNAMEALIAS / ANAME / flattening
Points toIPv4 addressAnother hostnameAnother hostname
Allowed at rootYesNoYes
Follows target IP changesNoYesYes (provider resolves it)
StandardYesYesProvider-specific feature

Common uses

  • www → root domain.
  • shop → a hosted store platform's hostname.
  • cdn or static → a CDN endpoint.
  • Domain verification and DKIM keys published by email providers as CNAMEs (for example s1._domainkey).

Add a CNAME in cPanel

  1. Go to cPanel → Domains → Zone Editor and click Manage.
  2. Click Add Record, choose CNAME.
  3. Enter the name (for example shop.example.com.) and the target hostname, then save.

If a record with that name already exists (an A record, for example), delete it first.

Check a CNAME

dig shop.example.com CNAME +short
dig shop.example.com +short

The second command follows the alias and shows the final IP.

Troubleshooting

  • "CNAME and other data" error: another record with the same name exists – remove it.
  • Email stops working after adding a CNAME: you put a CNAME on a name that also needs MX records.
  • SSL warning on the alias: the target server must have a certificate covering your alias name.
  • Trailing dot issues: in zone files, a target without a trailing dot gets the zone name appended.

FAQ: DNS CNAME records

Can I use a CNAME for my root domain?

Not with standard DNS. Use an A record, or a DNS provider that supports ALIAS records or CNAME flattening.

Does a CNAME redirect visitors?

No. It only changes DNS resolution; the browser's address bar keeps the original name. Use an HTTP redirect to change the URL.

Is a CNAME slower than an A record?

Slightly, because of the extra lookup, but resolvers cache both records so the difference is usually negligible.

Next steps

Was this guide helpful?

Still stuck?

Ask MdmHost AI for a quick answer, or open a ticket and our team will take a look. We are here 24/7.