Blockchain

What is the difference between ALIAS and CNAME and when to use them?

The main difference between CNAME records and ALIAS records is not the results (they both point to different DNS records), but how the target DNS record is resolved when querying. Because of these differences, one is safe to use in a zone apex (e.g. a primary domain like example.com), while the other is not.

Let’s start with the CNAME record type. This simply points a DNS name, such as www.example.com, to another DNS name, such as lb.example.net. This instructs the resolver to look for the answer in reference names for all DNS types (e.g. A, AAAA, MX, NS, SOA, etc.). This reduces performance because at least one additional DNS lookup must be performed to resolve the target (lb.example.net). If the recursive resolver has never queried both records before, it may traverse the entire DNS hierarchy for both records, which is much more expensive in terms of time.

  1. As a DNS client (or stub resolver), you query the recursive resolver for www.example.com.
  2. The recursive resolver queries the root name server for www.example.com.
  3. The root name servers refer to the recursive resolver as the .com top-level domain (TLD) authority server.
  4. The recursive resolver queries the .com TLD authority server for www.example.com.
  5. The .com TLD authoritative server references the recursive server as the authoritative server for example.com.
  6. The recursive resolver queries the authoritative server for www.example.com and receives lb.example.net in response.
  7. The recursive resolver caches the answer and returns it to the user.
  8. Now run a second query to the recursive resolver for lb.example.net.
  9. The recursive resolver queries the root name server for lb.example.net.
  10. The root name servers refer to the recursive resolver as a .net top-level domain (TLD) authority server.
  11. The recursive resolver queries the .net TLD authority server for lb.example.net.
  12. The .net TLD authoritative server refers to the recursive server as an authoritative server for example.net.
  13. The recursive resolver queries the authoritative server for lb.example.net and receives an IP address in response.
  14. The recursive resolver caches the answer and returns it to the user.

Each of these steps takes at least a few milliseconds, often more, depending on network conditions. This can result in significant amounts of time waiting for a final, actionable answer regarding your IP address.

For an ALIAS record, everything is the same as a CNAME, except that the authoritative server at example.com performs steps 6 through 13 and returns the final response as an IPv4 and IPv6 address. This offers two advantages and one significant disadvantage.

Advantages

Faster final answer resolution speed

In most cases, example.com’s authoritative servers have cached answers and can return answers very quickly.

Alias ​​responses are A and AAAA records. ALIAS records return an answer consisting of one or more IP addresses, so they can be used anywhere that A or AAAA records can be used, including Zone Apex. This is more flexible than CNAME, which cannot be used on area vertices. You need the flexibility of alias records when publishing your site to some of the most popular CDNs, which require the use of CNAME records if you want users to be able to access your site through your primary domain, such as example.com.

disadvantage

Geotargeting information has been lost.

Because it is the authoritative server for example.com that issues queries for lb.example.net, the intelligent routing feature for lb.example.net records works based on the location of the authoritative server rather than the user’s location. that much EDNS0 The edns-client-subnet option does not apply here. This means it could potentially be routed incorrectly. For example, if you are in New York and the authoritative server for example.com is in California, lb.example.com will believe you are in California and return the answer. It’s definitely the next best option for you in New York. However, if you use a DNS provider that provides pops globally, this problem is alleviated as the authoritative DNS servers are likely to be located in your region.

One important thing to note is that NS1 shrinks CNAME records if they are all included in the NS1 system. NS1’s nameserver is authoritative for both the CNAME and the target record. Minification simply means that the NS1 nameserver returns the entire chain of records from the CNAME to the final response in a single response. This eliminates any additional lookup steps and allows you to use CNAME records even in nested configurations without any performance penalty.

Additionally, NS1 supports a unique record type called Linked Record. This is essentially a symbolic link within the platform that serves as an ALIAS record, except for sub-microsecond resolution rates. To use linked records, create a target record as usual (it can be of any type), then create a second record pointing to it and select the Linked records option. Linked records can span domain (zone) boundaries as well as account boundaries within NS1, providing a powerful way to organize and optimize your DNS record structure.

CNAME, ALIAS, and linked record reference charts

CNAMENicknamelinked record
Want to use it in Apex?noyesYes (only applicable to other NS1 zones)
Relative speed (TTFB)fastfasterfaster
Collapse responseYes (NS1 Connect exclusive feature)yesyes

Scroll to see the full table.

Insert display text here.

Was this article helpful?

yesno

Related Articles

Back to top button