fbpx

DNS CNAME Record – What is it and how does it work?

Posted By: Harry Masson
Date Posted: 21/03/2022

A CNAME record is a DNS record that allows you to associate one name with another name. When you create a CNAME record, you can point your domain to another record — or alias — that has the same name as itself.

The purpose of the CNAME record is to provide a way for you to leverage a domain name (to which you have the rights) for purposes that you do not own. For example, you may have the rights to build a site on http://hosting-australia.com, but you do not own the name itself. You can create a CNAME record pointing the domain name to your domain. The name used for the CNAME record (e.g. http://au.hosting-australia.com) is the alias (or target) for the domain name.

A common misunderstanding is that a CNAME record must always resolve to the same website as the domain it points to, although this isn’t true. The CNAME record merely directs the client to the root domain’s IP address. The web server will still handle the URL properly once the client reaches that IP address. For example, au.hosting-australia.com might have a CNAME that links to hosting-australia.com, pointing the client to the IP address of hosting-australia.com. When the client connects to that IP address, the webserver checks the URL and sees that it is au.hosting-australia.com, thus the blog page is delivered instead of the home page.

Example of a CNAME record:

au.hosting-australia.com TTL Type value:
@ 3600 CNAME is an alias of au.hosting-australia.com

You can see that au.hosting-australia.com points to hosting-australia.com in this case, and assuming that it is based on our example, We know that the IP address 151.139.128.10 will eventually resolve to a record.

Is it possible for a CNAME record to point to another CNAME record?

It’s impractical to point a CNAME record to another CNAME record because it needs numerous DNS lookups before the domain can be loaded, slowing down the user experience, but it’s feasible. For example, au.hosting-australia.com may have a CNAME record that linked to www.hosting-australia.com‘s CNAME record, which then pointed to the A record for hosting-australia.com.

CNAME for au.hosting-australia.com:

au.hosting-australia.com TTL Type value:
@ 3600 CNAME is an alias of www.hosting-australia.com

Which points to a CNAME for www.hosting-australia.com:

This option adds a step to the DNS lookup process that should be avoided if at all possible. Instead, both au. hosting-australia.com and www. hosting-australia.com ‘s CNAME records should link to hosting-australia.com.

What are the constraints of using CNAME records?

MX and NS records must point to an A record (for IPv4) or a AAAA record instead of a CNAME record (for IPv6). A mail exchange record (MX record) is a record that routes messages to a certain mail server. An NS record is a ‘name server’ record that specifies which DNS server for a domain is authoritative.

How to find out your domain’s CNAME record?

Command Prompt

  • Open your Command Prompt or Terminal
  • Type “nslookup [domainname]” then press Enter.
  • The command prompt will display your the name (CNAME) record
Command Prompt CNAME Record

Command Prompt CNAME Record

 

If you need help ...

As always if you need extra support regarding the content in this article our team at Hosting Australia have a range of development and security services that can help your website perform better and protect it from attack ...

Don't risk your valuable business asset.
Get in contact with us to talk about security, backups, speed optimisations and more.

WordPress Website Design

Hosting Australia has a team of expert WordPress Designers, all based in Australia and ready to assist you with any task. From a ground up new site build, updating security or plugins, or just changing some minor details - we can assist with all aspects on your site.

Hit the button below to find our more and get in contact with our design team today.