问题原文
原帖链接 · Andrew B · CC BY-SA 3.0
This is a Canonical Question about CNAMEs at the apices (or roots) of zones
It's relatively common knowledge that CNAME records at the apex of a domain are a taboo practice.
Example:
example.com. IN CNAME ithurts.example.net.
In a best case scenario nameserver software might refuse to load the configuration, and in the worst case it might accept this configuration and invalidate the configuration for example.com.
Recently I had a webhosting company pass instructions to a business unit that we needed to CNAME the apex of our domain to a new record. Knowing that this would be a suicide config when fed to BIND, I advised them that we would not be able to comply and that this was bunk advice in general. The webhosting company took the stance that it is not outright forbidden by standard defining RFCs and that their software supports it. If we could not CNAME the apex, their advice was to have no apex record at all and they would not provide a redirecting webserver. ...What?
Most of us know that RFC1912 insists that A CNAME record is not allowed to coexist with any other data., but let's be honest with ourselves here, that RFC is only Informational. The closest I know to verbiage that forbids the practice is from RFC1034:
If a CNAME RR is present at a node, no other data should be present; this ensures that the data for a canonical name and its aliases cannot be different.
Unfortunately I've been in the industry long enough to know that "should not" is not the same as "must not", and that's enough rope for most software designers to hang themselves with. Knowing that anything short of a concise link to a slam dunk would be a waste of my time, I ended up letting the company get away with a scolding for recommending configurations that could break commonly used software without proper disclosure.
This brings us to the Q&A. For once I'd like us to get really technical about the insanity of apex CNAMEs, and not skirt around the issue like we usually do when someone posts on the subject. RFC1912 is off limits, as are any other Informational RFC applicable here that I didn't think of. Let's shut this baby down.
社区高分解答
原帖链接 · Daniel Liuzzi · CC BY-SA 4.0
June 2022 Update
New SVCB and HTTPS resource records enable aliasing of apex domains and facilitate lookups for connecting to services like HTTP origins. Many DNS providers and browsers already support them, so it seems this will be the de facto standard one the spec is finalized.
Resources
- The Use Cases and Benefits of SVCB and HTTPS DNS Record Types (brief overview)
- What's the use case of SVCB (type 65 , service binding) RR (excellent answer to relevant question)
- Service binding and parameter specification via the DNS (DNS SVCB and HTTPS RRs) (full draft)
The Internet Systems Consortium recently posted a write-up on CNAME at the apex of a zone, why this restriction exists, and a number of alternatives. This is not likely to change anytime soon, sadly:
We cannot change how the special CNAME record is used without changing all of the >DNS server implementations in the world at the same time. This is because its meaning and interpretation was strictly defined in the DNS protocol; all current DNS client and server implementations adhere to this specification. Attempting to ‘relax’ how CNAME is used in authoritative servers without simultaneously changing all DNS resolvers currently in operation will cause name resolution to break (and web and email services to become intermittently unavailable for those organizations implementing ‘relaxed’ authoritative server solutions.
But there's hope:
Another potential solution currently being discussed would add a new dns resource record type that browsers would look up, that could exist at the apex. This would be an application-specific hostname for http requests (similar to the way MX works).
Pros: This is completely consistent with the DNS design.
Cons: This is not available yet, and would require a browser client update.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
