DNS CNAME 记录的澄清
只是想看看我是否理解正确。
CNAME 记录指定别名,格式如下:
alias CNAME canonical-domain
这意味着如果某些内容尝试查找别名,它将找到 CNAME 记录并开始搜索canonical-domain。
一条记录直接将主机映射到 IP
主机 A IP-addr
因此,如果我有 2 个域最终指向同一个 IP 地址,则一个是规范域,另一个是规范域对于别名域,我将使用 A 记录作为规范域 -> IP 映射,并使用 CNAME 记录作为别名 -> 规范映射。
为什么我不能只使用 2 个 A 记录,一个是规范 -> IP 映射,另一个是别名 -> IP 映射?是不是以后如果需要更改IP,只需要更新一次? (类比 CNAME 是一个软链接,A 记录是文件系统中的一个文件)
Just want to see if I understand this correctly.
CNAME record specifies an alias, in the following form:
alias CNAME canonical-domain
Which means if something is trying to look up alias, it will find the CNAME record and start searching for canonical-domain instead.
A record directly maps a host to an IP
host A IP-addr
So if I have 2 domains eventually pointing to the same IP addr, one is a canonical domain and another is an alias domain, I would use an A record for the canonical domain->IP mapping, and a CNAME record for the alias->canonical mapping.
Why can't I just use 2 A records, one being canonical->IP mapping and the other being alias->IP mapping? Is it so that you only have to update the IP once if you ever need to change it? (Analogy would be CNAME is a softlink and A record is a file in a filesystem)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你可以——这很正常。
是的,没错。
常见的配置是让规范名称成为服务器的真实主机名,然后将托管在该服务器上的站点的 CNAME 记录指向该主机名。
请注意,您不能为裸域名(例如 stackoverflow.com)提供 CNAME。
CNAME
记录不能与预期存在于顶点的NS
和SOA
记录共存一个区域。这不是我会使用的类比。
You can - that's perfectly normal.
Yes, that's right.
A common configuration is to have the canonical name being the server's real hostname, and then CNAME records for the sites hosted on that server pointing at that.
Note that you can't have a CNAME for a bare domain name (e.g. stackoverflow.com) . A
CNAME
record can't coexist with theNS
andSOA
records that are expected to exist at the apex of a zone.That's not an analogy I'd use.