A Record vs. CNAME Record
An A record maps a domain or subdomain directly to an IPv4 address, such as 203.0.113.10. A CNAME record instead points a name to another hostname, which is then looked up to find the final address. Use an A record for your root domain, and a CNAME for aliases such as www or a subdomain that should always follow another name.
What an A record does
An A record (short for "address record") maps a hostname straight to an IPv4 address. It is the most direct kind of DNS record: when a browser looks up example.com, the A record tells it exactly which server to connect to. The equivalent record for an IPv6 address is called an AAAA record.
What a CNAME record does
A CNAME record (Canonical Name record) does not point to an address at all. It points to another hostname, and the resolver has to look up that name next to find the actual IP address. CNAMEs are common for aliases, such as pointing www.example.com to example.com, or pointing a subdomain to a service hosted elsewhere, such as a CDN or an email marketing platform.
A record vs. CNAME, side by side
| A record | CNAME record | |
|---|---|---|
| Points to | An IPv4 address | Another hostname |
| Extra lookup needed | No | Yes, one more step to resolve the target name |
| Can be used at the root domain | Yes | Usually not allowed by most DNS providers |
| Can share a name with other records | Yes, with AAAA or MX for example | No, a name with a CNAME cannot have any other record type |
| Follows the target if it changes | No, must be updated manually | Yes, automatically |
Rules and common mistakes
- A name that has a CNAME record cannot have any other record type, including MX or TXT, at that same name.
- Most DNS providers block a CNAME at the bare root (apex) domain, such as
example.comwithout a subdomain, so the root almost always uses an A record instead. - CNAME chains, where one CNAME points to another CNAME, add extra lookup time and should be kept short.
- Changing an A record's IP takes effect only after its TTL (time to live) expires, so lower the TTL in advance of a planned server move.
Checking records from a terminal
dig example.com A
dig www.example.com CNAME
nslookup www.example.com
The output shows the record type returned and, for a CNAME, the target name that was followed before the final address was found.
Frequently asked questions
What is an A record used for?
An A record points a domain or subdomain directly to an IPv4 address, so visitors reach the right server. It is the record type most root domains use.
What is a CNAME record used for?
A CNAME record points one hostname to another hostname instead of to an address, which is useful for aliases like www or for pointing a subdomain to an external service such as a CDN.
Can I use a CNAME for my root domain?
Most DNS providers do not allow a CNAME at the bare root domain, because a CNAME cannot coexist with other required records like MX. Point the root with an A record, and use a CNAME for subdomains instead.
What happens if I add both an A record and a CNAME for the same name?
This is not allowed. A hostname with a CNAME record cannot have any other record type at the same name, and most DNS systems will reject or ignore the conflicting entry.
Does a CNAME work for IPv6 addresses?
A CNAME points to a hostname, not an address type, so the same CNAME resolves correctly whether the target eventually has an A or an AAAA record. You do not need a separate CNAME for IPv6.
How do I check which record type a domain uses?
Run a command such as dig example.com A or dig www.example.com CNAME from a terminal, or use an online DNS lookup tool, to see the exact record type and value returned.
Related topics
- IPv4 vs. IPv6 Networking & IP
- What Is an IP Address? Networking & IP
- What Is DNS (Domain Name System)? Domains & DNS
- What Is a CDN (Content Delivery Network)? Performance & CDN
- What Is TTL (Time to Live) in DNS? Domains & DNS