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=private16.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 檔中缺少參數,則會套用預設值。
相關程序
相關主題
|