DNS (Domain Name System) records are fundamental to how the internet works, helping translate domain names into IP addresses. One of the most versatile and widely used DNS records is the CNAME record, which plays a key role in domain aliasing and simplifying DNS management. This article explores what a CNAME record is, how it's structured, common use cases, best practices, how to troubleshoot it, and answers to frequently asked questions.
A CNAME (Canonical Name) record is a type of DNS record that maps an alias domain name to a **canonical domain name **. Instead of pointing directly to an IP address, like an A or AAAA record, the CNAME points to another domain name.
For example, if you have a website www.example.com and you want it to point to example.com, you would use a CNAME
record for www that points to example.com.
This allows multiple domain names to refer to a single DNS entry, making management easier and more efficient.
A typical CNAME record includes the following components:
www.example.com)CNAME for canonical name records| Name | Type | Value | TTL |
|---|---|---|---|
| www | CNAME | example.com | 3600 |
Note: A CNAME record must always point to another domain name, not an IP address.
www.example.com to example.com or blog.example.com to hosting.example.net.cdn.example.com →
cdn.provider.net.example.com), though some providers support
workarounds.images.example.com → img.cdnprovider.com).If a CNAME record isn’t resolving correctly, consider the following:
dig, nslookup, or online DNS checkers to see if the CNAME is available globally.CNAME records are a powerful tool in DNS that simplify aliasing and domain management. Whether you're connecting subdomains to services, managing external providers, or streamlining internal DNS structures, CNAME records offer flexibility and efficiency. By following best practices and understanding their behavior, you can ensure a robust and reliable DNS setup.
A CNAME record maps a domain to another domain name, while an A record maps a domain directly to an IPv4 address.
Generally, no. Most DNS providers do not allow a CNAME at the root domain (example.com) due to DNS specification
limitations. Instead, use an A or ALIAS/ANAME record.
Use dig, nslookup, or online tools like DNSHog to look up the CNAME and see where it points.
If the canonical domain fails to resolve (e.g., has no A or AAAA record), the alias will not resolve either.
No. A CNAME must always point to a domain name, not a direct IP address.