A CNAME (Canonical Name) is a DNS record that defines a domain name as an alias for another domain name. Unlike an A record, a CNAME doesn't contain an IP address: the resolver first looks up the name specified in the CNAME, then resolves the address for that name.

CNAME is worth using when a subdomain needs to "follow" another name: for a www version of a site, for connecting an external service or CDN (Content Delivery Network), or for migrating to another host. If you need to point to a specific IP address, or you're configuring the root domain, use an A record instead.

As an example, take the subdomain blog.example.com. You can make it an alias of example.com: if the IP address of the main domain changes, the CNAME record itself won't need to be updated.

How CNAME differs from an A record

The main difference is what the record points to. An A record links a name to an IPv4 address, and an AAAA record links it to an IPv6 address. A CNAME links one domain name to another, and the resolver then obtains the IPv4 and IPv6 addresses from that target name.

Name

Type

Value

example.com

A

203.0.113.10

example.com

AAAA

2001:db8::10

blog.example.com

CNAME

example.com

Key differences:

Parameter

A / AAAA

CNAME

Record value

An IP address: IPv4 in A, IPv6 in AAAA

A domain name

If the resource's IP address changes

The record must be updated in your DNS zone

No change needed if the address changes on the target name

Root domain (apex)

Can be used

Cannot be used

Other records on the same name

Allowed (MX, TXT, etc.)

Not allowed

Additional name resolution

Not required

Required: the resolver looks up the address of the target name

When it fits

When you need a specific IP address: root domain, your own server

When you need an alias: external service, CDN, www

A CNAME is not an HTTP redirect. If a user opens blog.example.com, the browser isn't told to navigate to example.com, and the address bar doesn't change. CNAME operates at the DNS level: it determines which name needs to be resolved to get an IP address.

What "canonical name" means

Canonical Name is exactly that — a "canonical name." In a CNAME record, one name acts as the alias, while the other is the canonical name — the one the record points to.

Name

Type

Value

shop.example.com

CNAME

stores.example.net

Here, shop.example.com is the alias, and stores.example.net is the canonical name. If stores.example.net has an A record pointing to 203.0.113.25, the resolver will ultimately get that same IP address for shop.example.com as well.

This is convenient when a resource needs to be tied not to a specific IP address, but to another domain name.

When to use CNAME: practical scenarios

There are several typical situations where a CNAME makes sense.

Site subdomains

The simplest case is making a subdomain an alias of the main domain.

Name

Type

Value

www.example.com

CNAME

example.com

This way you don't have to manually duplicate the main site's IP address: if the address that example.com points to changes, the www record stays the same.

Connecting an external service

SaaS platforms, website builders, analytics systems, and other third-party services often let you connect your own subdomain via a CNAME. The instructions usually look like this:

Name

Type

Value

support.example.com

CNAME

customer.service.example

You create a record in your own DNS zone, and the service starts handling requests to the chosen subdomain. CNAME is convenient here because the domain owner doesn't need to track the external platform's IP addresses.

CDN and cloud services

A CDN or another cloud service may give you a domain name to point your subdomain to.

Name

Type

Value

static.example.com

CNAME

customer.cdn.example

The client doesn't need to enter the CDN infrastructure's full set of IP addresses: the target name is served by the service itself, and its DNS configuration changes independently of your DNS zone. The exact connection method depends on the specific CDN — some use CNAME, others rely on different mechanisms.

Migration and hosting changes

If a site or service is moving to a provider that assigns clients their own domain name, it's convenient to point your subdomain to that name via a CNAME. When the provider changes the IP addresses behind its name, your record stays the same. And when moving to a different provider, you only need to update the value of that one record.

Before a planned move, lower the record's TTL in advance (more on this in the "Common mistakes" section) so the switch propagates to users faster.

Where to configure a CNAME

DNS records are edited wherever the domain is delegated to DNS servers: with your registrar or DNS provider. If your domain uses Leneex's DNS servers, check in the domain control panel whether a DNS zone editor is available and whether it supports the CNAME record type: the set of available record types may depend on your plan.

When you don't need a CNAME

Don't mechanically replace all A records with CNAMEs. CNAME doesn't fit when:

  • you need to configure the root domain (example.com): for that, use A and AAAA records or your DNS provider's special mechanisms;

  • the name already has other records, such as MX or TXT: in that case, point to the needed address with an A/AAAA record, or choose a different name for the CNAME;

  • you need to redirect visitors from one URL to another: that's done with a server-side HTTP redirect, not a CNAME.

CNAME limitations and rules

If a name is a CNAME, no other DNS records can exist on it (the exception being certain DNSSEC-related records). This is laid out in the standards: RFC 1034, section 3.6.2 and RFC 2181, section 10.1.

CNAME cannot coexist with MX, A, AAAA, TXT

Example of an invalid configuration:

Name

Type

Value

support.example.com

CNAME

