What is a CNAME and an A Record?
A CNAME - long form a Canonical Name - is a form of alias used in Domain Name Systems (DNS). Its function is to map to the main base domain name (known as the A record).
As an example, say you have a website selling horse riding gear. You will pick an easy to remember main domain name - such as ilikehorses.com - and receive an associated IP address. Then, you are good to go.
However, in practice it is not so straightforward. Users may search for terms such as www.ilikehorses.com or simply ilikehorses. If you have not established and linked these potential aliases to your main domain, you may fail to generate valuable traffic to your site. So, you’ll need a way to efficiently map these alternative “alias” names to your main domain.
That’s where a CNAME comes in. A CNAME is an alias or alternative name for the main domain - a “sub-name” if you wish.
These sub-names should be categorized and registered as CNAMES that link back to the A record hostname (main domain). As a result, websites usually end up with several sub domains (CNAMES) - for example ftp.ilikehorses.com or mail.ilikehorses.com.
Since websites are actually serviced through an IP address - a long code of numbers - the domain (A Record) name is a more “easy to remember” way to access the required website.
The CNAME however exists as a pointer to the main domain name (A Record) - not to the IP address. When a user enters a domain name, the browser will use a DNS to identify the correct IP address in a master database.
As we already alluded, the A Record is usually the main domain name - in this example ilikehorses.com. The A Record should map directly to the IP address for the website, and the associated CNAMES should map to the A Record.
Domain or Sub Domain | Type | Lookup destination |
---|---|---|
ilikehorses.com | A Record | 333.222.111.444 (IP address) |
ftp.ilikehorses.com | CNAME | ilikehorses.com |
mail.ilikehorses.com | CNAME | ilikehorses.com |
What is the difference between a CNAME and an A Record?
In a nutshell - as we have just learned above - the A Record maps directly to the IP address of a particular website. The CNAME is then used to link different variants of the same website name to the A Record. The main purpose of either is to directly or indirectly map any entry a user makes to the IP address. Here are some of the key differences to note:
A Record | CNAME |
---|---|
Matches to an IP address | Maps to a name |
Can be a main domain name | Cannot be a main domain name |
Also known as an Actual Record | Also known as Alias Records, Canonical Name |
Necessary as a minimum | Not necessary, but very useful for maintaining accessibility |
Top tips for using the differences between CNAME and A Record set up to maximize success
1) If you do one thing, and one thing only, then it has to be the setup of the A Record. This is the minimum base requirement for your website.
2) However, even if you only have a site with one page, you will most likely benefit from creating a CNAME record for the www. Alias (ilovehorses.com being the A record, www.ilovehorses.com being the CNAME)
3) Best practice however would be to register a number of alias CNAMES so you cover more than one alternative.
4) Don’t make the mistake of confusing a CNAME and an A Record. You cannot map a CNAME directly to an IP address - it must go via the A Record. So, start with an A Record and build from there.
5) You can also use CNAMEs cleverly when going for world domination. Register your domain in multiple countries and use CNAMEs to link them back to the main domain (usually, it’s a .com domain)
6) Domain mapping through CNAMEs are also useful for companies - usually larger ones - that have ended up with a bunch of websites either through acquisition or poor marketing control. These multiple and inconsistent sites can be linked via CNAMEs to the main and more centralized corporate site
Conclusion
The CNAME and A Record functions are similar - but do not make the mistake of thinking they are interchangeable.