A CNAME record (canonical name record) makes one hostname an alias of another hostname. When a resolver looks up the alias, it follows the CNAME to the target name and returns that name's addresses. An A record instead points a hostname straight to an IPv4 address. Choose the type that matches the destination your service provider gives you.
What is a CNAME record?
A CNAME has an owner name (the alias) and a target (the canonical name). In a zone file it looks like this:
www.example.com. 3600 IN CNAME example.com. shop.example.com. 300 IN CNAME stores.example-host.net.
The first line sends www to whatever addresses the root domain uses. The second hands shop to a hosted store, so the host can change its servers without you editing DNS. The TTL (3600 or 300 seconds) controls how long resolvers may cache the alias itself.
- The target is a hostname, never an IP address or a URL with a path.
- A CNAME cannot share its name with other records, so no MX or TXT at the same name.
- The root domain usually cannot be a CNAME; see ALIAS and flattening below.
- A CNAME is not a web redirect. The browser keeps showing the alias in the address bar.
To see the alias chain a name currently returns, use the CNAME record lookup.
CNAME vs A record at a glance
| Question | A record | CNAME |
|---|---|---|
| Stores | An IPv4 address | A canonical hostname |
| Example | www → 192.0.2.10 | www → site.example.net |
| Ordinary zone apex | Allowed | Conflicts with required SOA/NS data |
| Other records at the same name | Usually allowed | Ordinary data cannot coexist |
| Destination address changes | You update the address | The target operator can change its addresses |
| IPv6 | Use AAAA separately | The target can return A and AAAA |
Two routes to the same service
These are documentation examples. The CNAME adds a name dependency, although caching can reduce repeated work. It does not redirect a browser URL or choose an HTTP path.
When to use A
Use A when you operate a service on an IPv4 address or your provider explicitly tells you to publish one. It works at the root domain and can coexist with MX and TXT records there. Keep the address up to date when you move hosting.
When to use CNAME
Use a CNAME on a suitable subdomain when a CDN, hosted application or storefront assigns a hostname to your account. This lets the target operator manage changing addresses. You still need to verify the hostname with that service and configure its certificate.
What about the root domain?
A normal CNAME cannot coexist with the apex SOA and NS data. Some DNS providers offer flattening or an ALIAS-like feature that accepts a hostname in the control panel but publishes address answers. Ask the DNS provider how its feature behaves and check both A and AAAA. A missing public CNAME answer is expected in some flattened setups.
ALIAS, ANAME and CNAME flattening
Many DNS providers offer a record that behaves like a CNAME at the zone apex. Depending on the provider it is called ALIAS, ANAME or CNAME flattening. You enter a hostname; the provider's nameservers look up that hostname's addresses and answer visitors with ordinary A and AAAA records. Because the public answer contains addresses, the apex keeps its SOA, NS, MX and TXT records.
These are provider features, not a standard DNS record type. A public lookup shows A or AAAA answers rather than the hostname you configured, and the answer may depend on where the provider resolved the target. Check your provider's documentation for how often it refreshes the target addresses.
AWS Route 53 alias records
Route 53 alias records are an AWS-specific extension. They can sit at the zone apex and point to AWS resources such as CloudFront distributions, Elastic Load Balancing load balancers and S3 website endpoints, or to another record in the same hosted zone. Route 53 answers with the target's A or AAAA records. See AWS's comparison of alias and CNAME records for current behaviour and pricing.
| What you need | Use |
|---|---|
| A subdomain points to a CDN or SaaS hostname | CNAME |
| The root domain must follow a provider hostname | ALIAS / ANAME / flattening, if your DNS provider supports it; otherwise the provider's A/AAAA addresses |
| You run the server on a fixed address | A, plus AAAA for IPv6 |
| An AWS resource at the apex of a Route 53 zone | Route 53 alias record |
A website migration example
Suppose www currently has an A record and your new provider requires a CNAME. Save the old settings, configure the destination, then replace the conflicting A record at www with the assigned CNAME. Do not remove the root-domain mail records. Check the chain, certificate and website before retiring the old host.
Verify the result
dig www.example.com A dig www.example.com CNAME nslookup -type=CNAME www.example.com
Use CNAME Lookup to see the chain and A Record Lookup for returned IPv4 addresses. If the answer is old, compare the previous TTL and active nameservers using the propagation troubleshooting guide.
Limits to remember
CNAME chains can loop, depend on abandoned services or fail when a target disappears. Multiple A records do not guarantee a healthy load balancer. Neither record type configures a web server, redirects a URL or proves that HTTPS works.
