When you start working with a website, there a few items that may often scare people off because the terms may seem too technical. DNS records, especially A records and CNAME records are perfect examples of this. You have the ability to make changes to DNS records in cPanel for most InMotion Hosting web site solutions. The exception being those that do not use cPanel for the webserver interface. This article explains the basic concepts of an A record in comparison to a CNAME record.
Just getting started with a website? Do you need a budget solution that provides performance, capability, and the ability to scale up as you business grows? Look no further than InMotion’s Business Shared Hosting solutions!
What is an A record?
The A in “A record” simply stands for address. This is because this particular DNS record is nothing more than IP address. The IP address points to the server location. Here’s an example of how the DNS record would appear:
example.com. A 188.8.131.529
Why would you use more than one A record? There are multiple reasons. For example, your mail server may not be at the same IP address, but it’s using your domain name in some form. In that case, you would need to indicate the location of the mail server by an A record. Here’s an example:
mail.example.com. A 999.432.10.123
You may also have subdomains for a blog or eCommerce website for which you need to specify an IP address . This can all be done by using an A record.
What is a CNAME record?
CNAME stands for “Canonical Name.” This record is just another name for other CNAME records or A records defined for your domain. Or, to explain it in simpler terms, it is an alias.
Before responsively designed websites were in vogue, it was very popular to create a mobile version of the website in addition to the main website. However, the practice of using responsive design made it unnecessary to have two sets of code. If you have one website with two names, it’s best to simply use a CNAME to make one name resolve to the other. Here’s an example of how the record would appear:
mobi.example.com. CNAME example.com.
CNAME records point to another name. That name could an A record, or it could be another CNAME. CNAME records are often used to simplify something that is otherwise more complex or simply very long. They’re also used when a name changes and you still want the other name to be valid. For example:
blog.examp.com. CNAME simontalksalot.examp.com.
Here, you can see that the new CNAME record (at left) shortens the old name of the site. The old site name can also be a CNAME that points to an A record like this:
simontalksalot.examp.com. A 123.345.67.890
If both records were saved together then blog.examp.com would resolve to the IP assigned to the A record of simontalksalot.examp.com – 123.345.67.890. CNAME records can be assigned to either another CNAME record or A record.
When to use an A record or CNAME
An A record should always be used to indicate the server address of a particular resource or your web server. For example, your domain name may be examp.com and it is assigned by your web host service to the web server address of 3184.108.40.2066. Your resulting DNS record would simply be:
examp.com. A 3220.127.116.116
Mail server records (MX) can also point to an IP address. If the mail server were at a different IP address, then it would look like this:
mx.examp.com. A 318.104.22.1686
A common CNAME is the one that represents the use of WWW for your domain. This allows the use of WWW in front of the domain name so that it properly resolves to the domain name.
www.examp.com. CNAME examp.com.
If you created a separate eCommerce website installation on the same server and it resolves to the same primary domain name, then it may look like this:
shop.examp.com. CNAME examp.com.
You will not want to use CNAME records excessively as they do have to be resolved at the DNS server. This can result in slight performance issues. Resources like mail servers should also be assigned only to an A record to identify the location of the server.
On the other hand, CNAME records can be useful when you have several versions of a website name and you want to re-direct them to your main domain name. This is handy when you have different URLs for different countries. You may also have multiple names that you want to resolve to your domain name. These examples are well-suited for using a CNAME record.
Congratulations! You’ve completed our tutorial on the A record versus the CNAME record and how to use them. If you wish to continue learning more about DNS, please see our DNS and Nameserver Changes articles.