What is a CNAME Record?

What is a CNAME Record?

We’ve previously talked about how the Domain Name System (DNS) works, but this isn’t the whole picture. There are lots of additional cogs that make up the wheel, and so far we haven’t discussed some of the most common elements, such as CNAME records.

For this article, we’ll answer the question of what a CNAME record is, and show you several variants that you can use. Then we’ll talk about the limitations you’ll experience, and finally show you how to add them for your domain.

Let’s get to it!

What Is a CNAME Record?

At its core, the DNS works by mapping domain names to specific IP addresses. When you type a URL in your browser, it looks up the corresponding IP address through the DNS and leads you to the website you want to visit.

However, this is just one type of record the DNS uses. With CNAME records, you can map URLs as aliases to your canonical domain. This means if the IP address mapped to that canonical domain changes, your CNAME records will still work because they point to the root domain.

To offer a real-world example, let’s say you have these three URLs:

  1. yourwebsite.com
  2. www.yourwebsite.com
  3. yourwebsite.io

URL number one would be your site’s canonical domain, which points towards your site’s IP address. In practice, you’d need to set up a CNAME record that redirects www.yourwebsite.com visitors towards yourwebsite.com.

At the same time, we also have the same name registered using a different Top-Level Domain (TLD). This means you’d want to create a second record that redirects address three towards number one. All of that usually happens through your domain registrar or whichever service you use to manage the URLs that you “own”.

2 Examples of CNAME Records

In fact, CNAME entries come in many shapes and sizes. However, in most cases you’ll only need to set up one CNAME record for a new website – typified by the www example we just mentioned.

In a later section, we’re going to show you how to set up a similar record through your registrar. First, let’s go over three more examples in closer detail.

1. Setting Up Separate Hostnames for Services Such as File Transfer Protocol (FTP) or Email

If you want to access your website via FTP using a domain such as ftp.yourwebsite.com, you’ll need to set up a corresponding FTP CNAME record:

This same approach applies to CNAME records for additional services that you use, such as email. Here, you’d want to set a “hostname” such as “mail” instead:

Creating a mail CNAME record.

Those records would correspond to the following two URLs:

  1. ftp.yourdomain.com
  2. mail.yourdomain.com

With most registrars, you can either enter the full hostname (those two URLs you see above) or an abbreviation such as wwwftp, and mail.

2. Pointing Addresses With Different TLDs Towards a “Main” Domain

In some cases, it pays off to register the same domain name using different TLDs. For example, you can set up a CNAME record for yourdomain.org that points towards yourdomain.com. Here’s how the record would look:

Configuring a new CNAME record.

It’s important to understand that you need to add this type of CNAME record to the domain you want to point towards a different URL. In other words, you can’t point a root level domain towards another using a CNAME record. Root domains, such as yourdomain.com need to be mapped towards an IP address.

Using this same approach, you can map entirely different domains to a root URL. Let’s go over how the mapping process works, so you know where to start.

How to Add CNAME Records For Your Domain

Adding new CNAME records works largely the same with most registrars, although the interface that each one uses might be different. To show you how this works, we’re going to set up a basic record to point a www URL towards its canonical domain. For starters, you’ll want to open your domain’s settings through your registrar.

For example, if you’re using Namecheap, the registrar includes an Advanced DNS tab for each domain you own. Within the tab, you can add multiple types of records (there are more options beyond CNAME!).

In the example below, you can see an “A” record. This is a type of record that maps your canonical domain towards your site’s IP address.

An example of an A record.

To add a record, you’d need to click on ADD NEW RECORD and select CNAME Record under Record Type:

Adding a new CNAME record.

Under Host you need to enter the www prefix for this particular example. Now add your website’s canonical domain under Target:

Pointing a www URL towards a canonical URL.

Finally, there’s one last setting called TTL. This acronym stands for “Time to Live” and it tells your nameservers how often they should update your DNS records. As you might know, DNS records take some time to “propagate” and become accessible globally. The lower your TTL time is, the shorter the wait should be.

In most cases, we recommend leaving this setting to Automatic as DNS records usually propagate fast enough. For now, save your new record, which should appear under its A sibling:

A and CNAME records.

Keep in mind that you can set up multiple CNAME records depending on your needs. In the previous section, we explored multiple options, and all of them can be set up concurrently.

What you can’t do is set up records that direct the same domain towards different canonical URLs. This means you couldn’t set up two records pointing www.yourdomain.com towards yourdomain.com and alternatedomain.com. If you’re setting up a new website, most times you’ll only need to create two records for everything to work. Those would be one A and one CNAME record.


CNAME records are a core component of the DNS. If you need to point domains towards one another (instead of towards an IP address), you’ll need to use CNAME records.

There are several uses for CNAME records, but two of the most common uses include:

  1. Setting up separate hostnames for services such as FTP or email.
  2. Pointing addresses with different TLDs towards a “main” domain.

Do you have any questions about how to use CNAME records? Let’s talk about them in the comment section below!

Article thumbnail image by DiA99 / shutterstock.com

Leave a Comment