语法与约定
; (semicolon) is used to denote the beginning of a comment.
Any text on a given line following a ';' is a
comment, and not part of the host table.
NET keyword introducing a network entry
GATEWAY keyword introducing a gateway entry
HOST keyword introducing a host entry
DOMAIN keyword introducing a domain entry
:(colon) is used as a field delimiter
::(2 colons) indicates a null field
,(comma) is used as a data element delimiter
XXX/YYY indicates protocol information of the type
TRANSPORT/SERVICE.
其中 TRANSPORT/SERVICE 选项的指定方式如下
"FOO/BAR" both transport and service known
"FOO" transport known; services not known
"BAR" service is known, transport not known
注:有关机器类型、操作系统以及协议/服务的具体选项和缩写,参见"Assigned Numbers"。
每个主机表条目是一个由 6 个字段组成的 ASCII 文本字符串,其中
Field 1 KEYWORD indicating whether this entry pertains to
a NET, GATEWAY, HOST, or DOMAIN. NET entries are
assigned and cannot have alternate addresses or
nicknames. DOMAIN entries do not use fields 4, 5,
or 6.
Field 2 Internet Address of Network, Gateway, or Host
followed by alternate addresses. Addresses for a
Domain are those where a Domain Name Server exists
for that domain.
Field 3 Official Name of Network, Gateway, Host, or Domain
(with optional nicknames, where permitted).
Field 4 Machine Type
Field 5 Operating System
Field 6 Protocol List
字段 4、5 和 6 是可选的。对于域(Domain),这些字段不使用。
字段 3-6(如果包含)均针对字段 2 中的第一个地址。
数据元素或字段之间的"空白"(空格和制表符)会被忽略,但数据元素内部不允许出现空白。
每个条目以冒号结束。
表中的条目按类型分组,顺序为域(Domain)、网络(Net)、网关(Gateway)、主机(Host)。每种类型内部的顺序不作规定。
注意,虽然允许主机带有可选的别名,但不鼓励使用,除非主机名已被更改,并且新旧名称都在适当的一段时间内同时保留,以实现平稳过渡。NET 名称不允许使用别名。