What is a CNAME Record? Clarifying Domain Aliases

The CNAME record is also known as a canonical name record. It is used for specifying that a domain name is an alias for another domain, the “canonical” domain. A typical example is the www subdomain which is often set as an alias to the root domain name

The CNAME Record is used only for subdomains. You can't add any other records for a given hostname, if this hostname has a CNAME Record. Also, it's not possible to create CNAME record if there are any other records for this hostname.

The CNAME record has the following look in your ClouDNS Control Panel:

Host: Type: Points to: TTL
example.hostname.com CNAME example2.hostname.com 1 Hour

Why do you need a CNAME record?

CNAME records are frequently used for pointing many hosts to the same place and updating them easily. Illustration of this can be seen below:

Host Type Points to: TTL
panel.cloudns.net A 185.107.80.223 1 Hour
www.panel.cloudns.net CNAME panel.cloudns.net 1 Hour

The example above is a typical setup for websites. If for some reason, your server's IP has changed, only a single record will need adjustment.

Common Uses

Some of the most popular scenarios for implementing CNAME record are the following:

  • Providing a separate hostname for specific services, such as email or FTP, and pointing that hostname to the root domain.
  • Registering the same domain in several countries and pointing the country versions to the main “.com” domain
  • Pointing from several websites owned by the same organization to a primary website

How to create a DNS CNAME record?

Go to your Control Panel and click on Add new record. Type, as follow:

Type: CNAME
TTL: 1 Hour
Host: example
Points to: example2.hostname.com

How to add a CNAME record - Step by Step video:

Best Practices for CNAME Records

By following these best practices you will ensure the proper functioning of your CNAME record:

  • First, it is important to always verify the target hostname with the host that owns it. When linking to an external domain name, make sure that it is still active and points to the desired resource. 
  • Secondly, make sure to set a proper TTL (Time to live) value for your CNAME record. This helps to ensure that other DNS servers are aware of any changes that you make to the CNAME record. Generally, a TTL of 30 minutes to an hour is considered a good setting for most CNAME records. 
  • Lastly, ensure that there are no nested CNAME records. If a CNAME record points to another CNAME record, the DNS query will eventually time out and result in an error. Therefore, all CNAME records should point to an IP address or another hostname.

Following these best practices can help to ensure that your CNAME records are configured correctly and provide you with a smooth resolution of your domain name requests.

Restrictions

Here are several important restrictions that you should be aware of:

  • A CNAME record can point to another hostname and it cannot be pointed to an IP address directly.
  • According to RFC 1912 2.4, a CNAME record is not allowed to coexist with any other data for the same host.
  • A CNAME record cannot be placed for the root domain.
  • Pointing CNAME to another CNAME is considered as a bad practice and it is not recommended as it is inefficient.

CNAME record VS A record

The A records and the CNAME records are the two most commonly used records and sometimes you can easily get confused when to use A and when CNAME. With A record, the hostname is resolved to the corresponding IP address. On the other hand, CNAME records map your hostname to another hostname.

CNAME record VS ALIAS record

The CNAME record maps a name to another name and it should only be used when there are no other records on that name. The ALIAS record also maps a name to another name, but can coexist with other records on that name. ALIAS records can also be added for the root domain.

CNAME record VS TXT record

TXT records and CNAME records fulfill different DNS functions. While TXT records are used for storing text-based data, such as a description of a domain or a string of characters, CNAME records are used to map a domain name or subdomain to another hostname. This allows you to easily redirect to a new host without altering any existing records. In addition, TXT records have become popular for enforcing Domain-based Message Authentication, Reporting, and Conformance (DMARC) compliance to protect domains from malicious activities such as phishing and spoofing.

DKIM and CNAME

Setting up DKIM records often involves creating CNAME records, especially when using third-party email services. These services typically require CNAME records for domain validation and DKIM configuration to ensure the authenticity and integrity of email communications.

Example Integration:

  • Domain Validation: To verify domain ownership, a third-party email service may ask you to add a CNAME record to your DNS settings. This CNAME record points to a specific target provided by the service, confirming that you control the domain.
  • DKIM Configuration: The service then provides a DKIM public key in the form of a CNAME record. This CNAME record directs DNS queries to the service's DKIM public key infrastructure. For instance, instead of adding a long TXT record with the DKIM key directly, you add a CNAME record like selector1._domainkey.yourdomain.com pointing to dkim.serviceprovider.com. This setup ensures that the public key is always up-to-date and managed centrally by the email service provider.

How to check my CNAME record?

You can check your CNAME records via the following DIG, Nslookup, and Host commands:

$ dig CNAME hostname.example.com

$ nslookup -type=CNAME hostname.example.com

$ host hostname.example.com

In case you prefer to use an online tool, you can check your CNAME record with ClouDNS Free DNS tool.

How to start managing CNAME records for your domain name?

  1. Open free trial account from here - free forever
  2. Verify your e-mail address
  3. Log into your control panel
  4. Create new Master DNS from the [add new] button - read more here
  5. Add the CNAME record(s) you need as it is described in this article

Support of CNAME records

ClouDNS provides full support for CNAME records for all our DNS services, including the listed below. Just write to our technical support, if you need any assistance with your CNAME records configuration. Our Technical Support team is online for you 24/7 via live chat and tickets.

What is CNAME Flattening? 

CNAME flattening is a DNS technique that improves the resolution of CNAME records by pre-resolving them to their final IP addresses. Instead of requiring multiple lookups to follow a chain of CNAME records to an A or AAAA record, the DNS provider returns the IP address directly. This reduces latency and speeds up the DNS resolution process, resulting in faster website load times and enhanced performance.

This method is particularly useful for root domains (apex domains) where traditional CNAME records can't be used. In ClouDNS, this process is implemented using ALIAS records. By using CNAME flattening or ALIAS records, domain owners can achieve more efficient and reliable DNS management, ensuring quicker access and better reliability for their online services.

FAQ

Question: What is the main purpose of the CNAME record?

Answer: In a nutshell, it redirects from your domain’s subdomains to other domains/subdomains.

Question: Why there can't be a CNAME record for the root domain?

Answer: According to RFC 1912 2.4, a CNAME record is not allowed to coexist with any other data. And since there are other data for the root domain (e.g. SOA records, NS records, etc.), a CNAME record cannot be added for the root. For such cases, we recommend using the ALIAS record, which is a replacement of CNAME and it can coexist with other data (it can be created for root domain).

Question: Can I use more than one CNAME record for the same host?

Answer: No, because of the same reason we stated above, there can be only one CNAME record the same host. 

Question:  Can CNAME records be used to point to an IP address? 

Answer: No, CNAME records can only point to a hostname or another CNAME record.

Question: How often can I change a CNAME record?

Answer: CNAME records can be modified as frequently as needed, but keep in mind that changes may take time to propagate across DNS servers due to caching mechanisms and TTL settings.

Question: How long does it take for CNAME record changes to take effect?

A: DNS propagation times vary, but it generally takes anywhere from a few minutes to 48 hours for changes to CNAME records to propagate across DNS servers globally. The Time-to-Live (TTL) value associated with the record influences this duration.

 

Last modified: 2024-09-24
Cookies help us deliver our services. By using our services, you agree to our use of cookies. Learn more