Hosting Industry News & Blog

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

Date: 21 March 2022
Author: harry

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

 

Related Products

Newsletter Signup

Signup to our hosting newsletter, to keep up to date with all the latest hosting news, special offer and updates from Hosting Australia.

Related Posts

Hosting Australia Newsletter

Don't miss out on the latest news and
special offers from Hosting Australia.

Sign up today!