customer.service.example

support.example.com

MX

10 mx.service.example

Here, both a CNAME and an MX record are assigned to the same name, but a CNAME only allows a single record on that name. The DNS server or control panel may reject such a zone, and different resolvers may handle it inconsistently, which can make mail on that name unreliable or completely broken.

For the same reason, you can't add a CNAME to a name that already has an A, AAAA, TXT, or other record: you need to remove the existing ones first, or choose a different name for the CNAME.

CNAME can't be used on the root domain

The apex, or root domain, is the zone name itself, without a subdomain. For example.com, the apex is example.com, while www.example.com is already a subdomain.

You can't use a CNAME on the root domain: the zone's root must always have NS and SOA records, and a CNAME can't coexist with other records.

Name

Type

Value

example.com

CNAME

service.example.net

This configuration is invalid. For the root domain, some DNS providers offer proprietary mechanisms: ALIAS, ANAME, or CNAME flattening. These are provider-specific extensions, not standard CNAME records — to the outside world, they appear as regular A and AAAA records.

CNAME can form a chain

A CNAME can point to a name that is itself a CNAME:

Name

Type

Value

a.example.com

CNAME

b.example.com

b.example.com

CNAME

c.example.com

c.example.com

A

203.0.113.10

The resolver has to follow the whole chain, and each link means an extra lookup. Chains that are too long or circular cause resolution errors, so it's best to avoid unnecessary intermediate CNAMEs.

Common CNAME configuration mistakes

Mistakes involving CNAME on the root domain and combining CNAME with other records on the same name were covered above, in the "CNAME limitations and rules" section. Below are other common mistakes.

CNAME pointing to an IP address

A CNAME must reference a domain name, not an IP address like 192.0.2.10. For a direct IPv4 address, use an A record; for IPv6, use AAAA.

The control panel auto-appends the domain to the value

In some control panels and zone files, a name without a trailing dot is treated as relative, and your zone name gets appended to it: service.example.net becomes service.example.net.example.com. After saving, check the final record value. In zone file format, a fully qualified name is written with a trailing dot: service.example.net.

If the final target name is known and won't change, point the CNAME directly to it rather than to another CNAME, whenever possible. This reduces the number of steps the resolver has to take and makes the setup easier to follow.

Editing the DNS zone that serves mail

When connecting a third-party service, don't remove existing records before finding out what they're for: MX records, as well as SPF and DKIM TXT records, handle mail. If such records already exist on the name you want to use, you can't create a CNAME there — choose a different subdomain for the service instead.

Confusing CNAME with an HTTP redirect

A CNAME doesn't redirect a visitor from one URL to another. It only affects the DNS name resolution process.

Not accounting for TTL

TTL (time to live) is the number of seconds resolvers are allowed to cache a response. After you change a record, some resolvers will keep serving the old answer until the TTL expires, so results can vary across different networks. Before a planned change, lower the TTL (for example, to 300 seconds) in advance — no later than the duration of the previous TTL — and restore the original value after confirming everything works.

Conclusion

A CNAME is useful when one name needs to be an alias of another: for example, a subdomain for an external service, a CDN, or the www version of a site. If you need to point to a specific IP address or configure the root domain, use A and AAAA records instead. Don't create a CNAME on a name that already has other records, especially mail-related ones.

Before making a change, check the zone's existing records and lower the TTL in advance: this makes mistakes easier to spot and fix, and the switchover will go faster. To dig deeper into DNS, read our article on DNS record types: A, AAAA, CNAME, MX, TXT, and others. Once the DNS structure makes sense to you, add the record in your registrar's or hosting provider's DNS editor.

FAQ

Can CNAME be used for the root domain?

No. The zone's root must always have NS and SOA records, and a CNAME can't coexist with other records on the same name. For the root domain, use A and AAAA records, or a DNS provider's special mechanisms such as ALIAS or ANAME.

What's the difference between CNAME and an A record?

An A record points a name to an IPv4 address (AAAA is used for IPv6), while a CNAME points to another domain name. CNAME is handy when a resource is represented by a domain name whose IP address can change independently of your DNS zone.

Does CNAME slow down site loading?

A CNAME on its own doesn't make page loading noticeably slower. It adds an extra DNS resolution step, but the result gets cached, so CNAME can't be considered a direct cause of a slow site.

Can I add an MX record to a subdomain that already has a CNAME?

No. A CNAME can't coexist with an MX record on the same DNS name. If a subdomain is already a CNAME, you can't create a regular MX record for it — mail needs to be configured on a different name.

How long do changes to a CNAME record take to apply?

There's no fixed timeframe for all zones: it depends on the record's TTL. Resolvers may keep serving the old answer until the TTL expires, so with a TTL of 3600 seconds, changes usually propagate within an hour, while a TTL of one day can take up to 24 hours. Sometimes propagation takes longer due to quirks in specific resolvers or intermediate systems.