Comparisons Networking

A Record vs CNAME

An A record points a name at an IPv4 address; a CNAME makes a name an alias of another name. The rules, the apex restriction and when to use each.

Last reviewed:

AdSense Placeholder
Slot: header_reference_page
On this page

An A record answers a lookup directly with an IPv4 address (its IPv6 twin is the AAAA record). A CNAME says "this name is really that other name; look that up instead", so the resolver follows it to the target's own A/AAAA records. Use A/AAAA records for names you control the addresses of, including the bare domain; use a CNAME for subdomains that should follow a hostname someone else manages, such as a CDN, a SaaS platform or a load balancer whose IP addresses change.

At a glance

Property A record CNAME record
Points to An IPv4 address (AAAA: an IPv6 address) Another domain name (the canonical name)
Example www.example.com. 300 IN A 192.0.2.10 www.example.com. 300 IN CNAME example.net.
Lookups needed One answer The alias plus the target's records (resolvers usually return the chain in one response)
Allowed at the zone apex (example.com) Yes No
Can coexist with other records at the same name Yes (several A records, MX, TXT and so on) No: a CNAME must be the only record at its name (DNSSEC records aside)
Can be the target of MX or NS records Yes (MX and NS must point at names with A/AAAA records) No
When the target's IP changes You must update the record Nothing to do; it follows automatically
Multiple values for load spreading Yes, several A records No, exactly one target
Typical uses Bare domain, your own servers, mail hosts www, CDN hostnames, SaaS custom domains, verification subdomains

Look up what a name currently returns with the DNS Record Lookup; the answer for a CNAME shows the alias and then the target's addresses.

A record

An A record is the final answer: a name and an IPv4 address with a TTL. Several A records on one name give simple round-robin load spreading, and an AAAA record next to it makes the name reachable over IPv6. Because A records can coexist with anything, they are what you use at the root of a domain, alongside its NS, SOA, MX and TXT records.

Choose an A (and AAAA) record when:

  • The name is the bare domain (example.com).
  • You run the server and know its static address.
  • The name must also carry other records, such as MX or TXT.
  • The name is the target of an MX or NS record.

CNAME record

A CNAME delegates the answer to another name. When a provider moves its servers or adds addresses, your alias follows without you touching your zone. The cost is a few rules: the CNAME must be alone at its name, it cannot sit at the apex, it adds a step to resolution (each name in the chain has its own TTL), and chains of CNAMEs pointing at CNAMEs slow lookups and are fragile. Never leave a CNAME pointing at a service you have cancelled: someone else may claim that hostname and serve content on your subdomain ("subdomain takeover").

Choose a CNAME when:

  • The target is a hostname a provider tells you to use (CDN, hosting platform, e-mail or marketing service).
  • You want several names (www, shop, docs) to follow one canonical host.
  • The provider's IP addresses may change without notice.

Which should you choose?

  • Bare domain: A and AAAA records, or the provider's ALIAS/ANAME/flattening feature if the target is a hostname.
  • www or another subdomain on a CDN or SaaS platform: CNAME to the hostname they give you.
  • Your own server with a fixed address: A and AAAA records.
  • A name that also needs MX or TXT records: A/AAAA, because a CNAME cannot share its name.
  • Mail server named in an MX record: A/AAAA, never a CNAME.

After a change, lower the TTL in advance and watch the new answer spread with the DNS Propagation Checker. If the alias serves a website, confirm with the SSL Certificate Checker that the target's certificate covers your name. For the whole resolution process, see How DNS Works.

Try these tools

See also

  • Guide How DNS Works
    How a name becomes an IP address through resolvers, root, TLD and authoritative servers, the record types, TTL and caching.
  • Glossary DNS
    DNS (Domain Name System) is the internet's directory that translates domain names like example.com into IP addresses and holds other.
  • Glossary TTL
    TTL (time to live) is how long, in seconds, a DNS record or cached item may be reused before it must be fetched again.
  • Glossary Subdomain
    A subdomain is a name placed in front of a domain, such as blog.example.com or www.example.com.
  • Glossary CDN
    A CDN (content delivery network) is a network of servers around the world that stores copies of a site's files and serves them from the.
  • Glossary Domain name
    A domain name is the human-readable address of a website or service, such as example.com, which DNS translates into an IP address.

Frequently Asked Questions

Not in standard DNS. The zone apex must hold SOA and NS records, and a CNAME cannot share a name with any other record. Use A and AAAA records there, or your DNS provider's ALIAS, ANAME or CNAME-flattening feature, which answers with addresses while tracking a target name.

No. DNS only changes which server the browser connects to; the address bar and the Host header keep the original name. The target server must be configured to serve that name, including a TLS certificate that covers it. A visible redirect needs an HTTP 301 or 302.

AdSense Placeholder
Slot: footer_leaderboard