DNS records7 min read

CNAME vs A Record: Differences and When to Use Each

A records point directly to IPv4 addresses. CNAME records make one hostname an alias of another hostname. Both can direct users toward a service, but they behave differently during migrations, CDN onboarding and provider changes.

A record behavior

An A record returns an IPv4 address directly. It is suitable when you control a stable destination address or when a provider explicitly supplies IP addresses.

A record lookupdig
dig example.com A +short
dig @1.1.1.1 example.com A +noall +answer

CNAME behavior

A CNAME returns a canonical hostname. The resolver must then obtain A or AAAA records for that target. This allows the target provider to change its own addresses without requiring you to update the alias.

CNAME and target lookupdig
dig www.example.com CNAME +short
dig www.example.com A +short
dig target.provider.net A +short

Choose based on ownership and change

  • Use A when the service gives you an IPv4 address you are expected to manage.
  • Use CNAME when a SaaS, CDN or hosting provider gives you a managed target hostname.
  • Use multiple A records only when the service supports direct address-based load balancing.
  • Check whether your DNS provider offers ALIAS, ANAME or CNAME flattening for the zone apex.

Important limitations

CNAME at the zone apex

Traditional DNS rules conflict with required apex records such as SOA and NS.

CNAME alongside TXT or MX at the same name

A CNAME owner name should not contain other data.

Pointing CNAME directly to an IP address

The target must be a hostname.

Deleting the old record before verifying the target

Confirm TLS, HTTP routing and target resolution before cutover.

Related DNS guides