思科路由器IOS系统和配置文件的备份、删除及还原

思科路由器IOS系统和配置文件的备份、删除及还原

续上篇讲的思科路由器的密码重置,本篇讲一下思科路由器iOS系统的备份、删除
还原。在生产情况下,很少有iOS文件的丢失的,大多是人为的删除,可能是为了安全,也有可能是恶意的删除,作为网络工程师,更多的时候会面对各种不同的意外情况,所以本篇就处理这个问题。

配置文件的备份、删除及还原

删除:
在我们配置命令的时候,通常是在特权模式下输入wr来保存文件的。这里就是将running-config文件复制到startup-config文件中,所以我们如果想清空配置命令的话,只需将startuo-config文件删除再重启设备即可。
删除配置文件:
R1#erase startup-config //删除启机配置文件
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm] //y 确认删除

备份
使用TFTP技术,搭建TFTP服务器。用copy的命令,将配置文件保存在TFTP服务器上,TFTP服务器可以是简单的电脑设备。只要具备TFTP服务即可。下面为具体步骤:
R1#copy startup-config tftp: //把启机配置文件,复制到Tftp服务器。
Address or name of remote host []? 192.168.1.1 //指定TfTP服务地址
Destination filename [R1-confg]? R1-2020.02.24-CFG //修改名字。

还原
Router#copy tftp: running-config //从Tftp服务器上复制文件到路由的running-config
Address or name of remote host []? 192.168.1.1 //指定服务器地址
Source filename []? R1-2020.02.24-CFG //指定源文件名称
Destination filename [running-config]? //是否改名
R1#wr //注意,恢复配置后,配置是在当前运行文件,需要记得保存,如果不保存,下次开机,依然空配.

IOS文件的删除、备份、还原

删除
删除IOS文件:
Router#delete flash: //删除Flash内的文件
Delete filename []?c2800nm-advipservicesk9-mz.124-15.T1.bin //指定删除什么文件. (文件名字可以通过show flash: 来查找)
Delete flash:/c2800nm-advipservicesk9-mz.124-15.T1.bin? [confirm] //确认删除.
注意:删除文件后,记得重启设备,不然没有效果。
备份
备份IOS文件:
R1#copy flash: tftp: //把Flash内的文件,复制到Tftp服务器
Source filename []? c2800nm-advipservicesk9-mz.124-15.T1.bin //指定Flash内的源文件
Address or name of remote host []? 192.168.1.1 //指定Tftp服务器
Destination filename [c2800nm-advipservicesk9-mz.124-15.T1.bin]? R1-c2800nm-advipservicesk9-mz.124-15.T1.bin //修改名字

还原
rommon 7 > tftpdnld //开始TFPT下载,如果没有配置正确的IP,掩码等信息,会得到以下提示:
Missing or illegal ip address for variable IP_ADDRESS
Illegal IP address.
usage: tftpdnld
Use this command for disaster recovery only to recover an image via TFTP.
Monitor variables are used to set up parameters for the transfer.
(Syntax: “VARIABLE_NAME=value” and use “set” to show current variables.)
“ctrl-c” or “break” stops the transfer before flash erase begins.
The following variables are REQUIRED to be set for tftpdnld:
IP_ADDRESS: The IP address for this unit
IP_SUBNET_MASK: The subnet mask for this unit
DEFAULT_GATEWAY: The default gateway for this unit
TFTP_SERVER: The IP address of the server to fetch from
TFTP_FILE: The filename to fetch
使用以上提示为路由器的第一个接口配置IP地址。
rommon 3 > IP_ADDRESS=192.168.1.254 //配置路由器地址
rommon 8 > IP_SUBNET_MASK=255.255.255.0 //配置路由掩码
rommon 9 > DEFAULT_GATEWAY=192.168.1.100 //配置路由器网关,当路由和服务器不是直连网络的时候,需要使用.
rommon 10 > TFTP_SERVER=192.168.1.1 //指定Tftp服务器地址
rommon 11 > TFTP_FILE=R1-c2800nm-advipservicesk9-mz.124-15.T1.bin //指定下载文件的名称
恢复配置:
注意.空配的设备,接口是没有IP的,如果需要在Tftp服务器上下载文件需要IP的封装,所以需要为路由器接口配置IP地址.

实例配置及命令

在这里插入图片描述
需求:
1、 R2备份配置,和IOS到Server上。
2、 删除R1的IOS文件,使用R2的IOS文件为R1进行恢复。
需求一:
R2:
R2#copy startup-config tftp:
输入命令后,输入TFTP服务器地址及文件命名。成功copy启动配置文件。
在这里插入图片描述
R2#copy flash: tftp:
输入命令后依次敲上文件名字,服务器地址,还有重新命名。成功备份。
在这里插入图片描述

最后查看服务器是否备份。
在这里插入图片描述

需求二:
删除文件IOS文件。
R1#delete flash:
输入命令后依次敲c2800nm-advipservicesk9-mz.124-15.T1.bin,Y 确认删除。
重启设备,可以发现之后就直接进入监控模式,无法进入用户模式。在这里插入图片描述

rommon 7 > tftpdnld //开始TFPT下载,如果没有配置正确的IP,掩码等信息,会得到以下提示:
rommon 3 > IP_ADDRESS=12.1.1.1 //配置路由器地址
rommon 8 > IP_SUBNET_MASK=255.255.255.0 //配置路由掩码
rommon 9 > DEFAULT_GATEWAY=12.1.1.2 //配置路由器网关,当路由和服务器不是直连网络的时候,需要使用.
rommon 10 > TFTP_SERVER=192.168.1.100 //指定Tftp服务器地址
rommon 11 > TFTP_FILE=c2800nm-advipservicesk9-mz.124-15.T1.bin //指定下载文件的名称
最后输入
rommon 7 > tftpdnld
输入Y确认保存。成功的修改。
在这里插入图片描述

重启设备,进入用户模式。成功还原。
在这里插入图片描述

最后

本篇讲的比较基础,为了方便以后遇到这种情况,所以记录一下,最后,感谢观看。谢谢!