What is the difference between CNAME and A records, and when should they be used? This tutorial is designed to clear up some of the confusion around the differences between CNAME and A (address) records.
Websites are served from locations that are uniquely identified by a group of numbers, which are known as IP addresses; but to access these sites we usually type in their corresponding domain names, which are easier to remember. To find the correct IP address, your browser will contact a Domain Name Server (DNS) and query its database for the IP address.
CNAME and A records
What is an A Record?
An A record is a record in these Domain Name Servers that links or maps a domain directly to its corresponding IP address.
For example, when you type mydomain.com into your browser, your browser will perform a DNS lookup which will return the corresponding IP address eg. 111.222.333.444. Mass Illusions IP for all hosts (Including reseller domains) is: 188.8.131.52.
Whas is a CNAME Record?
A CNAME, or Canonical Name record, is a record that points to another domain address rather than an IP address.
For example, say you have several subdomains, like www.mydomain.com, ftp.mydomain.com, mail.mydomain.com etc and you want these sub domains to point to your main domain name mydomain.com. Instead of creating A records for each sub-domain and binding it to the IP address of your domain you can create CNAME records.
As you can see in the table below, in the case where the IP address of your server changes, you only need to update one A record and all the subdomains follow automatically because all the CNAMES point to the main domain with the A record:
|(sub)Domain / Hostname
||Target / Destination
Examples of using CNAME records:
Domains registered in different countries
CNAME records can also be handy in the case that you registered your domain name in several countries and you want to redirect them all to your main domain. For example mydomain.com.au and/or mydomain.co.nz can be redirected to mydomain.com
Products and brand names
In case you have registered several domain names, for example for your different products or brand names and you want to redirect them all to your main domain, you create CNAME records for all these other domains. For example: myproduct.com > mydomain.com.
Limitations of CNAME records
- Usage of CNAME records means that there is an additional request sent to the DNS servers, which can cause a delay of a few milliseconds.
- You cannot create a CNAME record for the main domain name (mydomain.com) itself, this must be an A record.
For example, you cannot map mydomain.com to google.com, however, you can map google.mydomain.com to google.com.
- MX or NS (nameserver) records may never point to a CNAME record, only A records.