What is a DNS CNAME record?

The ‘canonical name’ record is used instead of an A record. When a domain or subdomain is an alias of another domain.

A domain with a CNAME record is like a clue that can point you to another clue (another domain with a CNAME record) or to the treasure (a domain with an A record).

 For example, suppose www.olitt.com has a CNAME record with a value of ‘olitt.com’ (without the ‘www’). This means when a DNS server hits the DNS records for www.olitt.com, it actually triggers another DNS lookup to olitt.com, returning olitt.com’s IP address.

 In this case, we would say that olitt.com is the canonical name (or true name) of blog.olitt.com.

NB: All CNAME records must point to a domain, never to an IP address.

Oftentimes, when sites have subdomains such as blog.example.com or shop.example.com, those subdomains will have CNAME records that point to a root domain (example.com). 

This way if the IP of the host changes, only the DNS A record for the root domain needs to be updated and all the CNAME records will follow along with whatever changes are made to the root.

A frequent misconception is that a CNAME record must always resolve to the same website as the domain it points to, but this is not the case. The CNAME record only points the client to the same IP address as the root domain. Once the client hits that IP address, the webserver will still handle the URL accordingly.

 So for instance, blog.example.com might have a CNAME that points to example.com, directing the client to example.com’s IP address. But when the client actually connects to that IP address, the webserver will look at the URL, see that it’s blog.example.com, and deliver the blog page rather than the home page.

Example of a CNAME record:

Was this article helpful?

Related Articles

Leave A Comment?