06-配置文件管理命令
本章節下載: 06-配置文件管理命令 (180.97 KB)
目 錄
1.1.2 archive configuration interval
1.1.3 archive configuration location
1.1.4 archive configuration max
1.1.5 backup startup-configuration
1.1.7 configuration replace file
1.1.8 display archive configuration
1.1.9 display current-configuration
1.1.10 display default-configuration
1.1.11 display saved-configuration
1.1.14 reset saved-configuration
1.1.15 restore startup-configuration
1.1.17 startup saved-configuration
· 設備運行於FIPS模式時,本特性的相關配置相對於非FIPS模式有所變化,具體差異請見本文相關描述。有關FIPS模式的詳細介紹請參見“安全配置指導“中的“FIPS”。
· 本章中典型配置舉例中的配置,如無特殊說明,均以設備運行在非FIPS模式下的命令行為準。
archive configuration命令用來手工備份當前配置。
【命令】
archive configuration
【視圖】
用戶視圖
【缺省用戶角色】
network-admin
【使用指導】
設備支持手工和自動兩種方式來備份當前配置。執行該命令後,係統會將當前的配置以指定的文件名保存到指定的路徑。
需要注意的是:
· 執行archive configuration命令前必須先執行archive configuration location命令來設置備份配置文件的保存路徑和文件名前綴。
· 執行該命令後,隻有Master會備份當前配置,Slave不進行備份操作。
【舉例】
# 手工備份當前配置。
<Sysname> archive configuration
Save the running configuration to an archive file. Continue? [Y/N]: Y
The archive configuration file myarchive_1.cfg is saved.
【相關命令】
· archive configuration interval
· archive configuration location
· archive configuration max
· display archive configuration
archive configuration interval命令用來使能自動備份當前配置功能,並設置自動備份的時間間隔。
undo archive configuration interval用來恢複缺省情況。
【命令】
archive configuration interval minutes
undo archive configuration interval
【缺省情況】
係統不會自動備份當前配置。
【視圖】
係統視圖
【缺省用戶角色】
network-admin
【參數】
minutes:表示自動備份當前配置的時間間隔,取值範圍為10~525600,單位為分鍾。(525600分鍾相當於365天)
【使用指導】
設備支持手工和自動兩種方式來備份當前配置。成功執行本命令後,每隔指定時間(由minutes值決定)係統會把當前配置以指定文件名自動保存到指定路徑。
使用該命令時應根據設備存儲介質的性能和修改配置的頻繁程度來設置minutes參數的具體值:
· 對於不會頻繁修改配置的設備,建議按需手動備份當前配置(相關配置可參考命令archive configuration);
· 對於使用低速存儲介質(如Flash)的設備,建議不要進行自動備份配置,或設置minutes大於1440分鍾(24小時);
需要注意的是:
· 執行archive configuration interval命令前必須先執行archive configuration location命令來設置備份文件的前綴和保存路徑。
· 執行該命令後,隻有Master會備份當前配置,Slave不進行備份操作。
【舉例】
# 設置每隔一小時自動備份當前配置。
<Sysname> system-view
[Sysname] archive configuration interval 1500
Archive files will be saved every 1500 minutes.
【相關命令】
· archive configuration
· archive configuration location
· archive configuration max
· display archive configuration
archive configuration location命令用來設置備份配置文件的保存路徑和文件名前綴。
undo archive configuration location命令用來恢複缺省情況。
【命令】
archive configuration location directory filename-prefix filename-prefix
undo archive configuration location
【缺省情況】
係統沒有設置備份配置文件的保存路徑和文件名前綴。
【視圖】
係統視圖
【缺省用戶角色】
network-admin
【參數】
directory:表示保存備份配置文件的文件夾的路徑,為1~63個字符的字符串,格式為存儲介質名:/[文件夾名]/子文件夾名。
filename-prefix:表示備份配置文件的文件名前綴,為1~30個字符的字符串,隻能包含字母、數字、“_”和“-”。
【使用指導】
自動或手動備份當前配置前必須使用該命令設置備份配置文件的保存路徑和文件名前綴。
需要注意的是:
directory必須是Master上已存在的路徑,且參數中不能包含成員編號。
執行undo archive configuration location命令後,用戶將不能手工備份當前配置,係統也不再自動備份當前配置,archive configuration interval和archive configuration max的配置也會恢複到缺省情況,display archive configuration的顯示信息也會被清除。
【舉例】
# 在flash:/archive/目錄下備份配置文件,文件名前綴為my_archive。
<Sysname> mkdir flash:/archive
Creating directory flash:/archive... Done.
<Sysname> system-view
[Sysname] archive configuration location flash:/archive filename-prefix my_archive
【相關命令】
· archive configuration
· archive configuration location
· archive configuration max
· display archive configuration
archive configuration max命令用來設置係統允許保存的備份配置文件的最大數。
undo archive configuration max用來恢複缺省情況。
【命令】
archive configuration max file-number
undo archive configuration max
【缺省情況】
係統最多允許保存5個備份配置文件。
【視圖】
係統視圖
【缺省用戶角色】
network-admin
【參數】
file-number:表示可保存的備份配置文件數目上限,取值範圍為1~10。該參數的具體數值應根據設備存儲介質的空間大小來決定。對於存儲空間較小的設備,建議設置file-number為較小值。
【使用指導】
備份配置文件數目過多會占用係統內存空間,通過該命令可以控製備份配置文件的數目。當備份配置文件數目到達上限後,下次備份配置文件(包括自動和手動兩種觸發方式)時,將刪除保存時間最早的備份文件,以保存新的備份配置文件。修改備份配置文件數上限時並不刪除多餘文件,如果當前已有的備份配置文件數大於或等於新設置的上限值,則在備份新的配置時,係統將自動刪除生成時間最早的n(n=當前已有備份配置文件數-新設置的上限值+1)個備份配置文件。比如,當前已有備份配置文件數為7,新設置的上限值為4,當有配置需要備份時,係統會先刪除“7-4+1=4”個生成時間最早的備份配置文件。
需要注意的是:
· 在使用該命令前,必須先執行archive configuration location命令設置保存路徑和文件名前綴,否則,本命令執行失敗。
· 執行undo archive configuration location,係統最多允許保存的備份配置文件數目也會恢複到缺省情況。
【舉例】
# 設置係統最大允許保存10個備份配置文件。
<Sysname> system-view
[Sysname] archive configuration max 10
【相關命令】
· archive configuration
· archive configuration location
· archive configuration interval
· display archive configuration
backup startup-configuration命令用於將設備的主用下次啟動配置文件備份到指定的TFTP服務器。
【命令】
backup startup-configuration to tftp-server [ dest-filename ]
【視圖】
用戶視圖
【缺省用戶角色】
network-admin
【參數】
tftp-server:TFTP服務器的IPv4地址或主機名,主機名為1~20個字符的字符串。
dest-filename:目的文件名,後綴必須為“.cfg”。在服務器上將以該文件名保存設備的啟動配置文件。不指定該參數時,使用原文件名備份。
【使用指導】
FIPS模式下不支持該命令。
【舉例】
# 將設備的下次啟動配置文件備份到IP地址為2.2.2.2的TFTP服務器上,文件名為192-168-1-26.cfg。
<Sysname> backup startup-configuration to 2.2.2.2 192-168-1-26.cfg
Backup next startup-configuration file to 2.2.2.2, please wait…finished。
【相關命令】
· restore startup-configuration
configuration encrypt命令用來使能配置文件加密功能。
undo configuration encrypt命令用來關閉配置文件加密功能。
【命令】
configuration encrypt { private-key | public-key }
undo configuration encrypt
【缺省情況】
配置文件加密功能處於關閉狀態。
【視圖】
係統視圖
【缺省用戶角色】
network-admin
【參數】
private-key:使用私鑰進行加密。
public-key:使用公鑰進行加密。
【使用指導】
使能該功能後,每次執行save操作,都會先將當前的生效的配置進行加密,再保存。
· 私鑰是設備內部的一組參數,設備不同,私鑰不同,用戶不能通過命令行配置。因此,使用私有密鑰加密的配置文件隻能被本設備解密和識別,不能被其它設備解密和識別。
· 公鑰和軟件版本相關,軟件版本號相同的H3C設備擁有相同的公鑰。因此,使用公有密鑰加密的配置文件可以被本設備和軟件版本號相同的其它H3C設備解密和識別。
【舉例】
# 設置保存配置文件時使用公鑰進行加密。
<Sysname> system-view
[Sysname] configuration encrypt public-key
configuration replace file命令用來進行配置回滾。
【命令】
configuration replace file filename
【視圖】
係統視圖
【缺省用戶角色】
network-admin
【參數】
filename:指定用來回滾配置的配置文件名。
【使用指導】
本命令中指定的配置文件隻能是明文配置文件,不能是被加密的配置文件。否則,不能回滾。
【舉例】
# 將當前配置回滾到配置文件my_archive_1.cfg中的配置狀態。
<Sysname> system-view
[Sysname] configuration replace file my_archive_1.cfg
Current configuration will be lost, save current configuration? [Y/N]:n
Now replacing the current configuration. Please wait...
Succeeded in replacing current configuration with the file my_archive_1.cfg.
display archive configuration命令用來顯示備份配置文件的相關信息。
【命令】
display archive configuration
【視圖】
任意視圖
【缺省用戶角色】
network-admin
network-operator
【舉例】
# 顯示備份配置文件的相關信息。
<Sysname> display archive configuration
Location: flash:/archive
Filename prefix: my_archive
Archive interval in minutes: 120
Maximum number of archive files: 10
Saved archive files:
No. TimeStamp FileName
1 Wed Dec 15 14:20:18 2010 my_archive_1.cfg
2 Wed Dec 15 14:33:10 2010 my_archive_2.cfg
# 3 Wed Dec 15 14:49:37 2010 my_archive_3.cfg
‘#’ indicates the most recent archive file.
Next archive file to be saved: my_archive_4.cfg
表1-1 display archive configuration命令顯示信息描述表
字段 |
描述 |
Location |
保存備份配置文件的文件夾的絕對路徑 |
Filename prefix |
備份配置文件的文件名前綴 |
Archive interval in minutes |
自動備份配置文件的時間間隔,以分鍾為單位 若不自動備份配置文件,不顯示此項 |
Maximum number of archive files |
設備可保存的最大備份配置文件數目 |
Saved archive files |
當前已保存的備份配置文件信息 |
No. |
顯示已保存的備份配置文件信息的行號 |
TimeStamp |
備份配置文件的保存時間 |
FileName |
備份配置文件名,不包含路徑 |
‘#’ indicates the most recent archive file. |
“#”表示該行描述的備份配置文件是最近一次備份的 |
Next archive file to be saved |
下次保存備份配置文件將使用的文件名 |
【相關命令】
· archive configuration
· archive configuration interval
· archive configuration location
· archive configuration max
display current-configuration命令用來顯示設備當前生效的配置。
【命令】
display current-configuration [ configuration [ module-name ] | interface [ interface-type ] [ interface-number ] ]
【視圖】
任意視圖
【缺省用戶角色】
network-admin
network-operator
【參數】
configuration [ module-name ]:顯示具體功能模塊的配置信息。
interface [ interface-type ] [ interface-number ]:顯示接口的配置。interface-type表示接口類型,interface-number表示接口編號。
【使用指導】
當用戶完成一組配置之後,需要驗證是否配置正確,則可以執行display current-configuration命令來查看當前生效的參數。對於某些當前配置的參數,如果與缺省參數相同,則不顯示。對於某些參數,由於硬件或者規格限製,實際生效值和用戶配置值不一致,則顯示實際生效值。
【舉例】
# 查看當前設備上本地用戶的相關配置。
<Sysname> display current-configuration configuration local-user
#
local-user 123 class manage
password hash $h$6$S7Z7s7yl4Rn6v68k$0Gti4V6Mk7cH2MpHJhHmfhiEAZWU9DmZKhxftcCNRUp
PA2rtuDP+x/rsylegDS2xzI8blHidk74Q/FwABkgFEQ==
service-type ftp
authorization-attribute work-directory flash:/
authorization-attribute user-role network-operator
authorization-attribute user-role level-15
authorization-attribute user-role 15
# 查看當前設備上以太網接口的相關配置。
<Sysname> display current-configuration interface Ten-GigabitEthernet
interface Ten-GigabitEthernet1/0/1
port link-type hybrid
port hybrid vlan 20 to 24 tagged
port hybrid vlan 1 25 to 30 untagged
port link-aggregation group 1
#
interface Ten-GigabitEthernet1/0/2
#
interface Ten-GigabitEthernet1/0/3
#
---- More ----
display default-configuration命令用來顯示設備的出廠配置。
【命令】
display default-configuration
【視圖】
任意視圖
【缺省用戶角色】
network-admin
network-operator
【舉例】
# 顯示設備的出廠配置。
<Sysname> display default-configuration
#
telnet server enable
#
undo ip redirects enable
undo ip ttl-expires enable
undo ip unreachables enable
#
lldp global enable
#
vlan 1
#
interface NULL0
#
interface Ten-GigabitEthernet2/0/1
#
interface Ten-GigabitEthernet2/0/2
#
interface Ten-GigabitEthernet2/0/3
#
interface Ten-GigabitEthernet2/0/4
---- More ----
display saved-configuration命令用來查看主用下次啟動配置文件的內容。
【命令】
display saved-configuration
【視圖】
任意視圖
【缺省用戶角色】
network-admin
network-operator
【使用指導】
可以在管理/維護設備時使用該命令確認重要的配置是否已經保存到主用下次啟動配置文件。
如果設備未設置下次啟動配置文件,或下次啟動配置文件不存在,執行display saved-configuration命令,則沒有顯示信息。
【舉例】
# 顯示主用下次啟動配置文件的內容。
<Sysname> display saved-configuration
#
version 7.1.035, Release 2210
#
sysname H3C
#
ftp server enable
#
telnet server enable
#
irf mac-address persistent timer
irf auto-update enable
irf link-delay 0
irf member 2 priority 1
#
isis 1
#
mac-address mac-roaming enable
#
lldp global enable
#
system-working-mode advance
---- More ----
【相關命令】
· save
· reset saved-configuration
display startup命令用來顯示用於本次及下次啟動的配置文件名。
【命令】
display startup
【視圖】
任意視圖
【缺省用戶角色】
network-admin
network-operator
【使用指導】
· 因為Slave是根據Master的當前配置啟動和運行的,所以IRF中所有成員設備顯示的當前啟動配置文件始終是相同的。
· 當Master角色變更後,新的Master沒有從配置文件重啟而是沿用當前的配置繼續運行,使用display startup查看時,所有成員設備的當前啟動配置文件均會顯示為NULL。
【舉例】
# 顯示本次及下次啟動的配置文件名。
<Sysname> display startup
MainBoard:
Current startup saved-configuration file: flash:/startup.cfg
Next main startup saved-configuration file: flash:/startup.cfg
Next backup startup saved-configuration file: NULL
Slot 1:
Current startup saved-configuration file: flash:/startup.cfg
Next main startup saved-configuration file: flash:/startup.cfg
Next backup startup saved-configuration file: NULL
表1-2 display startup命令顯示信息描述表
字段 |
描述 |
MainBoard |
Master使用的本次及下次啟動的配置文件名 |
Current startup saved-configuration file |
當前啟動使用的配置文件 |
Next startup saved-configuration file |
下一次啟動時使用的配置文件 |
Slot n |
Standby設備(所在槽位號為n)使用的本次及下次啟動的配置文件名 |
【相關命令】
· startup saved-configuration
display this命令用來顯示當前視圖下生效的配置。
【命令】
display this
【視圖】
任意視圖
【缺省用戶角色】
network-admin
network-operator
【使用指導】
當用戶在某一視圖下完成一組配置之後,需要驗證是否配置成功,則可以執行display this命令來查看當前生效的配置。
需要注意的是:
· 有些已經生效的配置如果與缺省情況相同,則不顯示。
· 對於某些參數,雖然用戶已經配置,但如果這些參數所在的功能沒有生效,則不顯示。
· 在任意一個用戶界麵視圖下執行此命令,將會顯示所有用戶界麵下生效的配置。
【舉例】
# 顯示接口Ten-GigabitEthernet1/0/1下生效的配置(該顯示信息與設備當前的配置有關)。
<Sysname> system-view
[Sysname] interface Ten-GigabitEthernet 1/0/1
[Sysname-Ten-GigabitEthernet1/0/1] display this
#
interface Ten-GigabitEthernet1/0/1
#
return
# 顯示所有用戶界麵下生效的配置(該顯示信息與設備當前的配置有關)。
<Sysname> system-view
[Sysname] user-interface vty 0
[Sysname-ui-vty0] display this
#
user-interface aux 0
user-role network-operator
#
user-interface vty 0 15
authentication-mode none
user-role network-admin
#
return
reset saved-configuration命令用來刪除設備存儲介質中保存的下次啟動配置文件。
【命令】
reset saved-configuration [ backup | main ]
【視圖】
用戶視圖
【缺省用戶角色】
network-admin
【參數】
backup:刪除備用下次啟動配置文件。
main:刪除主用下次啟動配置文件。
【使用指導】
· 刪除操作會將配置文件從所有成員設備上徹底刪除,所以請慎用該命令。
· 如果當前設備的主備用下次啟動配置文件相同,僅執行一次刪除操作,係統隻會將相應的下次啟動配置文件設置為NULL,但不會刪除該文件。
· 不指定banckup和main參數時,缺省使用main。
【舉例】
# 刪除備用下次啟動配置文件。
<Sysname> reset saved-configuration backup
The saved configuration file will be erased. Are you sure? [Y/N]:y
Configuration file in flash is being cleared.
Please wait ...
..
MainBoard:
Configuration file is cleared.
Slot 2:
Erase next configuration file successfully
【相關命令】
· display saved-configuration
restore startup-configuration命令用於從指定TFTP服務器上下載配置文件並設置為設備的主用下次啟動配置文件。
【命令】
restore startup-configuration from tftp-server src-filename
【視圖】
用戶視圖
【缺省用戶角色】
network-admin
【參數】
tftp-server:TFTP服務器的IPv4地址或主機名,主機名為1~20個字符的字符串。
src-filename:源文件名,TFTP服務器上將要下載的文件的文件名。
【使用指導】
執行該命令會將指定配置文件下載到所有成員設備存儲介質的根目錄下,並設置為所有成員設備的主用下次啟動配置文件。對於成員設備使用不同存儲介質的情況(如,Master使用Flash,而Slave使用U盤),備份操作失敗。
FIPS模式下不支持該命令。
【舉例】
# 從IP地址為2.2.2.2的TFTP服務器上下載config.cfg文件作為設備的主用下次啟動配置文件。
<Sysname> restore startup-configuration from 2.2.2.2 config.cfg
Restoring the next startup-configuration file from 2.2.2.2. Please wait...finished.
Now restoring the next startup-configuration file from main board to backup board. Please wait...finished.
【相關命令】
· backup startup-configuration
save file-url命令用來將當前配置保存到指定文件,但不會將該文件設置為下次啟動配置文件。
save [ safely ] [ backup | main ] [ force ]命令用來將當前配置保存到存儲介質的根目錄,並將該文件設置為下次啟動配置文件。
【命令】
save file-url
save [ safely ] [ backup | main ] [ force ]
【視圖】
任意視圖
【缺省用戶角色】
network-admin
【參數】
file-url:文件路徑,必須以“.cfg”為後綴。
safely:以安全模式保存配置文件。如果不指定該參數,表示以快速保存方式保存配置文件。
backup:將該文件設置為備用下次啟動配置文件。當不指定backup和main時,係統缺省使用main。
main:將該文件設置為主用下次啟動配置文件。當不指定backup和main時,係統缺省使用main。
force:表示直接將當前配置保存到主用下次啟動配置文件,係統不再輸出交互信息。缺省情況下,用戶執行save命令,係統要求用戶輸入<Y>或<N>等參數來確認本次操作,如果在30秒內沒有確認,係統會自動退出本次操作。如果在執行save操作時使用了force參數,則係統會直接保存當前配置,不再需要用戶輸入任何信息。
【使用指導】
當執行save命令時,如果指定的文件名不存在,則係統會先創建該文件,再執行保存操作。如果指定的文件名存在,則會提示用戶是否覆蓋該文件,如果用戶選擇不覆蓋,則不會繼續執行save命令。
當執行save [ safely ] [ backup | main ] [ force ]命令輸入的文件名和設備上已存在的文件同名時,
· 如果使用了safely參數,則係統會先將當前配置保存到一個臨時文件,保存成功後,再用這個臨時文件替換原同名文件。因此,即使在保存過程中出現設備重啟、斷電等問題導致配置保存失敗,仍然能夠以原同名的配置文件啟動設備。
· 如果沒有使用safely參數,則會直接覆蓋原同名文件。在保存過程中如果出現設備重啟、斷電等問題,結果是當前配置保存失敗,原同名文件已刪除,下次啟動文件為空。
【舉例】
# 將當前配置文件保存到指定配置文件backup.cfg,但不將該文件設置為下次啟動配置文件。
<Sysname> save backup.cfg
The current configuration will be saved to flash:/backup.cfg. Continue? [Y/N]:y
Now saving current configuration to the device.
Saving configuration
flash:/backup.cfg. Please wait...
Configuration is saved to flash successfully.
# 直接將當前配置保存到主用下次啟動配置文件,不再進行信息確認。
<Sysname> save force
Validating file. Please wait....
Configuration is saved to device successfully.
# 將當前配置保存到存儲介質的根目錄,並將該文件設置為下次啟動配置文件。
<Sysname> save
The current configuration will be written to the device. Are you sure? [Y/N]:y
Please input the file name(*.cfg)[flash:/startup.cfg]
(To leave the existing filename unchanged, press the enter key):
Validating file. Please wait...
Saved the current configuration to mainboard device successfully.
Slot 1:
Save next configuration file successfully.
【相關命令】
· display current-configuration
· display saved-configuration
startup saved-configuration命令用來配置下次啟動配置文件(係統下次啟動時使用的配置文件)。
undo startup saved-configuration命令用來設置設備以出廠配置啟動。
【命令】
startup saved-configuration cfgfile [ backup | main ]
undo startup saved-configuration
【缺省用戶角色】
network-admin
【參數】
cfgfile:配置文件的名稱,該文件必須是存儲介質根目錄下、後綴為.cfg的文件。
backup:將配置文件設置為備用下次啟動配置文件。
main:將配置文件設置為主用下次啟動配置文件。
【使用指導】
所有成員設備的下次啟動配置文件必須是相同的文件,因此,使用本命令前,請確保指定的配置文件已經保存在所有成員設備存儲介質的根目錄下,也不要把配置文件保存在U盤裏,設備不能從U盤讀取配置文件,否則,操作失敗。
使用該命令設置配置文件時:
· 不指定main和back參數時,缺省使用main。
· 主用下次啟動配置文件和備用下次啟動配置文件可以設置為同一文件,但為了更可靠,建議設置為不同的文件,或者將一份配置保存在兩個不同名的文件中,一個設置為主用,一個設置為備用。
· 在執行undo startup saved-configuration命令之後,係統會將主用/備用下次啟動配置文件均設置為NULL,但不會刪除該文件。
需要注意的是,執行undo startup saved-configuration命令並重啟IRF或IRF中的成員設備時,會導致IRF分裂,請謹慎使用。
# 配置下次啟動配置文件。
<Sysname> startup saved-configuration testcfg.cfg
Please wait ....
... Done!
【相關命令】
· display startup
不同款型規格的資料略有差異, 詳細信息請向具體銷售和400谘詢。H3C保留在沒有任何通知或提示的情況下對資料內容進行修改的權利!