What is a CNAME record?
The CNAME record is one of the most common DNS records, and its main purpose is to point one hostname to another. The short acronym CNAME represents with “C” – canonical and with “NAME” – hostname. With this DNS record, the administrator is able to show the actual true canonical domain name.
In the majority of the cases, this DNS record is used for pointing multiple subdomains to the domain name. As a result, the administrator is not required to make any further adjustments for the subdomains. All of them are automatically redirected to the domain name. Thanks to this single DNS record, the management of your domain is becoming way more simple and easier for the DNS administrator.
Some illustrations of how you can use CNAME record:
www.example.com to example.com
blog.example.com to example.com
mail.example.com to example.com
Due to the fact that CNAME works in a very specific way, it has a limitation. When you create it and add it to a particular DNS zone, you won’t be able to create any other additional DNS records.
Structure of the CNAME record
The CNAME record has an easy-to-understand structure. It is represented in an easy text file, which contains several things:
Host: Here, you should place a hostname. More precisely, the subdomain you want to direct to the true domain name. For instance: blog.example.com
Type: Here is the type of DNS record. In our case, that is CNAME.
Points to: Here, you should place the actual canonical domain name. You could create multiple CNAME records for all of your subdomains and point them to the canonical one.
TTL: The TTL (Time-to-live) value is a period of time. It shows for how long the DNS record will be stored in the cache memory on the recursive DNS server.
How to check your CNAME record?
If you want to check and see your CNAME records, we have several commands that are going to help you achieve this easy task.
- The first one is the Dig command. You just have to type the following:
$ dig CNAME blog.example.com
- The second one is the Nslookup command. You just have to write the following:
$ nslookup -type=CNAME blog.example.com
- Lastly, you could use the Host command by simply typing the following:
$ host blog.example.com
When can you use it?
- The most popular way to use the CNAME record is to point your standard subdomains or subdomains for services, such as FTP or email, to the primary hostname (domain name).
- You can use it for Content Delivery Networks (CDN). That way, you could balance the traffic efficiently.
- Another common way for implementing the CNAME record is when a particular company has multiple websites. The DNS administrator could create and add several CNAME records and point them just to a single hostname – the actual domain name.
- This DNS record is beneficial if you hold .de, .it, .eu, and more registered domains. The DNS administrator could merge them and establish a single location, such as .com.