今天要做的测试是模拟cisco路由器的IOS文件丢失,如何恢复路由器的IOS文件
实验环境:
cisco2611路由器,PC机装上TFTP软件搭建TFTP服务器。
在删除路由器IOS文件之前,要把路由器的IOS文件先备份到TFTP服务器上。
1、首先删除路由器上的flash文件
Router#erase flash:
Erasing the flash filesystem will remove all files! Continue? [confirm]
Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee
ee ...erasedee
Erase of flash: complete
Router#dir
Directory of flash:/

No files in directory

16252928 bytes total (16252928 bytes free)
Router#dir nv
Router#dir nvram:
Directory of nvram:/

   27  -rw-         508                startup-config
   28  ----           5                private-config
    1  -rw-           0                ifIndex-table

29688 bytes total (28099 bytes free)
2、IOS文件删除完成后reload重启一下路由器。
Router#reload
Proceed with reload? [confirm]

00:02:35: %SYS-5-RELOAD: Reload requested
System Bootstrap, Version 12.2(7r) [cmong 7r], RELEASE SOFTWARE (fc1)
Copyright (c) 2002 by cisco Systems, Inc.
C2600 platform with 32768 Kbytes of main memory

device does not contain a valid magic number
boot: cannot open "flash:"
boot: cannot determine first file name on device "flash:"

System Bootstrap, Version 12.2(7r) [cmong 7r], RELEASE SOFTWARE (fc1)
Copyright (c) 2002 by cisco Systems, Inc.
C2600 platform with 32768 Kbytes of main memory
3、到这里,可以看到,路由器启动过程被中断了,因为找不到IOS文件。
device does not contain a valid magic number
boot: cannot open "flash:"

4、现在,该是我们大显身手的时候了,按Ctrl+Break进入rommon模式,
   输入set查看路由器的配置情况。
rommon 1 > set
PS1=rommon ! >
BSI=0
RET_2_RTS=
5、紧接着要做的就是配置路由器的IP地址,子网掩码,网关,TFTP服务器地址,
   以及TFTP文件名,这五项是必须要输入的,当然了,还有几项是选择输入的,
   这里不多讲了。
rommon 2 > IP_ADDRESS=192.168.3.1
rommon 3 > IP_SUBNET_NETMASK=255.255.255.0
rommon 4 > DEFAULT_GATEWAY=192.168.3.254
rommon 5 > TFTP_SERVER=192.168.3.10
rommon 6 > TFTP_FILE=c2600-i-mz.122-8.T10.bin
6、做完这些配置之后,可以再次输入set命令来查看一下刚刚配置的是否有错误。
7、下一步,就要输入tftpdnld命令来下载IOS文件了。
rommon 7 > tftpdnld

          IP_ADDRESS: 192.168.3.1
      IP_SUBNET_MASK: 255.255.255.0
     DEFAULT_GATEWAY: 192.168.3.254
         TFTP_SERVER: 192.168.3.10
           TFTP_FILE: c2600-i-mz.122-8.T10.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
文件正在下载中,请稍后,呵呵......
Receiving c2600-i-mz.122-8.T10.bin from 192.168.3.10 !!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
File reception completed.
Copying file c2600-i-mz.122-8.T10.bin to flash.
Erasing flash at 0x60fc0000
program flash location 0x60590000
8、到现在为止,IOS文件已经从TFTP服务器上下载完成了。reset重启路由器。
rommon 8 > reset
System Bootstrap, Version 12.2(7r) [cmong 7r], RELEASE SOFTWARE (fc1)
Copyright (c) 2002 by cisco Systems, Inc.
C2600 platform with 32768 Kbytes of main memory

program load complete, entry point: 0x80008000, size: 0x5942dc
Self decompressing the p_w_picpath : #################################################
############################################## [OK]
此时,路由器已经可以正常启动了!
以下省略n行部分路由器启动过程,
当路由器启动完成后,进入特权模式,查询ios文件是否导入到路由器中
Router#dir
Directory of flash:/

    1  -rw-     5850064                c2600-i-mz.122-8.T10.bin

16777216 bytes total (10927088 bytes free)
OK,困难排除了,路由器可以正常工作了。