RFC-952 (“假设”下的第1点的最后一句)禁止使用单字符主机名,而且我有过经验( 7年前的2002 年夏天),有些服务拒绝使用单字符主机名(因为这样的名字是不符合标准),但是在过去的几年中我看到了许多单字符主机名。 单字符主机名现在是否有效? (如果是这样,什么是适当的validation参考?)
编辑 (合并来自答案的一些信息):DNS的各个方面似乎在几个RFC中定义,包括1035,1123和2181 。 从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.
从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].
从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.
最后,如RFC-952所述 :
1. A "name" (Net, Host, Gateway, or Domain name) is a text string up to 24 characters drawn from the alphabet (AZ), 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.
我原来是从下面的这个链接来说,RFC-952禁止使用单字符主机名。
“有效”与“有效”是有区别的。 如果主机名是单个字符(我以前的post不能承受),则认为主机名是完全可能的。 但是,相当多的系统确实允许它们。 一个主要的系统,微软的AD / DNS系统,有允许单个字符名称的遗留原因。
老的NetBIOS名字的长度可以是1到15个字符。 这个规范是独立于RFC952开发的,它基于一个名为lmhosts的不同文件,所以它可以工作。 当Microsoft从NetBEUI(实际上是NBF,NetBIOS帧协议)转移到TCP / IP(实际上是NBT)时,问题就出现了,微软必须允许在TCP / IPnetworking上进行命名parsing。 MSselect使用WINS服务器来维护NetBIOS风格的parsing,避免了RFC952兼容主机的需求。
然后来了活动目录和它的DNS依赖关系。 dynamicDNS是规则,因此客户端必须在DNS域中注册他们的ComputerName(前15个字符也是他们的NetBIOS名称)。 由于MS允许在DNS中注册单字符的NetBIOS名称,因此与RFC952相冲突。 他们决定编写他们的系统来允许这样做,因为这模拟了它在WINS时代的工作方式。
BIND DNS也允许单字符主机名。 但RFC2181几乎指出,应用程序需要审核自己的数据,而不是DNS。 这给我们留下了大量的设备和软件,其中单字符主机名称很好,还有一些是RFC952严格的不允许的exception值。
你会认为它们是有效的,因为根名称服务器都是单字母主机(a.root-servers.net),DNS规范不会为它们创build特定的例外。 有问题的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.
因此,单字母主机名在基于DNS的系统中是有效的,并且在发明垃圾邮件之前就已经存在了。 不符合RFC的系统,可能会被模拟。 除非他们根本不使用DNS,只使用主机文件,在这一点上怜悯是一个更好的select。
由于主机名在任何人甚至考虑写关于他们的RFC之前,我看不出任何原因单个字符主机名应该突然变成“非法”。 这个特定的RFC在声明时丢失了我
这个RFC是官方的规范
因为RFC不是一个标准。 差远了。
尽pipe如此,必须指出的是,这个RFC是为了适用于一个相对较小的组织而设立的,即国防部(大概是美国)。
我认为现在的主机名更依赖于DNS规范,因为大多数人会在networking或互联网中使用DNS。 说,有三个RFC(脑筋急转弯,1034-概念,1035-执行,2181-关于DNS的澄清)。
RFC 1034 第3节说:
域名空间是一个树状结构。 树上的每个节点和树叶对应于一个资源集(可能是空的)。 域系统不区分内部节点和叶子的用途,本备忘录使用术语“节点”来指代两者。
每个节点都有一个长度为0到63个八位字节的标签。 兄弟节点可能没有相同的标签,尽pipe相同的标签可以用于不是兄弟的节点。 一个标签是保留的,这是用于根的空(即零长度)标签。
在RFC 2181的第11节中,我们对地址的每个节点进行了说明:
DNS本身对特定标签只有一个限制
可以用来识别资源logging。 那一个限制
涉及到标签的长度和全名。 任何一个标签的长度限制在1到63个八位字节之间。 完整的域名限于255个八位位组(包括分隔符)
所以,根据DNS规范,你可以有一个.domain.tld
正如你所确定的那样,RFC 1123在这个长度问题上并不完全清楚。
第2.1节确实说:
主机软件必须处理多达63个字符的主机名,并且应该处理最多255个字符的主机名
由于该文本实际上完全覆盖了RFC 952中的文本,所以也应该认为,最多255个字符的长度是合法的。
不幸的是,1989年的互联网草案并没有得到他们现在得到的令人难以置信的严格审查,所以模糊可能根本没有被发现。