IOS恢复的2种方法
如果不小心把Router或者Switch的IOS删除了,特别是Flash中的IOS和ROM中的Mini IOS都没有了的话,连启动都不行的话,有什么方法恢复它呢?
是方法不只一种,而是两种。其实是我只知道两种:)
第一种方法:X-Modem
以前我曾经尝试过一种方法,就是当Flash被删除后,启动无法进入系统,可以用X-Modem来恢复它。当时我不小心删除了一台Cisco2950交换机的Flash IOS,导致系统无法启动,在查过不少资料后得到一个结论:唯一的方法通过X-Modem来恢复。我的恢复方法如下:
1、用控制线连接交换机console口与计算机串口1,用带有xmodem功能的终端软件连接(win2000 and xp的超级终端就带这功能)。
2、设置连接方式为串口1(如果连接的是其他串口就选择其他串口),速率9600,无校验,无流控,停止位1。或者点击默认设置也可以。
3、连接以后计算机回车出现交换机无ios的界面,一般的提示符是:switch:
4、拔掉交换机后的电源线重新启动交换机
5、在超级终端输入:
switch:flash_init
会出现如下提示:
Initializing Flash...
6:输入拷贝指令:
switch:copy xmodem: flash:image_filename.bin
出现如下提示:
Begin the Xmodem or Xmodem-1K transfer now...
7、系统提示不断出现C这个字母就可以开始传文件了
8、点击超级终端菜单:传送---发送文件,在
选项中选择Xmodem或者Xmodem-1K协议,然后选择ios的影像文件(*.bin),开始传送。
9、因为不能改速率,所以传送得很慢,我的大概传送了80分钟左右,请耐心等待。
10、传送完毕后提示:
File "xmodem:" successfully copied to ....
switch:
11、在提示符下输入
switch:boot
启用新的ios系统
12、重新加电完成恢复工作。
这个是我恢复的方法,现在看来非常的不科学,效率低。后来看了别人同样用X-Modem恢复IOS,但是效率要高的方法:
先打开超级终端,进入rommon 模式(Ctrl+Break组合键),键入confreg, 如下:
rommon 1 > confreg 回车
Configuration Summary
enabled are:
load rom after netboot fails
console baud: 9600
boot: image specified by the boot system commands
or default to: cisco2-C2600
do you wish to change the configuration? y/n [n]: y (选择 yes)
enable "diagnostic mode"? y/n [n]: n (选择 no)
enable "use net in IP bcast address"? y/n [n]: n (选择 no)
disable "load rom after netboot fails"? y/n [n]: n (选择 no)
enable "use all zero broadcast"? y/n [n]: n (选择 no)
enable "break/abort has effect"? y/n [n]: n (选择 no)
enable "ignore system config info"? y/n [n]: n (选择 no)
change console baud rate? y/n [n]: y (选择 yes)
enter rate: 0 = 9600, 1 = 4800, 2 = 1200, 3 = 2400
4 = 19200, 5 = 38400, 6 = 57600, 7 = 115200 [0]: 7 (选择 7,用最大的115200速率的xmodem传输)
change the boot characteristics? y/n [n]: n (选择 no)
Configuration Summary
enabled are:
load rom after netboot fails
console baud: 115200
boot: image specified by the boot system commands
or default to: cisco2-C2600
do you wish to change the configuration? y/n [n]: n (选择 no)
You must reset or power cycle for new config to take effect
rommon 2 > reset 回车
注意:在此时键入 reset键之前,开始定义串口速度(我的电脑---端口属性----串口速度调为115200),然后再修改超级终端里设置速率为115200,记住,一定这么做!否则出现乱码! 然后关闭这个超级终端,重新建立一个超级终端连接,(期间系统重新启动)启动后,出现rommon 1> 提示符
然后,输入
rommon 1> xmodem -r
Do not start the sending program yet...
Invoke this application only for disaster recovery.
Do you wish to continue? y/n [n]: y (选择 yes)
Ready to receive file ...
此时,在超级终端的菜单上的“传送”---“发送文件”----选择IOS镜像文件所在地以及选择使用“xmodem”协议,点击“发送”即可
然后等待10-20分钟左右就把3-6M的IOS灌进去了!
(修改回计算机串口与超级终端、路由器confreg下的xmodem等9600的传输速率)
(videre注:实际用的时候,我发现这个命令总是改不成功,后来发现在line con 0下面有了一个speed 115200,所以即使改register成功,启动以后router又执行speed 115200,还是不行,所以如果有这个问
,记得把这个语句no掉)
Router>en 进入新IOS的特权模式
Router#reload 重启系统
Proceed with reload? [confirm] 回车
00:01:04: %SYS-5-RELOAD: Reload requested
System Bootstrap, Version 11.3(2)XA4, RELEASE SOFTWARE (fc1)
Copyright (c) 1999 by cisco Systems, Inc.
TAC:Home:SW:IOS:Specials for info
PC = 0xfff0a530, Vector = 0x500, SP = 0x680127b0
C2600 platform with 24576 Kbytes of main memory
PC = 0xfff0a530, Vector = 0x500, SP = 0x80004684
monitor: command "boot" aborted due to user interrupt
rommon 1 > confreg ( 输入“confreg”命令)
Configuration Summary
enabled are:
load rom after netboot fails
console baud: 115200
boot: image specified by the boot system commands
or default to: cisco2-C2600
do you wish to change the configuration? y/n [n]: y (选择 yes)
enable "diagnostic mode"? y/n [n]: n (选择 no)
enable "use net in IP bcast address"? y/n [n]: n (选择 no)
disable "load rom after netboot fails"? y/n [n]: n (选择 no)
enable "use all zero broadcast"? y/n [n]: n (选择 no)
enable "break/abort has effect"? y/n [n]: n (选择 no)
enable "ignore system config info"? y/n [n]: n (选择 no)
change console baud rate? y/n [n]: y (选择 yes)
enter rate: 0 = 9600, 1 = 4800, 2 = 1200, 3 = 2400
4 = 19200, 5 = 38400, 6 = 57600, 7 = 115200 [7]: 0 (选择 0,改回用标准速率速率9600的xmodem传输)
change the boot characteristics? y/n [n]: n (选择 no)
Configuration Summary
enabled are:
load rom after netboot fails
console baud: 9600
boot: image specified by the boot system commands
or default to: cisco2-C2600
do you wish to change the configuration? y/n [n]: n
You must reset or power cycle for new config to take effect
rommon 2 >
此时手工改回计算机串口与超级终端2者传输速率为9600
然后敲入
rommon 2 >reset
( 最好关电源)
他的方法有两个地方和我的不一样,首先是他在启动后进入了rommon模式,其次是他修改了串口的速率,这样就比我快的多了。
[Page: ]
第二种方法:TFTP
本来在用X-Modem之前尝试用TFTP的方法来恢复,但是都没有成功,就以为TFTP方法行不同。但后来在网上看到,其实TFTP也是可以用的,而且效率可能更高。下面是别人恢复的方法,可惜我没实践过,因为我没有进入过rommon模式:
在一台机器上安装TFTP服务器软件,将IOS文件放置在TFTP服务器的默认根目录下,打开TFTP服务器,用控制线将这台机器与ROUTER连接起来,另外用交叉网线连接机器的网卡和ROUTER的以太口。(也可以用普通的网线将ROUTER和交换机相连再连接机器)做好以上工作后,打开机器的超级终端工具,连接上ROUTER,按Ctrl+Break组合键,此时窗口中出现的命令行提示符为: ROMMON 1 > (其中“1”代表命令行的行数)。在提示符后输入命令:
ROMMON 1 >IP_ADDRESS= ROUTER的IP地址(要和TFTP服务器在同一网段内)
ROMMON 2 >IP_SUBNET_MASK= ROUTER的子网掩码
ROMMON 3 >DEFAUT_GATEWAY= 默认网关地址 (可以没有,也可以是TFTP服务器)
ROMMON 4 >TFTP_SERVER= TFTP 服务器IP地址
ROMMON 5 >TFTP_FILE= IOS文件名(只给出文件名,不需要路径)
ROMMON 6 >tftpdnld 回车
注意:前面的几条命令必须使用大写,而最后的tftpdnld则要用小写。
在tftpdnld命令执行后,只要根据提示选择,就可完成文件的传输。当文件传输完后,将自动回到命令行下,输入reset重启ROUTER,重启后就又回到了熟悉的IOS模式下甚至连以前配置的信息都不会丢失。
注意的几个问题:
A.在连接运行tftp server的PC 机至路由器时,必需使用路由器的第一个以太口,即Ethernt0(对2500系列等),Ethernet0/0(对2600系列等),其它系列略有差别,可根据使用手册进行确定。
B.在使用连接电缆时,一定要用交叉线,因这种情况属DTE与DCE之间的连接。
C.在运行tftp server的PC 机上,一定要有相应的路由器的IOS映象文件,可以通过多种渠道和多种方式获得该文件。
D.tftp server的地址可以随意定义,但必须与路由器定义的地址在同一网段上。
可以看到,以上两种方法都需要有IOS文件,如果没有备份原文件的话,可以找个同一版本的IOS来替代。
Exec commands:
<1-99> Session number to resume
access-enable Create a temporary Access-List entry
access-template Create a temporary Access-List entry
archive manage archive files
cd Change current directory
clear Reset functions
clock Manage the system clock
cns CNS agents
configure Enter configuration mode
connect Open a terminal connection
copy Copy from one file to another
debug Debugging functions (see also 'undebug')
delete Delete a file
dir List files on a filesystem
disable Turn off privileged commands
disconnect Disconnect an existing network connection
dot1x Dot1x Exec Commands
enable Turn on privileged commands
erase Erase a filesystem
exit Exit from the EXEC
format Format a filesystem
fsck Fsck a filesystem
help Description of the interactive help system
lock Lock the terminal
login Log in as a particular user
logout Exit from the EXEC
mkdir Create new directory
more Display the contents of a file
name-connection Name an existing network connection
no Disable debugging functions
ping Send echo messages
pwd Display current working directory
rcommand Run command on remote switch
reload Halt and perform a cold restart
rename Rename a file
resume Resume an active network connection
rmdir Remove existing directory
rsh Execute a remote command
rtr RTR Exec Configuration
send Send a message to other tty lines
set Set system parameter (not config)
setup Run the SETUP command facility
show Show running system information
systat Display information about terminal lines
telnet Open a telnet connection
terminal Set terminal line parameters
test Test subsystems, memory, and interfaces
traceroute Trace route to destination
tunnel Open a tunnel connection
udld UDLD protocol commands
undebug Disable debugging functions (see also 'debug')
verify Verify a file
vlan Configure VLAN parameters
vmps VMPS actions
vtp Configure global VTP state
where List active connections
write Write running configuration to memory, network, or terminal
<1-99> Session number to resume
access-enable Create a temporary Access-List entry
clear Reset functions
connect Open a terminal connection
disable Turn off privileged commands
disconnect Disconnect an existing network connection
enable Turn on privileged commands
exit Exit from the EXEC
help Description of the interactive help system
lock Lock the terminal
login Log in as a particular user
logout Exit from the EXEC
mrinfo Request neighbor and version information from a multicast
router
mstat Show statistics after multiple multicast traceroutes
mtrace Trace reverse multicast path from destination to source
name-connection Name an existing network connection
ping Send echo messages
rcommand Run command on remote switch
resume Resume an active network connection
show Show running system information
ssh Open a secure shell client connection
systat Display information about terminal lines
telnet Open a telnet connection
terminal Set terminal line parameters
1)本机IP 与交换机VLAN 1地址同网段
2)开启TFTP,浏览到IOS文件
3)删除交换机中的BIN文件及其所在目录
Cisco3550BK#dir
Directory of flash:/
2 -rwx ; 0 Jan 1 1970 00:01:22 +00:00 env_vars
3 -rwx 344 Jan 1 1970 00:01:22 +00:00 system_env_vars
4 -rwx 616 Mar 1 1993 06:05:47 +00:00 vlan.dat
5 -rwx 5 Mar 1 1993 04:51:45 +00:00 private-config.text
8 drwx 64 Mar 1 1993 00:06:05 +00:00 c3550-i9q3l2-mz.121-20.EA1a
7 -rwx 4051 Mar 1 1993 04:51:45 +00:00 config.text
Cisco3550BK#cd c3550-i9q3l2-mz.121-20.EA1a
Cisco3550BK#dir
Directory of flash:/c3550-i9q3l2-mz.121-20.EA1a/
9 drwx 2688 Mar 1 1993 00:03:20 +00:00 html
91 -rwx 3447390 Mar 1 1993 00:04:24 +00:00 c3550-i9q3l2-mz.121-20.EA1a.bin
92 -rwx 255 Mar 1 1993 00:04:24 +00:00 info
15998976 bytes total (9356800 bytes free)
Cisco3550BK#delete c3550-i9q3l2-mz.121-20.EA1a.bin
Delete filename [/c3550-i9q3l2-mz.121-20.EA1a/c3550-i9q3l2-mz.121-20.EA1a.bin]?
Delete flash:/c3550-i9q3l2-mz.121-20.EA1a/c3550-i9q3l2-mz.121-20.EA1a.bin? [confirm]
Cisco3550BK#dir
Directory of flash:/c3550-i9q3l2-mz.121-20.EA1a/
9 drwx 2688 Mar 1 1993 00:03:20 +00:00 html
92 -rwx 255 Mar 1 1993 00:04:24 +00:00 info
15998976 bytes total (12804608 bytes free)
Cisco3550BK#del html
Delete filename [/c3550-i9q3l2-mz.121-20.EA1a/html]?
Cisco3550BK#delete info
Delete filename [/c3550-i9q3l2-mz.121-20.EA1a/info]?
Delete flash:/c3550-i9q3l2-mz.121-20.EA1a/info? [confirm]
Cisco3550BK#delete /force recursive c3550-i9q3l2-mz.121-20.EA1a
Cisco3550BK#archive download-sw /overwrite tftp://10.49.0.4/c3550-i5q3l2-tar.122-25.SEA.tar
examining image...
Loading c3550-i5q3l2-tar.122-25.SEA.tar from 10.49.0.4 (via Vlan1): !
extracting info (252 bytes)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 7748608 bytes]
Image info:
Version Suffix: i5q3l2-122-25.SEA
Image Name: c3550-i5q3l2-mz.122-25.SEA.bin
Version Directory: c3550-i5q3l2-mz.122-25.SEA
Ios Image Size: 6089728
Total Image Size: 7746048
Image Feature: LAYER_3|MIN_DRAM_MEG=64
Image Family: C3550
Extracting files...
Loading c3550-i5q3l2-tar.122-25.SEA.tar from 10.49.0.4 (via Vlan1): !
extracting info (252 bytes)
c3550-i5q3l2-mz.122-25.SEA/ (directory)
c3550-i5q3l2-mz.122-25.SEA/html/ (directory)
extracting c3550-i5q3l2-mz.122-25.SEA/html/more.txt (62 bytes)
extracting c3550-i5q3l2-mz.122-25.SEA/html/menu.css (1654 bytes)!
extracting c3550-i5q3l2-mz.122-25.SEA/html/back.htm (435 bytes)
extracting c3550-i5q3l2-mz.122-25.SEA/html/images/tab_left_active.gif (852 bytes)
extracting c3550-i5q3l2-mz.122-25.SEA/html/images/122353.gif (3132 bytes)!
extracting c3550-i5q3l2-mz.122-25.SEA/c3550-i5q3l2-mz.122-25.SEA.bin (6087424 bytes)!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
extracting c3550-i5q3l2-mz.122-25.SEA/info (252 bytes)!
extracting info.ver (252 bytes)
[OK - 7748608 bytes]
New software image installed in flash:c3550-i5q3l2-mz.122-25.SEA
Configuring system to use new image...done.
Cisco3550BK#verify c3550-i5q3l2-mz.122-25.SEA.bin
Verified c3550-i5q3l2-mz.122-25.SEA.bin
traceroute Trace route to destination
tunnel Open a tunnel connection
where List active connections