Skip to main content

Detailed Explanation of CNAME Records

What is a CNAME record?

A CNAME record (Canonical Name Record) is used to point one domain name to another domain name to implement alias resolution. For example:
If a.example.com is pointed to www.example.com, when users visit a.example.com, they will be redirected to www.example.com.

Common uses of CNAME records

1. Pointing a subdomain to the primary domain

  • For example: blog.example.com is pointed to www.example.com, so all requests to access blog.example.com will be redirected to the server pointed to by www.example.com.

2. Load balancing and CDN

  • Point your domain to the domain name provided by the CDN to implement acceleration and content distribution, for example www.example.com points to example.cdnprovider.com.

3. Service Alias

  • Used for binding domain names to third-party services, such as email services, cloud storage, SaaS applications, etc.:

    • mail.example.commail.provider.com

    • shop.example.comshop.saasplatform.com

4. Simplified Domain Redirection Management

  • When the server changes, you only need to update the target domain that the record points to, instead of modifying the IP address for each subdomain individually.

Add a CNAME Record

Add a CNAME record

Host Record:

  • @ represents the root domain (such as example.com)

  • www indicates www.example.com

  • Other specific subdomains

Type: Select CNAME record

TTL: 600 seconds (recommended)

Value: Enter the domain address to point to

Weight: No special requirements; you can fill in 1 uniformly.

TTL
  • TTL is the time-to-live for DNS records in the cache of recursive DNS servers.

  • The unit is seconds. The shorter the TTL, the faster DNS changes take effect; the longer the TTL, the higher the cache hit rate and the more stable the resolution speed.

  • 600 seconds (10 minutes) is a common compromise value that balances flexibility and stability.

Weight

The higher the weight value, the higher the proportion of traffic assigned to it. This only takes effect among records of the same type.

Notes

  1. A CNAME record can only point to another domain name, not an IP address.

  2. According to RFC standards, when a subdomain is configured with a CNAME record, no other records can exist for it. In actual operations, if other records exist at the same time, CNAME usually takes priority, but this does not comply with the standard.

  3. Root domains, such as example.com, usually need to be configured with A records or AAAA records, and cannot be configured with CNAME records.