Differences between the A, CNAME, ALIAS and URL records
URL records are all possible solutions to point a host name (name hereafter) to your site. However, they have some small differences that affect how the client will reach your site.
Before going further into the details, it’s important to know that
CNAME records are standard DNS records, whilst
URL records are custom DNS records provided by DNSimple’s DNS hosting. Both of them are translated internally into
A records to ensure compatibility with the DNS protocol.
Understanding the differences
Here’s the main differences:
Arecord maps a name to one or more IP addresses, when the IP are known and stable.
CNAMErecord maps a name to another name. It should only be used when there are no other records on that name.
ALIASrecord maps a name to another name, but in turns it can coexist with other records on that name.
URLrecord redirects the name to the target name using the HTTP 301 status code.
Some important rules to keep in mind:
ALIASrecords causes a name to resolve to an IP. Vice-versa, the
URLrecord redirects the name to a destination. The
URLrecord is simple and effective way to apply a redirect for a name to another name, for example to redirect
Aname must resolve to an IP, the
ALIASrecord must point to a name.
Which one to use
Understanding the difference between the
A name and the
CNAME records will help you to decide.
The general rule is:
- use an
Arecord if you manage what IP addresses are assigned to a particular machine or if the IP are fixed (this is the most common case)
- use a
CNAMErecord if you want to alias a name to another name, and you don’t need other records (such as
MXrecords for emails) for the same name
- use an
ALIASrecord if you are trying to alias the root domain (apex zone) or if you need other records for the same name
- use the
URLrecord if you want the name to redirect (change address) instead of resolving to a destination.
You should never use a CNAME record for your root domain name (i.e. example.com).