December 10, 2024

ALIAS record vs CNAME record

Let’s compare these two DNS record types that have a similar purpose. Both redirect from one hostname to another, but they have more than a few differences in between. Let’s see what exactly distinguishes the ALIAS record and the CNAME record.

What is the ALIAS record?

ALIAS record links two hostnames, showing that one is just another way to write the other. It is not a standard DNS record type, and not all of the Managed DNS providers offer it. This record type can coexist with other DNS records, for example, MX records. A great thing about the ALIAS records is that they will save time and not only show the other hostname, but an ALIAS query will return the IP address. The only problem with ALIAS that might lead you to CNAME records is that it doesn’t work well with GeoDNS because it will show the IP address of the name server and won’t redirect to the best location. 

Why do you need an ALIAS record?

What is the CNAME record?

The CNAME DNS record is a way to indicate that one host has a real name and which is the canonical name. The purpose of CNAME is easier DNS management from a single point and no multiple DNS records for each subdomain. 

You don’t need to add an A or AAAA record for each subdomain. A typical case is subdomain www (www.domain.com), which leads to the root domain (domain.com). The CNAME works only for subdomains and can’t coexist with other DNS records in the same zone. It cannot lead to another domain name. 

The answer that you will get from a CNAME query is the FQDN (fully qualified domain name). The next step will be to perform another DNS query for the FQDN to get the A or AAAA record, and that will take an extra step and time.

CAA record explained

ALIAS record vs CNAME record

So, let’s see when the ALIAS record is better than the CNAME record and why in some cases, you will still need to use CNAME records:

  • Both ALIAS and CNAME records can point one hostname to another – for example, subdomain.domain.com to domain.com.
  • Both ALIAS and CNAME records can’t point one domain name to another. They are not Web Redirects. 
  • Both ALIAS and CNAME records can work well with a load balancer like Round-Robin.
  • ALIAS records can coexist with most other types of DNS records, including MX records. It can’t coexist with CNAME records or Web Redirects. On the other hand, CNAME can’t coexist with another DNS type of record for the same host.
  • ALIAS record can be added to the root domain while the CNAME can’t. This is one of the biggest advantages of the ALIAS record. 
  • ALIAS record can be faster than the CNAME because it will retrieve the A or AAAA records with the answer, and therefore the domain resolution is faster.
  • The ALIAS record is a newer type of record in comparison with the CNAME record. 
  • Not all DNS service providers support ALIAS record, while CNAME record is standard. 
  • ALIAS record doesn’t work with GeoDNS correctly. It will get back the address of the nameserver and not of the visitors, so the result won’t be the correct one.
  • Some DNS providers like Amazon, redirecting with ALIAS records, are free while redirecting with CNAME requires additional payment.

Recommended article: 4 most popular DNS records

Conclusion

Both ALIAS and CNAME records are similar but also different enough to continue to exist. Yes, ALIAS records have many benefits, but sometimes the good-old CNAME record is all you need.

Leave a Reply

Your email address will not be published. Required fields are marked *