CNAME vs A record, they are not serving the same purpose! Pay attention and know when to use them. The first will directly show which is the true domain name. It will point to there, and you don’t have to put more DNS records inside that zone. The other will indicate the address of a domain name.
What is the CNAME record?
The CNAME is the canonical DNS record. It shows that one domain or subdomain (hostname) is just another way to say the main domain (hostname) or also known as the canonical domain. Although you can use the CNAME with various results for different purposes, the right way of using it is only for subdomains like www.domain.com to link to domain.com or subdomain.domain.com to link to domain.com.
Remember that having a CNAME DNS record already created in a zone will block your chance to add any other DNS record for that zone. If you want to have similar action, pointing one hostname to another, but still be able to add more records, like, for example, MX records, you will need to use the ALIAS records for that purpose.
Example of a CNAME record:
- Host: www.domain.com
- Type: CNAME
- Points to: domain.com
- TTL: 1 Hour.
What is the purpose of the CNAME record?
The CNAME record has a very simple purpose – to show that a subdomain is just a part of a domain name. To direct to the domain name and its Master zone. That way, for your subdomain, you only need a CNAME record, and everything else that somebody needs will be taken from the domain name’s zone. That simplifies the management of the DNS and allows you to have fewer DNS records. You point once the subdomain to the domain. Then you can manage everything from the zone of the domain.
What is A record?
The A record is the easiest DNS record to understand. It points a domain name (hostname) to an IPv4 address. It is one of the first things that you will add to your Master zone. You will need A or AAAA records if you want your domain to be accessible.
Example of A story:
- Host: domain.com
- Type: A
- Points to: 22.214.171.124
- TTL: 1 Hour.
What is the purpose of the A record?
The purpose of the A record is very simple: when somebody inputs a domain name and wants to find its IPv4 address, they must get the A record. Inside the A record, you have that link between the name of the host and its IPv4 address.
CNAME vs A record?
So why are we even talking about CNAME vs A record? People still get confused with the use of the two. Remember this simple idea. The CNAME connects one subdomain to the domain or another subdomain (hostname to hostname), and the A record connects one domain name to an IP address (hostname to IPv4 address).
The CNAME can’t coexist with any other records, including other CNAME records.
The A record can coexist with almost all other DNS records, and it can coexist with other A or AAAA records in the same zone. Multiple records could be used for redundancy and load balancing.