大网数据广告活动
服务器运维问答

Why using CNAME and DNAME together isn't allowed

· 52CE 我爱测

If you have a main domain and a bunch of similar domains that you basically want to behave exactly the same it seems logical to configure as follows: 'Poor relation' zone: amazon.co.uk. DNAME amazon.com. amazon.co.uk. CNAME amazo…

问题原文

原帖链接 · ostergaard · CC BY-SA 3.0

If you have a main domain and a bunch of similar domains that you basically want to behave exactly the same it seems logical to configure as follows:

'Poor relation' zone:

amazon.co.uk. DNAME amazon.com.

amazon.co.uk. CNAME amazon.com.

'Daddy' zone:

amazon.com. A 1.1.1.1

www.amazon.com. A 1.1.1.1

amazon.com. MX x.y.z.

... and expect email for both amazon.co.uk and .com to be handled by x.y.z and the web server at 1.1.1.1 to get requests for not only amazon.com and www.amazon.com but also for amazon.co.uk and www.amazon.co.uk.

However RFC 6672 says:

The owner name of a DNAME can only have one DNAME RR, and no CNAME RRs can exist at that name. These rules make sure that for a single domain name, only one redirection exists; thus, there's no confusion about which one to follow.

What I don't understand and my question is, what is the potential confusion which is avoided by not allowing CNAME with DNAME? My understanding is that DNAME will do everything except the apex and CNAME does the apex, what have I missed?

已采纳解答

原帖链接 · Martin Kealey · CC BY-SA 4.0

it seems like the answer is basically that the original architects never thought it would be useful or something equally short sighted

It's important to understand that the Domain Name System (DNS) was replacing an arrangement that used a globally cloned version of /etc/hosts across every computer on the internet at the time, so reliability and fast average responses were critical to its adoption. So the inclusion of caching resolvers in the original design was a critical to its success.

Since then the focus has shifted: backwards compatibility is also extremely important: caching DNS resolvers are a core service on consumer appliances that typically run for 10~15 years without software updates.

Now imagine a CNAME record were allowed in combination with some other record type, and then consider a caching resolver.

The first problem is efficiency.

Depending on the order of queries and the TTLs of the records, it will eventually wind up with only a CNAME in its cache for a given name.

Then what should happen when a client (which might be another caching resolver) queries for a AAAA: should it answer using the CNAME, or query the authoritative server for an AAAA?

The next problem is ambiguity.

If the owner and target names are both zone apexes, and the client queries for NS or SOA, then there are two completely different possible answers, both valid depending on why the query was made.

The "keep it simple" design would say "treat all queries the same", because you don't know why the client is asking: always follow the redirection.

You could argue that different rules should apply for different record types, and that there should be an enumerated a list of RR types which could co-exist with CNAME records, but such a list would have had to have been part of the original design (in the early 1980's). And while that would have solved the problem for SOA & NS, it would not have solved the problem for DNAME which was not added until later.

The addition of a "do not follow CNAME" field in the query record would probably have resolved most issues, without adding much complexity, but that would have been a prescient design at a time when symbolic links were a novelty, and O_NOFOLLOW was still at least decade away.

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

资料来源与适用范围

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

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

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