What Is a CNAME in DNS?
A Canonical Name (CNAME) record is a DNS entry that maps an alias name to a true or "canonical" domain name. Instead of pointing a domain directly to an IP address, a CNAME points to another domain name, which eventually resolves to an IP address. This structure functions like a nickname or a forwarding address, ensuring that if the IP address of the main domain changes, all aliases automatically update without needing manual reconfiguration.
The Role of CNAME in DNS
A CNAME record simplifies domain management by allowing multiple domain names to map to a single source. For example, a website might use www.example.com and blog.example.com, but both can point to the root domain example.com via CNAME records. When a user queries blog.example.com, the DNS resolver sees the CNAME, redirects the query to example.com, and then finds the actual IP address associated with that root domain. This allows administrators to change the IP address of the main server in one place (the A record for the root domain) rather than updating every single subdomain individually.
Restrictions and Limitations
While useful, CNAME records come with specific rules. A domain name that has a CNAME record cannot have any other DNS records (such as MX or TXT records) assigned to it. This restriction means you generally cannot place a CNAME on a root domain (like example.com) because root domains require other record types to function properly. Additionally, CNAME records must always point to another domain name, never directly to an IP address.
Comparison with A Records
The primary alternative to a CNAME is an A Record (Address Record), which maps a domain directly to an IPv4 address.
| Feature | CNAME Record | A Record |
|---|---|---|
| Target | Points to another domain name | Points to an IP address |
| Efficiency | Requires an extra DNS lookup | Direct resolution (faster) |
| Root Domain | Generally not allowed on root | Required for root domains |
| Flexibility | Updates automatically if target IP changes | Must be manually updated if IP changes |
Common Use Cases
CNAME records are frequently used when integrating third-party services. For instance, platforms like Shopify or Squarespace often ask users to create a CNAME record pointing a subdomain (like shop.yourdomain.com) to their servers. They are also standard for handling the www version of a website, ensuring www.example.com always resolves to the same location as example.com. This setup delegates the management of the destination IP to the service provider, preventing broken links if the provider migrates servers.












