What is the difference between DNS A record and CNAME record ?

A record

  • It is the Address records also known as host records
  • Points to the IP address reflecting the domain
  • Used for forward lookup of any domain name

For example:
Our website is configured on 50.63.202.15 IP so the A record of my domain name will point towards that IP.

Every time a query for golinuxhub.com is made the internet will lookup for contents stored on the machine with 50.63.202.15 this IP.

Can I use multiple A records for a single domain?
Yes, there can be multiple A records for a single domain but only that is not going to help you with failover in case you are planning for one. Using multiple A records for a single domain will help you create a round robin configuration.

For example you have used two IPs 192.168.0.1 and 192.168.0.2 for same domain name example.com so when a user hits the lookup query for example.com, the query would land on your nameservers. Now there the query can pick any of the A record entry and will load the page. So, basically the back end user does not gets to know the server from which the website was picked and loaded. There might be a possibility that simultaneously if another request is made for the same domain, another A record might be picked up for different user.

CNAME Record

  • It is short abbreviation for Canonical Name
  • Provides an alias name for same hostname
  • Helps create subdomains

NOTE: You can not create a CNAME record for the domain name itself (it should be done with A record)

For example:
golinuxhub.com is a domain name whereas www.golinuxhub.com is a sub domain name

Example using A records and CNAME records
                 IN  NS example.com.
example.com.     IN  A 192.168.0.100

www.example.com  IN CNAME example.com.
ftp.example.com  IN CNAME example.com.
test.example.com IN CNAME example.com.
In the above example I have defined the nameserver for my machine and the A record determines the IP address pointing to the name server

Also I have used CNAME record to use multiple sub domain names for the same nameserver i.e. www, ftp, test etc