H3C配置管理实验
实验拓扑
注:如无特别说明,描述中的R1或SW1对应拓扑中设备名称末尾数字为1的设备,R2或SW2对应拓扑中设备名称末尾数字为2的设备,以此类推
实验需求
- 按照图示连接到物理机,并配置IP地址(
设备IP地址配置到VirtualBox Host-Only Ethernet Adapter网卡网段
) - R1保存当前配置(
设置特定设备名,用作检验配置是否确认还原
) - 在R1上开启FTP服务
- 使用物理机访问R1的FTP服务,把R1的配置文件拷贝到本地
- 在R1上清空配置,重启R1,确认已配置为空配状态
- 再次在R1开启FTP服务,并把物理机拷贝的配置文件还原到路由器
- 更改R1的启动配置文件名
- 再次重启R1,确认配置已还原
实验步骤
一、编写配置内容
<H3C>sys
System View: return to User View with Ctrl+Z.
[H3C]int g0/0
[H3C-GigabitEthernet0/0]ip add
[H3C-GigabitEthernet0/0]ip address 192.168.56.10 24
[H3C-GigabitEthernet0/0]ping 192.168.56.1
Ping 192.168.56.1 (192.168.56.1): 56 data bytes, press CTRL+C to break
56 bytes from 192.168.56.1: icmp_seq=0 ttl=128 time=0.414 ms
56 bytes from 192.168.56.1: icmp_seq=1 ttl=128 time=0.466 ms
56 bytes from 192.168.56.1: icmp_seq=2 ttl=128 time=0.519 ms
56 bytes from 192.168.56.1: icmp_seq=3 ttl=128 time=0.207 ms
56 bytes from 192.168.56.1: icmp_seq=4 ttl=128 time=0.360 ms
--- Ping statistics for 192.168.56.1 ---
5 packet(s) transmitted, 5 packet(s) received, 0.0% packet loss
round-trip min/avg/max/std-dev = 0.207/0.393/0.519/0.107 ms
# 设置特定设备名并保存
[H3C]sysname R1-check
[R1-check]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...
Configuration is saved to device successfully.
二、配置FTP服务
# 开启FTP服务
[R1-check]ftp server enable
# 创建FTP服务用户
[R1-check]local-user zhangsan class manage
New local user added.
[R1-check-luser-manage-zhangsan]password simple admin12345
[R1-check-luser-manage-zhangsan]authorization-attribute user-role level-15
[R1-check-luser-manage-zhangsan]service-type ftp
[R1-check-luser-manage-zhangsan]
三、备份配置文件
在物理机通过FTP服务拷贝配置文件到本地
3.1、登录示例:
3.2、拷贝图中的设备配置文件到本地
四、清空R1设备配置
<R1-check>reset saved-configuration
The saved configuration file will be erased. Are you sure? [Y/N]:y
Configuration file in flash: is being cleared.
Please wait ...
Configuration file is cleared.
4.1、由于reset saved-configuration
命令只是清除已保存的配置,并不会一起清除当前正在运行的配置内容所以还需要清理掉目前正在运行的配置,两种方法(二选一):
方法A:直接从模拟器窗口关闭R1,再开启(利用断电丢失当前数据特性清除当前运行配置,因无需反复确认,故推荐此方法)
方法B:使用reboot
重启命令重启设备(请注意:reboot命令重启设备时,第一次确认提示是设备检测到配置被清空,询问是否要重新保存当前配置
。此次询问需要输入N来否定;第二次确认提示才是询问是否确认要重启
,此时再输入Y确认重启)
<R1-check>reboot
Start to check configuration with next startup configuration file, please wait.........DONE!
Current configuration may be lost after the reboot, save current configuration? [Y/N]:N
This command will reboot the device. Continue? [Y/N]:Y
Now rebooting, please wait...
4.2、重连R1设备检验是否已清空配置
%Nov 2 20:33:19:953 2023 R1-check DEV/5/SYSTEM_REBOOT: System is rebooting now.
Cryptographic algorithms tests passed.
Startup configuration file doesn't exist or is invalid.
Performing automatic configuration... Press CTRL_C or CTRL_D to break.
Automatic configuration attempt: 1.
Interface used: GigabitEthernet0/0.
Enable DHCP client on GigabitEthernet0/0.
Obtained an IP address for GigabitEthernet0/0: 192.168.56.101.
Failed to download file network.cfg.
Failed to resolve the IP address 192.168.56.101.
Failed to download file device.cfg.
Waiting for the next...
Automatic configuration is running, press CTRL_C or CTRL_D to break.
Automatic configuration is running, press CTRL_C or CTRL_D to break.
Automatic configuration is running, press CTRL_C or CTRL_D to break.
Automatic configuration is aborted.
Line con0 is available.
Press ENTER to get started.
<H3C>%Nov 2 20:34:18:864 2023 H3C SHELL/5/SHELL_LOGIN: Console logged in from con0.
<H3C> #<------设备名
<H3C>
<H3C>dis int g0/0 # 查看g0/0口信息
GigabitEthernet0/0
Current state: UP
Line protocol state: UP
Description: GigabitEthernet0/0 Interface
Bandwidth: 1000000 kbps
Maximum transmission unit: 1500
Allow jumbo frames to pass
Broadcast max-ratio: 100%
Multicast max-ratio: 100%
Unicast max-ratio: 100%
......
可以看到R1设备名以及之前在g0/0口配置的IP等信息都已清空
五、恢复设备配置
5.1、再次配置R1设备的IP地址、FTP服务及账户
等,详细步骤参考前文。
5.2、利用FTP服务将刚才备份到本地的两份配置文件上传回R1设备。详细步骤参考前文。
5.3、修改R1设备的启动文件:
<H3C>startup saved-configuration startup.cfg
Please wait...... Done.
5.4、重启R1设备,检验配置是否恢复(重启方法还是同上,二选一)
<H3C>reboot
Start to check configuration with next startup configuration file, please wait.........DONE!
Current configuration may be lost after the reboot, save current configuration? [Y/N]:N
This command will reboot the device. Continue? [Y/N]:y
Now rebooting, please wait...
%Nov 2 20:54:14:397 2023 H3C DEV/5/SYSTEM_REBOOT: System is rebooting now.
Cryptographic algorithms tests passed.
Line con0 is available.
Press ENTER to get started.
<R1-check>%Nov 2 20:54:44:299 2023 R1-check SHELL/5/SHELL_LOGIN: Console logged in from con0.
<R1-check> #设备名
<R1-check>dis int g0/0
GigabitEthernet0/0
Current state: UP
Line protocol state: UP
Description: GigabitEthernet0/0 Interface
Bandwidth: 1000000 kbps
Maximum transmission unit: 1500
Allow jumbo frames to pass
Broadcast max-ratio: 100%
Multicast max-ratio: 100%
Unicast max-ratio: 100%
Internet address: 192.168.56.10/24 (Primary) #IP配置
IP packet frame type: Ethernet II, hardware address: 0ee5-73ce-0105
......
重启后可以看到设备名和g0/0口的配置都已恢复