单字母主机名有效吗?

Isa*_*aac 14 domain-name-system hostname rfc

RFC-952(假设下第 1 点的最后一句话)禁止使用单字符主机名,我曾有过(7 年前的 2002夏天)某些服务拒绝使用单字符主机名的经验(因为这些名称是不符合标准),但我在过去几年中看到了许多使用的单字符主机名。单字符主机名现在有效吗?(如果是这样,正确的验证参考是什么?)

编辑(整合答案中的一些信息):DNS 的各个方面似乎在几个 RFC 中都有定义,包括103511232181。来自RFC-2181 第 11 节

Note however, that the various applications that make use of DNS data
can have restrictions imposed on what particular values are
acceptable in their environment.  For example, that any binary label
can have an MX record does not imply that any binary name can be used
as the host part of an e-mail address.
[ ... ]
See also [RFC1123] section 6.1.3.5.
Run Code Online (Sandbox Code Playgroud)

来自RFC-1123 第 6.1.3.5 节

The DNS defines domain name syntax very generally -- a
string of labels each containing up to 63 8-bit octets,
separated by dots, and with a maximum total of 255
octets.  Particular applications of the DNS are
permitted to further constrain the syntax of the domain
names they use, although the DNS deployment has led to
some applications allowing more general names.  In
particular, Section 2.1 of this document liberalizes
slightly the syntax of a legal Internet host name that
was defined in RFC-952 [DNS:4].
Run Code Online (Sandbox Code Playgroud)

来自RFC-1123 第 2.1 节

The syntax of a legal Internet host name was specified in RFC-952
[DNS:4].  One aspect of host name syntax is hereby changed: the
restriction on the first character is relaxed to allow either a
letter or a digit.  Host software MUST support this more liberal
syntax.
Run Code Online (Sandbox Code Playgroud)

最后,正如最初引用的那样,来自RFC-952

1. A "name" (Net, Host, Gateway, or Domain name) is a text string up
to 24 characters drawn from the alphabet (A-Z), digits (0-9), minus
sign (-), and period (.).  Note that periods are only allowed when
they serve to delimit components of "domain style names". (See
RFC-921, "Domain Name System Implementation Schedule", for
background).  No blank or space characters are permitted as part of a
name. No distinction is made between upper and lower case.  The first
character must be an alpha character.  The last character must not be
a minus sign or period.
[ ... ]
Single character names or nicknames are not allowed.
Run Code Online (Sandbox Code Playgroud)

正是通过遵循这条链,我最初才说 RFC-952 禁止单字符主机名。

sys*_*138 11

您会认为它们是有效的,因为根名称服务器都是单字母主机 (a.root-servers.net),并且 DNS 规范没有为它们创建特定的例外。有问题的 RFC 专门针对主机文件格式,而不是 DNS。DNS 是在后来的 RFC 中定义的(RFC 1035开始了它)。RFC 1123 (1989) 清楚地说明了这一点。

 The syntax of a legal Internet host name was specified in RFC-952
 [DNS:4].  One aspect of host name syntax is hereby changed: the
 restriction on the first character is relaxed to allow either a
 letter or a digit.  Host software MUST support this more liberal
 syntax.
Run Code Online (Sandbox Code Playgroud)

因此,单字母主机名在基于 DNS 的系统中是有效的,并且在垃圾邮件发明之前就已经存在。不符合 RFC 的系统可能会被嘲笑。除非他们根本不使用DNS而只使用hosts文件,否则pie是更好的选择。


sys*_*138 3

“有效”和“有效”之间是有区别的。如果主机名是单个字符,则完全有可能不被认为是有效的(尽管我之前的帖子除外)。然而,相当多的系统确实允许它们。Microsoft 的 AD/DNS 系统这一主要系统有一个允许使用单字符名称的遗留原因。

老式 NetBIOS 名称的长度允许为 1 到 15 个字符。该规范是独立于 RFC952 开发的,它基于一个名为 lmhosts 的不同文件,因此它可以工作。当 Microsoft 从 NetBEUI(实际上是 NBF,NetBIOS 帧协议)转向 TCP/IP(实际上是 NBT)时,问题就出现了,并且 Microsoft 必须允许通过 TCP/IP 网络进行命名解析。MS 选择通过 WINS 服务器维护 NetBIOS 样式解析,从而绕过了对符合 RFC952 的主机的需求。

然后是 Active Directory 及其 DNS 依赖项。动态 DNS 是规则,因此客户端必须在 DNS 域中注册其 ComputerName(其中前 15 个字符也是其 NetBIOS 名称)。由于MS允许在DNS中注册单字符NetBIOS名称,这使其与RFC952发生冲突。他们决定对系统进行编码以允许这样做,因为这模仿了 WINS 时代的工作方式。

BIND DNS 还允许单字符主机名。但 RFC2181 几乎明确指出应用程序需要审查自己的数据,而不是 DNS。这给我们留下了大量的设备和软件,单字符主机名就可以了,还有一些严格的 RFC952 不允许这样做的异常值。