通常情况下,hosts 文件包含 IP 地址、系统名、系统别名和用户注释。创建的 hosts 文件可以包含有关系统的其他信息。该信息显示为一个或多个注释,这些注释位于系统的 hosts 文件条目之前。除非指定了其他值,否则将使用缺省值。为下列参数提供了缺省值:
可以修改 hosts 文件,以某个值替换一个条目的缺省值或更改所有后续条目的缺省值。要更改 hosts 文件中单个系统条目的值,请向 hosts 文件中的主机条目之前添加一个语句作为该行的注释,如以下示例所示。该语句应用于其后的系统,并仅应用于该系统。在以下示例中,缺省 TYPE 更改为系统 EngProliant 的服务器。
要全局性地更改缺省值,使其影响下一个文件条目和所有后续条目,请使用类似于以下示例的语句。将缺省值更改为下一个条目的路由器。路由器将为所有条目保留缺省值,直到另一个 #$IMXE_DEFAULT 语句更改了该值。如果 #$IMXE 语句更改了 TYPE 的单个实例,则不会仅对下个条目使用缺省值,然后恢复为路由器。
hosts 文件中引用的以下文本说明了多个语句。以井号 (#) 开头的说明不会显示在 hosts 文件中。
# Title: Systems in database
# Sorted by: IP address
# Date: 28-Mar-00 2:29:31 PM
# Author: administrator
The system EngProliant uses all current defaults.There are no
additional comments.
16.26.176.92 EngProliant.compaq.com EngProliant #user comments
The system testServer in the following example defaults for TYPE.
The defaults for SNMP Timeouts and Retries were
restored for this system but only apply to testServer.The SNMP
write community string default was changed and only applies
to testServer.
#$IMXE: TYPE=Server
#$IMXE: SNMP_TIM=0 SNMP_RET=0 SNMP_MON=public
SNMP_CON=private
16.26.160.20 testServer.compaq.com testServer
All defaults in the following example for the system BldRtr1 are
the same as for testServer, but had to be specified because
they are not the global defaults.These changes apply only to
BldRtr1.
#$IMXE: TYPE=Router
#$IMXE: SNMP_TIM=0 SNMP_RET=0 SNMP_MON=public
SNMP_CON=private
16.26.160.23 BldRtr1.compaq.com BldRtr1
For the system BldRtr5, the TYPE and protocols used for discovery
were changed from the current defaults.Because the remaining
keyword entries are missing, the standard defaults
are applied for the SNMP timeouts, retries, and community strings.
#$IMXE: TYPE=Router
16.26.160.24 BldRtr5.compaq.com BldRtr5
For the system AcctServer, only the TYPE was changed from the
current defaults.
#$IMXE: TYPE=Server
16.26.176.36 AcctServer.compaq.com AcctServer #user comments
The global default for TYPE was changed from Unknown to Router.
All subsequent entries will be identified as routers until a TYPE
statement is used to specify another type or restore the default.
#$IMXE_DEFAULT: TYPE=Router
16.25.176.38 FloorRtr2a.compaq.com FloorRtr2a #user comments
The default for the next host entry was changed to management
processor, which is enclosed in quotes.#$IMXE:
TYPE="Management Processor" AcctSvriLo.compaq.com
16.25.176.37 AcctSvriLo #user comments
...
缺省值如果 hosts 文件中缺少参数,则将应用缺省值。
相关步骤
相关主题
|