Windows 中 C:\Windows\System32\drivers\etc\hosts 文件中主机的最大长度是多少?

What is the maximum length of a host in C:\Windows\System32\drivers\etc\hosts file in Windows?

我在主机文件中添加了以下行:C:\Windows\System32\drivers\etc\hosts
127.0.0.1 firsthostfirsthostfirsthostfirsthostfirsthostfirsthostfirsthost

以上工作正常(长度为 63),能够 ping 并且主机正在响应。但是如果我把主机名写成
127.0.0.1 firsthostfirsthostfirsthostfirsthostfirsthostfirsthostfirsthostf

(这里长度为64),显示信息:"Ping request could not find host firsthostfirsthostfirsthostfirsthostfirsthostfirsthostfirsthostf. Please check the name and try again."

请帮助我了解原因。任何参考 link 将不胜感激。

提前致谢。

RFC 1035 将完全限定域名 (FQDN) 的长度限制为 255 个字符,每个 "label" - 点之间的部分 - 为 63 个字符。

您的第一个示例有效,因为它是一个 63 个字符的标签。您的第二个示例失败,因为它不符合 RFC 1035 中规定的规则。