A CNAME record creates an alias. It links one domain name to another name. The resolver then follows that target name to find A or AAAA records. The browser then obtains the server address through this chaining.
A CNAME record contains a name, a type, a target, and a TTL. The TTL indicates how long the response remains cached in the local resolver.
| Name | Type | Target | TTL in seconds |
|---|
| www | CNAME | host.example.net. | 3600 |
In this example, the name www is an alias. The target is another domain name. That target name must publish A or AAAA records to provide an address. A TTL of 3600 corresponds to one hour.
The same name cannot have multiple CNAME records. A CNAME cannot coexist with other records at the same location. No A, no AAAA, no MX, no TXT at the same label. The CNAME must stand alone.
A short TTL speeds up the visibility of a target change. Useful during a migration to a new provider.
A medium or long TTL reduces queries to the authoritative servers. Suitable for a stable service.
It's recommended to lower the TTL a few hours before a switchover, then raise it back once everything is stable.
Good to know
A CNAME can chain to another CNAME. This works, but each hop adds a slight delay. It's better to point directly to the final name whenever possible.
At the root of a domain name (the apex), avoid using a CNAME because the apex must already publish SOA and NS. Some providers offer an equivalent feature called flattening or ALIAS.
For www, a CNAME is often convenient when the target is managed by a provider. For api, cdn, or static, a CNAME keeps the architecture flexible. The target can change without touching the original name.
To avoid
Placing a CNAME at the same location as an A, AAAA, MX, or TXT is not compliant.
Using a CNAME at the apex without a provider's dedicated feature.
Pointing an MX record to a name that itself is a CNAME. The MX must point to a name that publishes A or AAAA.
An online DNS lookup lets you enter a name. You get the CNAME target and the TTL as visible from the Internet. It's a useful first check. Then run a local test from your machine.
Windows provides nslookup. You can use it in interactive mode.
nslookup
set q=cname
www.example.com
nslookup
set q=cname
server 1.1.1.1
www.example.com
The first part queries, according to the machine's network configuration. The second part forces the use of a third‑party resolver, here Cloudflare's.
On these systems, the dig command is handy and easy to use.
dig CNAME www.example.com
dig CNAME www.example.com @1.1.1.1
A response showing a CNAME indicates the target name. You must then verify that this target name does publish A or AAAA.
A high remaining TTL can explain a delay after a target change.
An overly long CNAME chain can create latency. Shorten the chain when possible.
- Prepare the final target that publishes A or AAAA.
- Lower the CNAME TTL to 300 or even 60 seconds a few hours before the switchover.
- Change the CNAME target at the planned time.
- Verify with nslookup or the dig command from multiple networks.
- Raise the TTL back to a comfortable value once everything is stable.
Practical tip
Note the current target and the planned target before any modification. Keep the date, the TTL, and the reason for the change. This record prevents confusion and speeds up rollback if needed.
Set www as a CNAME to the name provided by the CDN. Keep A and AAAA records at the apex if the platform offers an apex CNAME equivalent.
For a third‑party–managed service such as transactional email or analytics, a CNAME lets you delegate resolution without publishing an address.
Point preprod as a CNAME to a distinct hosting name. A simple switch by changing the target when the version is validated.
- If the site does not respond, first check that the CNAME points to the correct name.
- Verify that the target publishes A or AAAA. Without that, resolution will not provide an address.
- If a service changes infrastructure, update the target. Avoid unnecessary chains.
- If the response remains old, wait for the TTL to expire and purge the local resolver cache if possible.
In summary, a CNAME record creates an alias between two names. The resolver follows the target to obtain A or AAAA records. A CNAME must be alone at the same location. Avoid using a CNAME at the apex unless the provider offers a dedicated feature. Verification starts with an online tool, then with nslookup and dig.
With these guidelines, management stays clear. Changes proceed without stress. Visitors reach the site without incident.