Home » How-Tos » Learning and Resources » Understanding CNAME Records: Meaning, Their Uses, and Key Differences with A Records
A CNAME or canonical name record is a type of DNS record that allows a domain to alias another, directing traffic to an existing domain rather than assigning a new IP address. While CNAME records differ from A records (used to point a domain to an IP address directly), they are mostly used in two contexts:
- To create a subdomain that directs to a different server
- To send visitors from one domain to an alias or subdomain
In this article, we will discuss CNAME records, its components, uses, and the best practices to follow when using this DNS record.
What is a CNAME Record?
A CNAME record is a DNS setting that allows one domain to point to another. Instead of linking directly to an IP address, it links a subdomain (like blog.domain.com) to the main domain (domain.com), which holds the actual IP address. This makes it easier to manage multiple subdomains under one primary domain.
Components of a CNAME Record
Here is a table with a few examples of a CNAME record:
|
Hostname |
Record Type | Value |
TTL |
|
blog.example.com |
CNAME | Blogalias.com | 3600 seconds |
| shop.example.com | CNAME | yourstorename.myshopify.com |
3600 seconds |
Let us look at these components in detail:
Hostname:
A domain name that directs network requests to the appropriate device or server. Beyond accessing websites, a hostname can also be used to access email and FTP servers or other network-connected devices.
Record Type:
The record type for a CNAME query is always set as CNAME, making it easier for the DNS resolvers to follow the alias to the target.
Value:
The destination when the DNS resolver redirects the hostname’s queries. For instance, if you must link your Shopify shopping page for your website, you must add a CNAME record with the unique value “yourstorename.myshopify.com.”
Time to Live (TTL):
The duration that DNS resolvers cache the record before checking for updates. For example, a TTL of 3600 seconds (about 2 hours) means the record will be cached for one hour.
Uses of CNAME Records
Here are some common uses of CNAME records:
-
Connecting multiple websites:
You can use CNAME records to connect multiple websites you own to a primary domain. This provides a seamless navigation experience for visitors while consolidating your brand identity.
-
Network services:
Efficiently manage services like FTP, email, or other protocols by pointing specific hostnames to the root domain, ensuring smooth operations.
-
Internationalization:
Simplify international operations by registering the same domain in different countries and redirecting each to the main domain, fostering a consistent global presence.
-
Domain Consolidation:
Using CNAME records, companies can redirect multiple websites they own to a primary domain. This approach simplifies user navigation, strengthens brand identity, and reduces maintenance efforts by centralizing web traffic under a single domain.
How to Add CNAME Record for Your Domain
Here is a step-by-step guide on how to add a CNAME record to your domain:
- Log into your account and navigate to your list of purchases.
- Select the domain you want to edit the CNAME records.
- Go to the DNS management section at the right of the page. Then, click on “Manage DNS.”
- Select the “CNAME record tab” and add a new CNAME record.
- Start by entering the hostname. Then, click on the second radio button to enter the record value.
- Keep the TTL value unchanged, then click “Add Record.” That is it. You have successfully added a CNAME record.
After making changes, allow a couple of hours for DNS propagation to reflect.
Best Practices for Working with CNAME Records
Creating CNAME records requires a strategic approach to avoid misconfigurations that could disrupt online services. You can follow these best practices to create and manage CNAME records:
1. Verify Record Compatibility:
Ensure that the CNAME record aligns with your intended use case and the services you plan to integrate. For example, when using a CDN, contact the CDN provider to get the correct CNAME value for your record. Different services may have unique requirements and limitations, so consult the service provider and your DNS host’s support team for guidance to avoid errors and ensure a smooth configuration process.
2. TTL Management:
Time to live (TTL) defines how long a DNS record remains cached in a network before being refreshed. For CNAME records, setting the right TTL is essential for balancing update speed and server load. A lower TTL ensures quicker updates but may increase DNS queries. Therefore, when setting up a CNAME record, ensure the correct TTL value is entered.
3. Avoid CNAME Chains:
Limiting multiple CNAME records in a sequence helps reduce delays in DNS resolution and minimizes the risk of disruptions. Each extra CNAME lookup adds latency and increases potential failure points, leading to slower website performance and user experience issues. For instance, if “sales.example.com” points to “marketing.example.com,” which then points to “offers.example.com,” the chain introduces delays. It is better to point “sales.example.com” directly to “offers.example.com” to streamline resolution and enhance efficiency.
4. Perform Record Testing:
To ensure your CNAME record functions properly, test its setup by verifying that it resolves to the correct destination. You can use DNS lookup tools or online services to check the accuracy of the record and ensure that traffic is appropriately redirected. Regular testing helps confirm the functionality and avoids issues with incorrect or outdated configurations.
Understanding the Difference Between CNAME Record and A and Alias Record
CNAME records map a hostname to another hostname, while A records map a hostname directly to IP addresses. Alias records are like CNAME but allow other DNS records on the same hostname and return an IP address, improving performance. Here is a table to make it easy for you to understand the difference between them:
|
Features |
CNAME Record | A Record | Alias Record |
|
Purpose |
Maps a hostname to another hostname. | Maps a hostname to one or more IP addresses. |
Maps a hostname to another hostname. |
|
Resolution |
Resolves to another hostname. | Resolves directly to an IP address. |
Directly returns an IP address without hostname lookup. |
|
DNS Records on Hostname |
Cannot have other DNS records on the same hostname. | Can have multiple records associated with a hostname. |
Allows other DNS records. |
|
Performance |
Slower requires additional lookup for the target hostname. | aster, resolves directly to IP. |
Faster than CNAME, no additional lookup needed. |
Conclusion
In conclusion, CNAME records are an essential part of DNS, ensuring the smooth operation of a domain’s online infrastructure. Understanding their roles and interactions within the DNS system is crucial to creating and managing them.
Still confused or want to share something? Leave a comment below!







