华为交换机恢复出厂设置三种方法详解(PNP按钮/一键式/清空配置) - 夜莺博客

华为交换机恢复出厂设置三种方法详解(PNP按钮/一键式/清空配置)

华为 S 系列交换机(S5700/S6700 等 VRP 平台)需要利旧回收、密码遗失或配置混乱时,通常要恢复出厂设置。华为官方提供了三种方法:支持 PNP 键的机型可以免登录长按按键恢复,有登录权限时可用 reset factory-configuration 一键式恢复,或者通过 reset saved-configuration 清空配置文件后重启。本文整理三种方法的完整操作、命令输出差异以及恢复后的重新配置要点。

方法一:长按 PNP 按钮恢复出厂配置

带 PNP 按钮的机型(部分 S5700 及 CloudEngine 系列)无需登录即可恢复出厂设置:设备上电状态下,长按 PNP 按钮 6 秒以上,设备会自动恢复出厂设置并重新启动。该方法操作最简单,适合忘记密码、无法进入系统或远程不可达的应急场景。注意只有面板上带 PNP 键的型号才支持此方式。

方法二:reset factory-configuration 一键式恢复

在用户视图下执行一键式恢复命令,设备会删除所有配置和数据文件(startup、patch、module 和 license 文件除外),并自动重启:

<HUAWEI> reset factory-configuration
Warning: The command will delete all the configurations and files (except the
startup, patch, module, and license files) from the device. Continue? [Y/N]:y
Warning: The system will reboot after configurations and files are deleted.
Continue? [Y/N]:y

两次确认(y)后设备自动重新启动,恢复至出厂状态。

方法三:清空配置文件后重启

先删除保存的配置文件,再手动执行 reboot 重启。与一键式恢复不同,此方式只清除已保存的配置文件:

<HUAWEI> reset saved-configuration
Warning: The action will delete the saved configuration in the device.
The configuration will be erased to reconfigure. Continue? [Y/N]:y
Info: Succeeded in clearing the configuration in the device.

<HUAWEI> reboot
Warning: The configuration has been modified, and it will be saved to the next
startup saved-configuration file flash:/vrpcfg.zip. Continue? [Y/N]:n

重启提示保存配置时务必选择 n,否则会覆盖清空结果、把当前配置写回启动文件。

恢复出厂前:先备份配置

恢复出厂会删除所有 VLAN、接口、用户与 AAA 配置,操作前务必备份。最简单的办法是把 display current-configuration 的输出保存到本地文本;也可以把 vrpcfg.zip 通过 SFTP 上传到备份服务器:

<HUAWEI> system-view
[HUAWEI] ssh client first-time enable
[HUAWEI] sftp 10.1.1.1
sftp-client> put vrpcfg.zip

恢复出厂后的基本配置

设备重启后默认无管理地址,需要先配置管理接口 IP 和默认路由才能远程管理:

<HUAWEI> system-view
[HUAWEI] interface MEth 0/0/1
[HUAWEI-MEth0/0/1] ip address 10.1.1.2 24
[HUAWEI-MEth0/0/1] quit
[HUAWEI] ip route-static 0.0.0.0 0 10.10.10.10

没有独立管理口的型号可在 VLANIF 接口上配置管理 IP。恢复后请立即修改默认口令(如 admin/admin@huawei.com)并重新配置 SSH、ACL 等安全策略再接入业务网络。

站内延伸阅读

参考本站的华为交换机恢复出厂设置命令大全(含 BootROM 实操)Huawei S5700 Factory Reset: Three Official Methods(英文版)

原文链接:https://support.huawei.com/enterprise/zh/doc/EDOC1100088143