We are going to explore one alternative to the CNAME record, which has many advantages – the ALIAS record. With it, you can have different DNS records in the same DNS zone and even put ALIAS records inside the root. Put ALIAS records where you can’t do it with CNAME records and manage your DNS easier.
The ALIAS record is one of the DNS record types which serves to connect one hostname to another. After that, it will resolve to A or AAAA record (an A to IPv4 address and an AAAA to IPv6 address) that already exists for the second hostname. ALIAS has the benefit of being allowed for the root domain, and you can put it in a DNS zone with other DNS records like MX records.
Benefits of using ALIAS DNS record
How to create an ALIAS record?
Create an ALIAS record is an easy, few-step process:
Inside a DNS hosting provider’s control panel.
- Log in to your account with your credential.
- Go to the Master zone, where you want to add it. If you don’t have a Master DNS zone yet, you should create one and add SOA, NS, A, and AAAA records.
- Check the control panel of your DNS provider and find Add Record or new Record. From there, you will have a list of DNS record types, and you should select ALIAS DNS record.
- Now the type of DNS record is already selected, so you need to add the other values like TTL (you can put 1 hour), Host (like www.exmaple.com), and direct it to the domain name (example.com).
You can use it for subdomains or the root domain.
Why should you use an ALIAS record?
- Use the ALIAS record because you can add it to the root of our domain. Something that CNAME fails to provide.
- Use ALIAS record because it can coexist with other types of DNS records*. *You can’t put ALIAS record in a zone with a CNAME record or Web Redirect record.
- Use it because it works with a Round-Robin load balancer.
- Use the ALIAS record because it is very easy to integrate with many APIs.
- Use it because it is faster than a CNAME. During the answer retrieving, it can also bring back A or AAAA records and resolve the domain. That will save time and make it more convenient for the clients.
It is a very easy process to add an ALIAS record, and it can function for many purposes. It does not completely cover what a CNAME can do, but it works in many ways. The CNAME is still a very useful record for easy DNS management of subdomains.
The only significant problem of the ALIAS record is that it will lose the Geodata, and it will give the IP address of the DNS authoritative nameserver for the zone. So you will miss from where exactly the query was made. It is a problem, but not for everybody. It depends a lot on your use case.