关于VRP配置文件的操作
目录前言:
关于华为网络设备操作系统VRP配置文件的操作是NA级别的内容,已经学过很久了,但到了真实环境使用时多多少少有一些不自然,原因无非是思考的深度不足且练习的次数也不足,虽然现在已经学到IE了,但发觉发现这些基础的操作在日常工作当中使用的次数还是挺频繁的, 单独用一小节来复习巩固一下;
场景一
客户只有一台设备,客户已经做了一些配置;我不想动客户当前的环境,但是又想要一个新的环境,这怎么搞?
思路:
- 将内存的当中内容全都刷到配置文件当中,比如名字是vrpcfg.zip
- 将此配置文件在VRP系统当中复制一份名为vrpcfg.zip.back,并且保存到自己本地电脑一份
- 将vrpcfg.zip文件删除掉或重置
- 重启设备这样就获得了一个干净的环境,并且会新生成一个vrpcfg.zip文件
- 自己做完测试之后,将vrpcfg.zip.back配置覆盖vrpcfg.zip文件
# 这是一个新的设备刚开始
<Huawei>dis version
Huawei Versatile Routing Platform Software
VRP (R) software, Version 5.130 (AR2200 V200R003C00)
<Huawei>dis startup
MainBoard:
Startup system software: null
Next startup system software: null
Backup system software for next startup: null
Startup saved-configuration file: flash:/vrpcfg.zip
Next startup saved-configuration file: flash:/vrpcfg.zip
Startup license file: null
Next startup license file: null
Startup patch package: null
Next startup patch package: null
Startup voice-files: null
Next startup voice-files: null
<Huawei>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 09:46:51 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
1,090,732 KB total (784,464 KB free)
# 简单做一些配置,将配置刷到硬盘当中,会生成一个vrpcfg.zip的文件
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn AR1
[AR1]int vlan 1
[AR1-Vlanif1]ip add 192.168.0.1 24
[AR1-Vlanif1]
<AR1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait.......
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<AR1>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 09:46:51 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 265 May 30 2023 09:55:25 private-data.txt
5 -rw- 567 May 30 2023 09:55:24 **vrpcfg.zip**
1,090,732 KB total (784,448 KB free)
# 拷贝配置文件
<AR1>copy vrpcfg.zip vrpcfg.zip.back
<AR1>reset saved-configuration # reset相当于直接清空了vrpcfg.zip当中的内容
<AR1>dir # 会发现大小变成了120
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 09:57:30 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 265 May 30 2023 09:55:25 private-data.txt
5 -rw- 567 May 30 2023 09:56:48 vrpcfg.zip.back
6 -rw- 120 May 30 2023 09:57:30 vrpcfg.zip
1,090,732 KB total (784,448 KB free)
# 当前的配置还在内存当中
<AR1>dis ip int bri
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
NULL0 unassigned up up(s)
Vlanif1 192.168.0.1/24 down down
# 重启时,问你内存当中的配置是否要保存到启动文件当中,选不保存
<AR1>reboot
Info: The system is comparing the configuration, please wait.
Warning: All the configuration will be saved to the next startup configuration.
Continue ? [y/n]:n
System will reboot! Continue ? [y/n]:y
Info: system is rebooting ,please wait...
# 重启完成之后就是一个干净的系统了,如下所示:
<Huawei>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 10:00:27 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 265 May 30 2023 09:55:25 private-data.txt
5 -rw- 567 May 30 2023 09:56:48 vrpcfg.zip.back
6 -rw- 120 May 30 2023 09:57:30 vrpcfg.zip
1,090,732 KB total (784,452 KB free)
做完测试之后,我已经把设备的配置搞的面目全非了,这时候帮客户把配置还原,怎么搞?
# 模拟我测试时的操作
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]sysn WWWDKFJD
[WWWDKFJD]int vlan 1
[WWWDKFJD-Vlanif1]ip add 192.168.0.5 24
<WWWDKFJD>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait........
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
# 再看
<WWWDKFJD>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 10:03:08 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 265 May 30 2023 09:55:25 private-data.txt
5 -rw- 567 May 30 2023 09:56:48 vrpcfg.zip.back # 客户的旧的配置
6 -rw- 570 May 30 2023 10:03:08 vrpcfg.zip # 我做测试时的配置
# 把客户的配置,直接覆盖到下一次启动的配置文件
<WWWDKFJD>copy vrpcfg.zip.back vrpcfg.zip
Copy flash:/vrpcfg.zip.back to flash:/vrpcfg.zip? (y/n)[n]:y
The file flash:/vrpcfg.zip exists. Overwrite it? (y/n)[n]:y
Deleting file permanently from flash will take a long time if needed...Done.
100% complete
Info: Copied file flash:/vrpcfg.zip.back to flash:/vrpcfg.zip...Done
<WWWDKFJD>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 10:03:08 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 265 May 30 2023 09:55:25 private-data.txt
5 -rw- 567 May 30 2023 09:56:48 vrpcfg.zip.back
6 -rw- 567 May 30 2023 10:04:30 vrpcfg.zip
# 不保存当前的配置,直接重启
<WWWDKFJD>reboot
Info: The system is comparing the configuration, please wait.
Warning: All the configuration will be saved to the next startup configuration.
Continue ? [y/n]:n
System will reboot! Continue ? [y/n]:y
Info: system is rebooting ,please wait...
# 客户的配置又重新回来了
<AR1>dis ip int bri
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 unassigned down down
GigabitEthernet0/0/1 unassigned down down
GigabitEthernet0/0/2 unassigned down down
NULL0 unassigned up up(s)
Vlanif1 192.168.0.1/24 down down
场景二
一线一工程师,从客户那里收集了配置文件交给我,我要在公司测试设备上重新跑一下,看是否能复现客户现场的故障。假如从客户收集的客户的配置文件是bresee.zip,测试设备本身就已经有配置了,这个配置还有很多同事要使用,不能丢;
- 步骤,特别简单:
- 将当前的配置刷到硬盘当中,并备份当前的配置文件
- 将客户给的配置文件上传到设备当中
- 更改设备下一次开机使用的配置文件为客户的配置文件
- 测试完之后,把下一次开机启动的指向再改回来
# 当前设备的初始配置
<AR1>save
The current configuration will be written to the device.
Are you sure to continue? (y/n)[n]:y
It will take several minutes to save configuration file, please wait........
Configuration file had been saved successfully
Note: The configuration file will take effect after being activated
<AR1>dir
Directory of flash:/
Idx Attr Size(Byte) Date Time(LMT) FileName
0 drw- - May 30 2023 09:46:55 dhcp
1 -rw- 121,802 May 26 2014 09:20:58 portalpage.zip
2 -rw- 2,263 May 30 2023 10:05:33 statemach.efs
3 -rw- 828,482 May 26 2014 09:20:58 sslvpn.zip
4 -rw- 265 May 30 2023 09:55:25 private-data.txt
6 -rw- 567 May 30 2023 10:04:30 **vrpcfg.zip**
1,090,732 KB total (784,452 KB free)
# 默认下一次启动还是从vrpcfg.zip当前启动
<AR1>dis startup
MainBoard:
Startup system software: null
Next startup system software: null
Backup system software for next startup: null
**Startup saved-configuration file: flash:/vrpcfg.zip**
**Next startup saved-configuration file: flash:/vrpcfg.zip**
Startup license file: null
Next startup license file: null
Startup patch package: null
Next startup patch package: null
Startup voice-files: null
Next startup voice-files: null
# 把客户的配置文件bresee.zip上传到设备上
<AR1>dir
5 -rw- 567 May 30 2023 09:56:48 **bresee.zip**
6 -rw- 594 May 30 2023 10:14:58 vrpcfg.zip
#
<AR1>startup saved-configuration flash:/bresee.zip
This operation will take several minutes, please wait...
Info: Succeeded in setting the file for booting system
<AR1>dis startup
MainBoard:
Startup system software: null
Next startup system software: null
Backup system software for next startup: null
**Startup saved-configuration file: flash:/vrpcfg.zip**
**Next startup saved-configuration file: flash:/bresee.zip**
# 重启,问当前的配置是否配置,不保存
# 我们当前的配置已经保存过了,一旦在这里保存就会破坏客户的配置文件
<AR1>reboot
Info: The system is comparing the configuration, please wait.
Warning: All the configuration will be saved to the next startup configuration.
Continue ? **[y/n]:n**
System will reboot! Continue ? [y/n]:y
Info: system is rebooting ,please wait...
# 再开机就是客户的配置了!
Press any key to get started
<bresee>
# 测试完特准再把指向还原回去
<bresee>startup saved-configuration flash:/vrpcfg.zip
This operation will take several minutes, please wait...
Info: Succeeded in setting the file for booting system
<bresee>reboot
Info: The system is comparing the configuration, please wait.
Warning: All the configuration will be saved to the next startup configuration.
Continue ? [y/n]:n
System will reboot! Continue ? [y/n]:y
Info: system is rebooting ,please wait...
# 完美,又还原到了AR1
Press any key to get started
<AR1>
<AR1>
标签:rw,配置文件,zip,May,09,vrpcfg,VRP,30,操作
From: https://www.cnblogs.com/yizhangheka/p/17444089.html