How to cname record
Content on WhatAnswers is provided "as is" for informational purposes. While we strive for accuracy, we make no guarantees. Content is AI-assisted and should not be used as professional advice.
Last updated: April 4, 2026
Key Facts
- CNAME records create an alias for a domain name.
- They point to another domain name, not directly to an IP address.
- CNAMEs are crucial for services that use subdomains for their infrastructure (e.g., cloud hosting, CDNs).
- A CNAME record cannot coexist with other record types (like A or MX) for the same hostname.
- The target of a CNAME record must be a fully qualified domain name (FQDN).
What is a CNAME Record?
In the realm of the Domain Name System (DNS), records are essential components that help translate human-readable domain names into machine-readable IP addresses. Among these, the CNAME (Canonical Name) record plays a unique role. Unlike other DNS records that point directly to an IP address (like A records for IPv4 or AAAA records for IPv6), a CNAME record acts as a pointer to another domain name. Essentially, it establishes an alias, indicating that one domain name is an alias for another, the 'canonical' or true name.
Why Use CNAME Records?
The primary purpose of a CNAME record is to simplify management and provide flexibility. Here are some common use cases:
- Pointing 'www' to the root domain: A very common practice is to set up a CNAME record for 'www.yourdomain.com' that points to 'yourdomain.com'. This ensures that visitors can reach your website whether they type 'www.' or not.
- Using third-party services: Many services, such as Content Delivery Networks (CDNs), cloud hosting platforms (like Heroku or AWS Elastic Beanstalk), and website builders, require you to point a subdomain to their infrastructure. For example, you might create a CNAME record for 'blog.yourdomain.com' that points to a specific domain provided by your blogging platform.
- Multiple hostnames for the same server: If you have a server hosting multiple websites or services, you can use CNAME records to point different subdomains to the same canonical domain, which in turn resolves to the server's IP address.
- Facilitating domain changes: If you need to move your website or service to a new server or provider, you can update the CNAME record's target to the new domain name. This allows you to transition without immediately updating DNS records across all subdomains, as they will automatically follow the CNAME's new target.
How CNAME Records Work
When a DNS resolver queries for a hostname that has a CNAME record, the resolver receives the canonical name as the answer. It then must perform a second DNS lookup for that canonical name to find its corresponding IP address. This process is transparent to the end-user, but it does add an extra step in the DNS resolution process, which can slightly increase latency.
Important Considerations and Limitations
While CNAME records are powerful, they come with certain restrictions:
- Cannot coexist with other records: A hostname cannot have a CNAME record if it also has any other DNS records associated with it (except for DNSSEC-related records like RRSIG and NSEC). This means you cannot have a CNAME record for 'mail.yourdomain.com' if you also have MX records for it, as MX records are essential for email delivery.
- The root domain (apex domain): Generally, CNAME records cannot be used for the root (or apex) domain (e.g., 'yourdomain.com' itself). This is because the root domain typically needs other records like MX (for email) and NS (name server) records, which conflict with the CNAME rule. Some DNS providers offer workarounds like 'CNAME flattening' or 'ALIAS' records, which behave like CNAMEs at the root but are technically implemented differently.
- Performance impact: As mentioned, the extra DNS lookup required for a CNAME can add a small amount of latency. For critical performance applications, this might be a consideration.
How to Create a CNAME Record
The process of creating a CNAME record is done through your domain registrar or DNS hosting provider's control panel. The exact steps may vary, but generally, you will:
- Log in to your domain's DNS management interface.
- Navigate to the DNS records section.
- Create a new record.
- Select 'CNAME' as the record type.
- Enter the hostname or subdomain you want to alias (e.g., 'www', 'blog', or 'shop').
- Enter the target canonical domain name (e.g., 'yourdomain.com', 'ghs.googlehosted.com', or a CDN domain).
- Set the TTL (Time To Live), which determines how long DNS resolvers cache the record. A common TTL is 3600 seconds (1 hour).
- Save the record.
After saving, it can take anywhere from a few minutes to 48 hours for the DNS changes to propagate across the internet.
CNAME vs. Other DNS Records
Understanding the difference between CNAME and other common DNS records is crucial:
- A Record: Maps a hostname directly to an IPv4 address.
- AAAA Record: Maps a hostname directly to an IPv6 address.
- MX Record: Specifies the mail servers responsible for receiving email for a domain.
- TXT Record: Stores arbitrary text, often used for verification purposes (like SPF or DKIM records for email authentication).
- ALIAS/ANAME Record: These are non-standard records offered by some DNS providers that allow you to point the root domain to another hostname, mimicking CNAME functionality while allowing other record types.
In summary, CNAME records are a flexible tool for creating aliases within your DNS configuration, simplifying management and enabling integration with various online services. However, it's important to be aware of their limitations, particularly regarding the root domain and coexistence with other record types.
More How To in Daily Life
Also in Daily Life
More "How To" Questions
Trending on WhatAnswers
Browse by Topic
Browse by Question Type
Sources
- CNAME record - WikipediaCC-BY-SA-4.0
- What is a CNAME record? | Cloudflarefair-use
- What is a CNAME record? | Namecheapfair-use
Missing an answer?
Suggest a question and we'll generate an answer for it.