A record vs CNAME record for custom domain

独自空忆成欢 提交于 2019-12-06 08:09:49

问题


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?


回答1:


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.




回答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.




回答3:


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.



来源:https://stackoverflow.com/questions/37362002/a-record-vs-cname-record-for-custom-domain

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!