What is the difference between A and CNAME Records in Domain Name System?

DNS records guides the web server to an IP address when a user requests a domain. In other words, they tell the DNS server which domain name is mapped to which value or (IP address). Various record types are used to perform different actions on DNS servers which are A, AAAA, CNAME, MX, PTR, NS, SOA, SRV, TXT, and NAPTR. In this blog, we will discuss the widely used records A and CNAME.

A Record: It stand’s for ‘address’ in DNS records. It is the most basic address as it map’s the domain name to a specific IP address a.k.a. Value. For example, I want to map youvcode.com to map to address. The entry will look like below:

Type Name Value TTL
youvcode.com Automatic

CNAME Record: It stand’s for ‘canonical name’. It is used to point one name to other name instead of an IP address. CNAME is mostly used to redirect to the main domain or associate new sub domains with an existing domain’s DNS record. For example, people commonly use the alias http://www.youvcode.com and can be transferred to https://youvcode.com using the CNAME record as shown below:

Type Name Value TTL
www youvcode.com Automatic

Now when http://www.youvcode.com is searched by a user the DNS server will point to youvcode.com which in return will point to the address CNAME records can also be used to register a domain in several different countries and then redirect all of them to the main domain.

Limitations of CNAME: 
(1) Use of CNAME can adds a delay of few milliseconds because it adds an extra mapping.
(2) One can never create a CNAME of the main domain name like CNAME – youvcode.com
(3) MX or NS (name server) records will only point towards A records and not CNAME records.

Join Discussion

This site uses Akismet to reduce spam. Learn how your comment data is processed.