Using an ALIAS record to point an apex domain to a Netlify subdomain (external DNS provider)

Questions:

  • Can an ALIAS record (without any A record) be used with an apex domain to point to the Netlify subdomain (e.g. my-site.netlify.app), rather than pointing the apex domain to the Netlify load balancers? I am asking this for the case where we would like to keep our current external DNS provider, which is not one of the recommended providers in the Netlify docs (NS1, Cloudflare).
  • If so, would this then utilize the higher Netlify CDN speeds when sending requests to the apex domain (rather than the slower CDN speed when pointing to the load balancers and having to go through a redirect to the www subdomain)?
  • Finally, would changing the Netlify primary domain to be the apex domain affect this behavior?

More Information:

site name: TBD
custom domain: datascijedi.org (or www.datascijedi.org)

I am looking into using an external DNS Provider with Netlify web hosting. I read in the Netlify docs that the recommended setup is to use (1) www as the Netlify primary domain, (2) a CNAME for the www subdomain pointing to the Netlify subdomain, and (3) an ANAME, ALIAS, Flattened CNAME, or A record for the apex domain pointing to the Netlify load balancers. The docs also suggest that the www subdomain should be set as the Netlfy primary domain to take advantage of Netlify’s higher CDN speeds.

However, it is not clear to me why the recommendation is to use an ALIAS record to point the apex domain to the Netlify load balancers, rather than directly to the Netlify subdomain, and what the CDN speed implication of this might be. This has implications on preferring use of the apex domain or a www subdomain, so any thoughts on this would be very helpful.

Thank you in advance. a

Hi @raviweb :wave:t6: ,

Welcome to the forums and thanks so much for reaching out! Can you check out [this] support guide? This has some good resources for DNS providers for Alias/ANAME support.

Please note that you can ONLY do this safely with apex-loadbalancer.netlify.com which points to both of our load balancer addresses which is geo distributed only for one provider but you get good performance from anywhere.

Hi @SamO - thanks for the link, very helpful information.

I am still going through the provided support guide, but it would be helpful to clarify why the ALIAS record must be used with apex-loadbalancer.netlify.com, rather than the Netlify subdomain.

For instance, let us assume (1) external DNS is being used, (2) ALIAS and CNAME records point both the apex and www subdomain respectively to the Netlify subdomain, my-site.netlify.app. Consider the following two possible request-response flows for going to the website’s home page:

Flow 1 - GET www.datascijedi.org /

  1. [Browser] GET www.datascijedi.org /
  2. [DNS Server] CNAME my-site.netlify.app
  3. [Browser] Direct GET request to my-site.netlify.app
  4. [Netlify] Netlify/NS1 internal stuff
  5. [Netlify] HTTP Response for web page

Flow 2 - GET datascijedi.org /

  1. [Browser] GET datascijedi.org /
  2. [DNS Server] ALIAS my-site.netlify.app
  3. [Browser] Direct GET request to my-site.netlify.app
    …now, why wouldn’t step 4 and 5 be the same from here?

Thanks again for your help with sorting this out!

Oh. I think I know why. This is also why it is taking so long to support IPv6 on that load balancer.
The loadbalancer very likely resolves to something called anycast IPs. Multiple Netlify servers around the world respond to that IP and the Internet routing tables point to different datacenters depending on where you are in the world. This gives you reduced latency.
Now. If you ALIAS your domain to the netlify subdomain for your site, that resolves to IPs of a specific datacenter. The DNS server might even give you different IPs depending on where you are in the world (again, to reduce latency). BUT, you’re not the one resolving that domain when it’s an alias record. That would be whichever registrar you are using, which then in turn responds with the resolved IPs that happen to be closest to that registrar datacenter, not to you.

So, depending on how your registrar has implemented ALIAS you could get an IP fairly close to you (they themselves use anycast to reduce DNS latency) if every one of their DNS servers resolve the domain on their own, OR if they query once and then distribute across their network, you might get an IP for a server in Australia when browsing from Iceland.

Disclaimer: I’m doing quite a bit of speculation here, but I’m pretty sure the principle of it holds.

Thanks @andsens for your thoughts on this! So a follow up question: if it is more efficient from the point of view of the website visitor to use the Netlify load balancer domain via the apex domain ALIAS record, why not point the www subdomain to the load balancer as well? E.g. why would the guidelines have the www subdomain still point to the site subdomain?

@raviweb Now that is a very good question. I would guess it’s to avoid having everything depend on that one IP? It’d be a pretty bad single point of failure.
Because you’re right, I can run curl -H “Host: www.example.com” https://apex-loadbalancer.netlify.com and get the proper response of my site.

I suppose the DNS records could map apex-loadbalancer.netlify.com to multiple IPs to avoid a single point of failure as well.