What Are CNAME Records and How Do You Use Them?
Today I’ll be showing you how and why to configure the CNAME records for your domains. Let’s begin!
What Are CNAME Records?
CNAME stands for canonical name, and its primary purpose is to alias or redirect one domain name to another.
For example, say you store your documents on your own server and domain name. Perhaps you already have this configured as a subdomain:
This subdomain is all well and good, but it’s a bit wordy. Yes, you could just change the subdomain, but what if you can’t? What if you have to keep the long and difficult to remember subdomain, but you want to make it easier to remember? By using a CNAME record you could setup a redirect so that all you have to remember is:
This is performed by the domain name system (DNS), so even if you don’t have a web hosting provider yet, you can still (usually) configure these records.
Domain redirects aren’t just restricted to the same domain. I use CNAME records to redirect my personal website to my YouTube channel. If you can access it in a browser, you can redirect to it.
It’s possible to configure an almost unlimited number of CNAME records — just make sure you don’t accidentally set up a Redirect loop — redirecting your user to a page which then redirects them straight back and the cycle repeats infinitely!
Components of a CNAME Record
CNAME records consist of two main parts:
- Hostname: This is the source address. This can be an existing domain or sub domain name, or it can be a new one, which does not exist yet.
- Destination: This is where you want to route traffic to. As mentioned above, this can be anywhere: another domain, a different part of your website, and more.
They really are that simple. In fact, CNAMES might just be one the simplest aspects of configuring DNS for your website.
How to Change a CNAME Record
Adding or changing your CNAME records is a very easy process.
First, login to your domain control panel. This will nearly always be the company you purchased your domain from (unless your domain is managed by a third party).
Once into your control panel, you need to find the Manage DNS page, or words to that effect. This can vary by provider, but it will usually be under Domain Name Management.
Once inside the Manage DNS page, ensure you select the domain you wish to manage. If you only own one domain name, it will be the only domain name visible here.
Many providers will provide you with a Basic DNS for a simpler experience, along with Advanced DNS, for more in-depth (albeit more complex) control.
While basic DNS management pages can be helpful for more complex DNS tasks, CNAME records are so simple that even an advanced control panel will be very similar to a basic one. Choose whichever you feel most comfortable with.
Your DNS control panel may look something like this:
A simple table lists all the current DNS records. There are various buttons to add, edit, and delete records. Find the place to add new records, which is at the bottom with my provider (it may be somewhere different for you).
Start with the Hostname. This is the domain or subdomain you wish to redirect. Make sure this is fully qualified — in other words, ensure it is a domain or subdomain linked to your account. You can’t redirect google.com!
Next, change the Type to CNAME. There may be various options in the type selector, most of which are for more complex DNS tasks.
Finally, enter your destination IP address . It’s uncommon to enter a URL here, but it might be possible depending on your provider.
These IP addresses will nearly always be required in IPv4 format (instead of IPv6), and if you’re not sure of the differences, then make sure you read our IPv4 vs. IPv6 comparison .
Finally, press Add and you’re done!
If you made a mistake or changed your mind, it’s easy to delete or modify CNAME records using the tools in this DNS management page. Simply press the appropriate Delete or Edit buttons.
Final Things to Consider
While changing CNAME records is a fairly straightforward process, there are a few things that may trip you up.
The first is propagation. Put simply, whenever you alter a record, it make take a small period of time before your change actually works. Normally this will be between one and 24 hours, but it’s usually on the faster side.
Similarly, if you have visited your redirect, and now changed it, your web browser may be caching the old result, meaning everyone can see the change, apart from you! Clearing your cache will usually solve this problem, and it’s easy to clear your cache in Google Chrome .
Finally, one last word of warning. Redirecting domains with CNAME records can be slow in terms of server performance. What this means is it may take a small amount of time between visiting the domain or subdomain, and getting redirected to the new website. Fortunately, this is unlikely to be a real issue unless you have millions of visitors a day, or are redirecting hundreds of thousands of subdomains. Still, it’s something to be aware of.
Have you learnt any new tricks today? Have you used CNAME records in the past? Let us know in the comments!