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- A browser asks for
www.example.com. - DNS answers: it is an alias of
example.com. - The resolver looks up
example.comand gets203.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.comitself 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
| A | CNAME | ALIAS / ANAME / flattening | |
|---|---|---|---|
| Points to | IPv4 address | Another hostname | Another hostname |
| Allowed at root | Yes | No | Yes |
| Follows target IP changes | No | Yes | Yes (provider resolves it) |
| Standard | Yes | Yes | Provider-specific feature |
Common uses
www→ root domain.shop→ a hosted store platform's hostname.cdnorstatic→ a CDN endpoint.- Domain verification and DKIM keys published by email providers as CNAMEs (for example
s1._domainkey).
Add a CNAME in cPanel
- Go to cPanel → Domains → Zone Editor and click Manage.
- Click Add Record, choose CNAME.
- 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 +shortThe 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.
