A record vs CNAME record for custom domain
Asked Answered
C

3

4

Which should I pick and why? Firebase recommends CNAME records but why? Isn't it better to point to the ip address rather than point to another domain that points to the ip address?

Contractor answered 21/5, 2016 at 10:57 Comment(0)
M
7

Firebase recommends CNAME records but why?

Firebase hosting is probably marking CNAME records as recommended because they are widely allowed for setup by registrars and the easiest to setup for most novices when setting up their wildcards.

Isn't it better to point to the ip address rather than point to another domain that points to the ip address?

YES you are correct. It is going to be a faster lookup because it will not have to do 2 lookups (the CNAME then the pointed domain name).

Firebase Hosting gives you the option to add A records in your DNS with not just one IP address but two for even better performance.

Which should I pick and why?

You will have a choice here.

  • Use A records pointing to IP addresses if allowed first if you are not concerned the IP address will change for the hosting server. Will Firebase Hosting change IP addresses in the future? Maybe, but probably not very often.
  • Use CNAME if you are not concerned about the lookup making two lookups or you want an easier setup.
  • Use CNAME if you are using a multi-region CDN for a static site with google or a host like Netlify and you are not using their DNS servers for your domain. This will allow their servers to resolve users to the closest server in their region.

NOTE: Both of these options could require a change if Firebase Hosting decides to make a domain name or IP Address change to their hosting services, but I would suspect they would notify you ahead of time as soon as that is going to happen.

My choice is to use A record pointers in this case because we are dealing with Google here and typically are good about notifications of changes. I can change an IP address as quickly as a domain name in a DNS configuration.

Misanthrope answered 23/5, 2016 at 0:21 Comment(1)
I thought that you needed a CNAME record in order to take advantage of the CDN? The domain in the CNAME record returns a IP address for the closest (of 7-8 different IP addresses for example). But an A name record might only provide you with 2 different IP addresses to connect to? Am I missing something here? (I notice Netlify uses CNAME records, for this reason?)Flunky
D
2

As of early February 2017 CNAME is no longer supported for new domain connections for Firebase Hosting. A record is the way the go.

Firebase's Domain Connection option now makes it easier to connect with A records by providing the two A record IP addresses you will need to point your sites DNS entries to at the initial connection attempt (previously you had to go back in to the console for these after your site was validated). Further it validates that both A records have been added before the connection is marked as complete.

Dextrogyrate answered 5/2, 2017 at 15:10 Comment(1)
I thought that you needed a CNAME record in order to take advantage of the CDN? The domain in the CNAME record returns a IP address for the closest (of 7-8 different IP addresses for example). But an A name record might only provide you with 2 different IP addresses to connect to? Am I missing something here? (I notice Netlify uses CNAME records, for this reason?)Flunky
N
1

In almost all cases I can think of I'd say use an A record. However, if the hosting are done over multiple datacenters and/or servers, where you have someone else taking care of the final pointers to the servers itself and don't want to bother with changing IP:s and stuff like that a CNAME would probably be for the best. It all comes down to infrastructure imo.

Nelle answered 21/5, 2016 at 11:7 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.