大网数据广告活动
网站运营与故障问答

Understanding CNAME and NS in DNS

· 52CE 我爱测

I'm trying to learn the different types in DNS (A, CNAME, NS etc). I do understand what they is used for, but the way I see it, CNAME could be used whenever NS is used, or am I wrong? For instance: (dns.mysite.example, 192.0.2.4,…

问题原文

原帖链接 · lawls · CC BY-SA 4.0

I'm trying to learn the different types in DNS (A, CNAME, NS etc).

I do understand what they is used for, but the way I see it, CNAME could be used whenever NS is used, or am I wrong?

For instance:

(dns.mysite.example, 192.0.2.4, A)
(mysite.example, dns.mysite.example, CNAME)

Would it matter if I used CNAME of NS here?

Also, a second question, am I right in assuming that top level domain (TLD) DNS servers don't have any CNAME records?

社区高分解答

原帖链接 · Patrick · CC BY-SA 4.0

No, CNAME and NS are quite different.

CNAME associates an alias with a canonical ("true") name. So in your example, dns.mysite.example would be an alias for canonical/true name mysite.example, and all DNS queries for dns.mysite.example would be referred to (ie, retried with) mysite.example.

NS records identify an authoritative name server for a domain (more correctly, a DNS zone). They tell a DNS query where to look for authoritative detail about a domain (zone). Typically, unless you are setting up name server infrastructure, your domain registrar will provide correct NS details for your domain (typically, a few name servers for redundancy, each controlled by your registrar, such as ns1.registrar.example, ns2.registrar.example).

For subdomains which will resolve to the same address, you do have a choice between A and CNAME records. The practical difference between A and CNAME records is that CNAME will cause an additional lookup (to resolve the alias to the canonical name) which is not incurred with a direct A record. So there is a slight performance penalty on lookups if you use CNAME records rather than individual A records for your subdomains.

The root zone file does not contain any CNAME records, but that's not because it can't, but that it doesn't need to. It mainly contains NS and address (A & AAAA) records for top level domains, for country-code top level domains (and, more recently, for all those new/extended TLDs like .auction).

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Webmasters Stack Exchange
适用范围
以原帖系统、软件版本与发布日期为准(2015-03-16)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。