CNAME Record (Canonical Name)

DNS Record Types
A DNS record that creates an alias pointing one domain name to another, commonly used for subdomains and CDN configuration.
← Back to Glossary

What is a CNAME Record?

A CNAME (Canonical Name) record is a DNS record type that creates an alias from one domain name to another. Instead of pointing directly to an IP address like an A record, a CNAME points to another domain name, which is then resolved to an IP address.

How CNAME Records Work

When you set up a CNAME:

www.example.com.    IN    CNAME    example.com.

The resolution process:

1. User requests www.example.com

2. DNS finds CNAME pointing to example.com

3. DNS then resolves example.com's A record

4. Final IP address is returned

This chain resolution means CNAME targets must eventually resolve to an A or AAAA record.

Common CNAME Use Cases

WWW Subdomain

Point www to your root domain:

www    IN    CNAME    example.com.

CDN Integration

Point your domain to a CDN endpoint:

cdn.example.com    IN    CNAME    d111111abcdef8.cloudfront.net.

Platform Hosting

Point to hosting providers:

blog.example.com    IN    CNAME    yoursite.wordpress.com.

shop.example.com IN CNAME shops.myshopify.com.

SaaS Applications

Connect subdomains to SaaS platforms:

docs.example.com    IN    CNAME    example.gitbook.io.

status.example.com IN CNAME stats.uptimerobot.com.

CNAME vs A Record

ScenarioUse CNAMEUse A Record
Root domain (@)❌ Not allowed✅ Required
Subdomain to static IPEither works✅ Direct
Subdomain to provider✅ Preferred❌ IP may change
CDN configuration✅ TypicalVaries
Load balancing❌ Can't have multiple✅ Multiple IPs

Why Root Domains Can't Use CNAME

The DNS specification (RFC 1034) prohibits CNAME records from coexisting with other record types at the same name. Since root domains need SOA and NS records, they cannot have CNAME records.

Solutions for root domain aliasing:

CNAME Chains

CNAMEs can point to other CNAMEs (chaining):

blog.example.com    → myblog.host.com

myblog.host.com → lb-1234.hosting.com

lb-1234.hosting.com → 203.0.113.50 (A record)

While valid, chains add latency. Most DNS providers limit chain length to prevent infinite loops.

CNAME Record Configuration

Basic Syntax

subdomain    IN    CNAME    target.domain.com.
Important: The target domain should include a trailing dot (.) to indicate it's fully qualified. Without it, some DNS servers append the origin domain.

TTL Considerations

CNAME TTLs affect how quickly changes propagate:

www    300    IN    CNAME    example.com.

Lower TTLs (300 seconds) allow faster updates; higher TTLs reduce DNS queries.

Checking CNAME Records

Using dig:
dig www.example.com CNAME

; ANSWER SECTION:

www.example.com. 300 IN CNAME example.com.

Full resolution trace:
dig +trace www.example.com

Common CNAME Issues

CNAME at Root Domain

example.com    IN    CNAME    other.com.    ; INVALID

This breaks email (MX records) and other services.

CNAME with Other Records

blog.example.com    IN    CNAME    host.com.

blog.example.com IN MX mail.host.com. ; INVALID

A name with a CNAME cannot have other record types.

Missing Target Records

If the CNAME target doesn't resolve, your subdomain won't work either. Verify targets are valid before configuring CNAMEs.

Best Practices

1. Use CNAMEs for third-party services: Let providers manage IP changes

2. Avoid deep chains: Each hop adds latency

3. Don't CNAME the root: Use A records or ALIAS

4. Include trailing dots: Ensure fully qualified target names

5. Monitor CNAME targets: External changes can affect your site

Put This Knowledge to Work

Use DomScan's API to check domain availability, health, and more.