1、实验目的
通过本实验可以掌握:
- copy方式恢复IOS的步骤。
- TFTPDNLD方式恢复IOS的步骤。
- Xmodem方式恢复IOS的步骤。
2、实验拓扑
路由器IOS恢复的实验拓扑如下图所示。
3、实验步骤
如果工作中不慎误删除路由器IOS,或者升级了错误版本的IOS,导致路由器不能正常启动,动,可以通过COPY方式恢复IOS,也也可以通过TFTPDNLD恢复IOS,还可以用Xmodem方式通过Console端口恢复IOS,然而由于Console端口的速率很慢,除非万不得已,否则很少有人采用。需要注意的是,如果误删除了1OS,请不要将路由器关机或者重启,这样可以直接使用COPY方式从TFTP服务器恢复IOS,这比起上述其他2种方法都简单。注意,也可以通过命令tftp-server flash0:c2900-universalk9-mz.SPA.157-3.M.bin把路由器配置成TFTP服务器,这样就不需要单独的TFTP服务器了。
3.1、通过copy方式恢复IOS(TFTP服务器)
(1)查看IOS文件系统
R1#show file systems //查看IOS文件系统
File Systems:
Size(b) Free(b) Type Flags Prefixes
* 255744000 221896413 disk rw flash0: flash:#
262136 255005 nvram rw nvram:
R1#dir //查看Flash存储上的文件
Directory of flash0:/
3 -rw- 33591768 <no date> c2900-universalk9-mz.SPA.151-4.M4.bin
2 -rw- 28282 <no date> sigdef-category.xml
1 -rw- 227537 <no date> sigdef-default.xml
255744000 bytes total (221896413 bytes free)
以上输出列出了Flash、NVRAM和 USBFlash的总的可用空间和空闲空间的大小、文件系统的类型及其权限和文件系统的前缀名称。在命令输出的Flags字段中显示权限包括只读(ro)、只写(wo)和读写(rw)。值得注意的是usbflash0:只有在插入Flash后才会显示。Cisco交交换机和路由器上支持许多基本UNIX命令,如用于更改文件系统或目录的cd命令、用于显示文件系统目录的dir命令和用于显示当前工作目录的pwd命令等。
(2)删除IOS文件,模拟误删除
R1#delete flash:c2900-universalk9-mz.SPA.151-4.M4.bin //删除C2900的IOS文件
Delete filename [c2900-universalk9-mz.SPA.151-4.M4.bin]?
Delete flash:/c2900-universalk9-mz.SPA.151-4.M4.bin? [confirm]
R1#dir
Directory of flash0:/ //确认文件已被删除
2 -rw- 28282 <no date> sigdef-category.xml
1 -rw- 227537 <no date> sigdef-default.xml
255744000 bytes total (255488181 bytes free)
(3)从TFTP服务器192.168.1.100上复制 IOS
(4)路由器R1上的操作
R1#copy tftp: flash:
Address or name of remote host []? 192.168.1.100 //tftp服务器的IP地址
Source filename []? c2900-universalk9-mz.SPA.155-3.M4a.bin //粘贴文件名
Destination filename [c2900-universalk9-mz.SPA.155-3.M4a.bin]? //回车确认
Accessing tftp://192.168.1.100/c2900-universalk9-mz.SPA.155-3.M4a.bin....
Loading c2900-universalk9-mz.SPA.155-3.M4a.bin from 192.168.1.100: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 33591768 bytes]
33591768 bytes copied in 3.296 secs (1070084 bytes/sec)
R1#dir //查看Flash上的文件
Directory of flash0:/
4 -rw- 33591768 <no date> c2900-universalk9-mz.SPA.155-3.M4a.bin
2 -rw- 28282 <no date> sigdef-category.xml
1 -rw- 227537 <no date> sigdef-default.xml
255744000 bytes total (221896413 bytes free)
R1#write //保存配置文件
Building configuration...
[OK]
R1#reload //重启路由器
R1#show version //重启后查看IOS版本信息
Cisco IOS Software, C2900 Software (C2900-UNIVERSALK9-M), Version 15.5(3)M4a, RELEASE SOFTWARE (fc1)
3.2、通过copy方式恢复IOS(FTP服务器)
(1)设置FTP(192.168.1.100)服务器
(2)路由器上的配置
R1#dir
Directory of flash0:/
4 -rw- 33591768 <no date> c2900-universalk9-mz.SPA.155-3.M4a.bin
2 -rw- 28282 <no date> sigdef-category.xml
1 -rw- 227537 <no date> sigdef-default.xml
255744000 bytes total (221896413 bytes free)
R1#delete flash:c2900-universalk9-mz.SPA.155-3.M4a.bin //拷贝的文件名
Delete filename [c2900-universalk9-mz.SPA.155-3.M4a.bin]?
Delete flash:/c2900-universalk9-mz.SPA.155-3.M4a.bin? [confirm]
R1#conf t
R1(config)#ip ftp username cisco //配置登录ftp服务器的账号
R1(config)#ip ftp password cisco //配置登录ftp服务器的密码
R1#copy ftp: flash: //登录ftp服务器拷贝文件
Address or name of remote host []? 192.168.1.100 //设置ftp服务器的IP地址
Source filename []? c2900-universalk9-mz.SPA.155-3.M4a.bin //拷贝的文件名
Destination filename [c2900-universalk9-mz.SPA.155-3.M4a.bin]?
Accessing ftp://192.168.1.100/c2900-universalk9-mz.SPA.155-3.M4a.bin...
确认下载成功后即可继续使用。
3.3、通过TFTPDNLD恢复IOS
IOS丢失或者毁坏后,掉电或者重启,路由器加载IOS文件失败后,开机将进入 rommon(ROM监控)模式。恢复IOS之前请确保服务器上启动TFTP服务,并将IOS放置到正确的目录中。路由器配置步骤如下所述。
(1)删除IOS模拟故障
R1#delete flash:c2900-universalk9-mz.SPA.155-3.M4a.bin
Delete filename [c2900-universalk9-mz.SPA.155-3.M4a.bin]?
Delete flash:/c2900-universalk9-mz.SPA.155-3.M4a.bin? [confirm]
%Error deleting flash:/c2900-universalk9-mz.SPA.155-3.M4a.bin (No such file or directory)
R1#reload
System configuration has been modified. Save? [yes/no]:yes
Building configuration...
[OK]
Proceed with reload? [confirm]
(2)配置TFTPDNLD恢复IOS
rommon 1 > IP_ADDRESS=192.168.1.254
rommon 2 > IP_SUBNET_MASK=255.255.255.0
rommon 3 > DEFAULT_GATEWAY=192.168.1.100
rommon 4 > TFTP_SERVER=192.168.1.100
rommon 5 > TFTP_FILE=c2900-universalk9-mz.SPA.155-3.M4a.bin
rommon 6 > tftpdnld
IP_ADDRESS: 192.168.1.254
IP_SUBNET_MASK: 255.255.255.0
DEFAULT_GATEWAY: 192.168.1.100
TFTP_SERVER: 192.168.1.100
TFTP_FILE: c2900-universalk9-mz.SPA.155-3.M4a.bin
Invoke this command for disaster recovery only.
WARNING: all existing data in all partitions on flash will be lost!
Do you wish to continue? y/n: [n]: y
(3)成功拉取镜像后使用reset命令重启系统即可
rommon 9 > reset
3.4、通过Xmodem方式利用Console端口恢复IOS
在 SecureCRT窗口中,选择【传输】下拉菜单,然后单击【发送XModem[N]..】,传输菜单如图12-8所示。打开如图12-9所示窗口,选择IOS文件,单击【发送】按钮发送文件。如图12-10所示开始传输IOS 文件。由于速度很慢,通常需要几个小时,请耐心等待,通信速率为9 600bps,传送完毕后执行boot命令启动路由器。
实验至此结束。