Route53 中 A Rec 和 CNAME 的区别 [英] Difference between an A Rec and CNAME in Route53

查看:22
本文介绍了Route53 中 A Rec 和 CNAME 的区别的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于 Amazon Route 53 允许您使用别名将 A 记录或 CNAME 设置为不同的子域名,我想知道现在 A 记录和 CNAME 之间有什么区别.

为了澄清我的问题,传统NameServer中CNAME和A记录的区别在于,只能使用CNAME指向不同的子域,并且A记录必须指向有效的IP地址.由于 AWS Route53 允许您使用带有 A Rec 或 CNAME 的子域..它不会模糊两者之间的区别.

解决方案

您的问题很有道理,但您使用子域"一词的方式并不十分精确.

您实际上要问的是这样一个事实,即 Route 53、A 记录可以提供引用来自另一个域的完全限定主机名的外观,或来自其的主机名或子域的外观.自己的域,而在正确的 DNS 中,引用另一个主机名的唯一方法是使用 CNAME,但不能在指向子域(www.example.com").

您说的别名似乎在功能上等效,但比 CNAME 更灵活,所以有区别吗?

CNAME 和别名的区别在于 CNAME 仍然是一个适当的、标准的、普通的 DNS CNAME,它返回一个DNS 查询响应您需要知道您要查找的服务器的 real ("canonical") name 是 'x'",并且根据情况,还可能包含目标主机的 A 记录,也可能不包含,要求客户端进行第二次查找.

另一方面,别名是亚马逊创建的一个聪明的黑客,它不会破坏协议,但允许 Route 53 直接从资源X"分发 A 记录,当 A 资源Y"的记录被请求.别名也可以引用其他记录类型,但它们引用的记录类型必须相同,出于本次讨论的目的,我指的是 A 记录别名.

而且,这里重要的一点是,别名实际上返回了一个 A 记录——而不是对目标的引用,就像 CNAME 那样.>

问题在于,使用别名时,您不能将任何主机名放入该框中.它必须是 Route 53 具有神奇钩子的域中的主机名,以便它可以检索相应的 A 记录以提供服务——无论是您区域中的另一个条目,还是来自 S3、ELB、或云前线.这是一个与 CNAME 记录工作方式截然不同的实现,即使最终效果看起来是一样的.

将任何其他内容放入其中,无法保存记录集,因为:- Alias Target 包含无效值. 试试看.:)

当然,CNAME 记录没有这样的限制……它们只是受设计限制在区域顶部使用.

因此,实际上,别名和 CNAME 记录没有您最初想象的那么多重叠.在某些情况下,只有一种可用,而在任何一种都可以工作的情况下,差异可能微不足道.

在可以使用任何一个的情况下,别名的一个优点是别名从不需要 2 个 DNS 查询,正如我上面提到的.它总是由 Route 53 使用适当的 A 记录直接回答,其中 CNAME,至少在它引用不同顶级域中的主机名的情况下,可以需要两次连续的 DNS 查找,在这种情况下,Alias 具有理论上的性能优势.

As Amazon Route 53 allows you to set an A record or a CNAME to a different sub-domain name using Alias, I am wondering what is the difference between A record and CNAME now.

To clarify my question, the difference between CNAME and A record in a traditional NameServer is that only CNAME can be used to point to a different subdomain and A record must point to a valid IP address. Since the AWS Route53 allows you to do use a subdomain with either A Rec or CNAME .. does it not blur the distinction between the two.

解决方案

Your question is quite valid, but you are using the word "subdomain" in a not-quite-precise way.

What you are actually asking is about the fact that an Route 53, an A record can give the appearance of referencing either a fully-qualified hostname from another domain, or a hostname or subdomain from its own domain, while in proper DNS, the only way to reference another hostname is with a CNAME, yet those can't be provisioned at the apex of a domain ("example.com") pointing to a subdomain ("www.example.com").

An alias, you're saying, seems to be functionally equivalent but more flexible than a CNAME so is there a difference?

The difference between a CNAME and an alias is that a CNAME is still a proper, standard, ordinary DNS CNAME, which returns a DNS query response "hi, you need to know that the real ("canonical") name of the server you are looking for is 'x'" and, depending on circumstances, may also include the A record for the target host or may not, requiring the client to go for a second lookup.

Aliases, on the other hand, are a clever hack created by Amazon which does not break the protocol yet allows Route 53 to hand out the A record directly from resource "X" when the A record for resource "Y" is requested. Aliases can also reference other record types, but the record type they reference must be the same and for the purposes of this discussion, I am talking about A record aliases.

And, the important take-away here is that an alias actually returns an A record -- not a reference to the target, like a CNAME does.

The catch is that with an alias, you cannot put just any hostname in that box. It has to be a hostname within a domain where Route 53 has the magical hooks so that it can retrieve the apprpriate A record to serve up -- either another entry in your zone, or from S3, ELB, or Cloudfront. This is a very different implementation than how CNAME records work, even though the net effect appears to be the same.

Put anything else in there, and The record set could not be saved because:- Alias Target contains an invalid value. Try it. :)

Of course, CNAME records have no limitation like that... they're just limited by design in their use at the top of a zone.

So, in fact, Aliases and CNAME records do not have as much overlap as you may have initially thought. In some situations, only one is usable, and cases where either one would work, the difference is probably insignificant.

One advantage of Alias in the case where either one could be used is that an alias never requires 2 DNS queries, as I mentioned above. It is always answered directly by Route 53 with the appropriate A record, where a CNAME, at least in the case where it references a hostname in a different top level domain, can require two sequential DNS lookups, giving Alias a theoretical performance advantage in that case.

这篇关于Route53 中 A Rec 和 CNAME 的区别的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