CNAME Record - DNS Alias

Simplify your DNS with intelligent aliases.

The CNAME (Canonical Name) record creates an alias from one domain name to another. Instead of pointing directly to an IP like an A record, a CNAME points to another domain name that itself resolves to an IP. It's a powerful tool for simplifying DNS management.

CNAMEs are particularly useful for subdomains that need to point to third-party services (CDN, SaaS, hosting) or to centralize IP management. By changing the IP of the canonical domain, all CNAME aliases are automatically updated.

However, CNAMEs have important limitations: they cannot coexist with other records at the same level, and the root domain (apex) cannot have a CNAME. Understanding these rules is essential to avoid configuration errors.

What is a CNAME Record?

CNAME creates an indirection in DNS resolution:

CNAME Use Cases

CNAMEs are used in many scenarios:

How to Configure a CNAME

Follow these steps to create a CNAME:

  1. Identify the need: Determine which subdomain should be an alias and which canonical domain it should point to. Verify the target has an A record.
  2. Check for conflicts: Make sure there are no other records for this name (A, MX, TXT). Remove them or choose another name.
  3. Create the record: In your DNS manager, add a CNAME record with the alias name and canonical target.
  4. Test resolution: Use dig CNAME alias.example.com then dig alias.example.com to verify the resolution chain works.

CNAME Configuration Examples

Here are common CNAME configurations:

; www as alias for root domain
www.example.com. IN CNAME example.com.

; Subdomain to third-party service
blog.example.com.  IN CNAME example.ghost.io.
shop.example.com.  IN CNAME shops.myshopify.com.
mail.example.com.  IN CNAME ghs.googlehosted.com.

; CDN Cloudflare (example)
cdn.example.com.   IN CNAME example.com.cdn.cloudflare.net.

; SSL certificate validation
_acme-challenge.example.com. IN CNAME example.com.xxxxx.acme.zerossl.com.

; Verification with dig
$ dig www.example.com CNAME +short
example.com.

$ dig www.example.com +short
93.184.216.34

The CNAME points to another domain name (not an IP). Resolution follows the chain until reaching an A record. Note the mandatory trailing dot in zone files.

CNAME Best Practices

Avoid common CNAME pitfalls:

CNAME Checklist

  • Verify no other record exists at the same name
  • Verify target exists and resolves correctly
  • Do not use CNAME for root domain
  • Trailing dot added after target name in zone
  • Appropriate TTL defined
  • Resolution chain tested end-to-end

Frequently Asked Questions - CNAME

Why can't I have a CNAME at the apex?

The DNS RFC states that a CNAME cannot coexist with other records. However, the apex always has at least SOA and NS. Some DNS providers offer ALIAS or ANAME as an alternative.

Does CNAME impact performance?

Slightly. A CNAME adds one DNS resolution step. In practice, with DNS caches, the impact is generally negligible (a few milliseconds).

Can I have a CNAME and MX at the same level?

No. If you have a CNAME for a name, you cannot have MX (or A, TXT, etc.) for that same name. This is why CNAMEs are used for subdomains, not the main domain.

What happens if the CNAME target changes IP?

That's the advantage! Your alias follows automatically. If cdn.provider.com changes IP, your cdn.example.com CNAME to them follows without modification on your side.

CNAME vs A: which to choose?

Use A if you directly control the IP and it's stable. Use CNAME if you're pointing to a third-party service or want to centralize IP management.

How to monitor a CNAME with MoniTao?

MoniTao can monitor CNAME records and alert you if the target changes. You can also monitor the final resolution (the IP after following the CNAME chain).

Master DNS Aliases

CNAME records are powerful tools for simplifying your DNS infrastructure. They allow delegating IP management to third-party services and centralizing your configurations. But they have strict rules that must be followed.

Use CNAMEs wisely, document your configurations, and monitor them with MoniTao to detect any unexpected changes in your DNS infrastructure.

Ready to Sleep Soundly?

Start free, no credit card required.