Tuesday, June 21, 2011

Restore the Cisco IOS to a router



Have you ever accidentally wiped out the IOS on your router?If you're working quickly and not paying attention, it can be an easy mistaketo make. All it takes is making a typo in the destination filename when you'retrying to save a change.

Here's an example:

router# copy running-config startp-configDestination filename [startp-config]? Erase flash: before copying? [confirm]Erasing the flash filesystem will remove all files!
Continue? [confirm]

Hitting [Enter] a couple of times out of habit can all tooquickly wipe out the IOS. If you don't realize the mistake in time, rebootingthe router means the IOS is gone for good, and the router won't boot up.

Losing the IOS can also happen when upgrading the flash onthe router. As the Cisco IOS grows larger, having to upgrade your flash is a verycommon task. But when you install the new flash, it has no IOS, leaving you inthe same position as if you had accidentally erased the flash.

Unfortunately, if you're like many people, when you wipe outthe IOS, you may not have a backup copy of the IOS. Or, you may not have accessto the Cisco IOS download site or have the time to download the somewhat largeIOS file.

And if you're looking for the same IOS on all of yourrouters, it can be difficult to locate it on the Cisco IOS download site. Manytimes, it's much easier to take the IOS from an existing router and restore iton the router that's missing its IOS.

Let's look at the step-by-step process for restoring theCisco IOS to a router using this method.
Install a TFTP server

First you need to install a (TFTP) server. I recommend theTftpd32 server, which you can download from theWeb. This is a great TFTP server, without a lot of the fluff that most ofthe others have. At less than 1 MB, it's very small and has no installapplication.
Run the TFTP server on a PC

If you've just pulled the working router off a shelf, youcan connect the PC to the router with a reverse Ethernet cable. Configure therouter and PC on the same network. Make sure that you can ping the router and thatthe router can ping you.

If your working router is up on your network, you can just downloadthe IOS over the network directly using instructions in the next section.
Copy the IOS from the working router to the PC

Here's an example of how to accomplish this:

copy c2600-12-3.xxxx.bin tftp://10.253.15.72

Replace 10.253.15.72 with the IP address of your PC, andreplace c2600 with the name of your IOS. (You can locate the name of the IOS onthe working router using the show flashcommand.)

This saves the IOS on the PC in the directory configured bythe TFTP server. Figure A shows anexample of what it looks like while downloading. Make sure to note thedirectory in which you'll save the IOS.
Download the IOS to the nonworking router

The best way to accomplish this is via Ethernet. Thealternative—using XMODEM through the console—will be very slow, even if youincrease the serial port baud rate to the maximum. So, instead, connect thePC's reverse Ethernet cable to the nonworking router (or use twonormal/straight-through Ethernet cables and a switch).

Without an IOS, the nonworking router will boot up in ROMmonmode. The prompt will look like this:

rommon>

Verify the necessary settings

On the console of the nonworking router while in ROMmonmode, use the set command to displaythe current settings, which the program will use to download the IOS via TFTP. (Fora Cisco example of these steps, check out this Ciscodocumentation.)

For example, here are the settings you must set for the tftpdnld command to work:

rommon> setIP_ADDRESS=10.253.100.126IP_SUBNET_MASK=255.255.0.0TFTP_SERVER=10.253.15.72DEFAULT_GATEWAY=10.253.1.1TFTP_FILE={the name of the IOS that is saved on the PC}

However, your settings may not contain any of the requiredvariables for the tftpdnld command.By default, it may look something like this:

rommon 9 > setPS1=rommon ! > BSI=0RET_2_RUTC=0RET_2_RTS=?=1

If this is the case, set the required variables. While itmight seem obvious to use the setcommand to set the variables, you can actually set the variables simply by enteringthe name of the variable, the equal sign [=], and the value.

For example, to set the IP address of the broken router, youwould use the following:

IP_ADDRESS=10.253.100.126

Final steps

After setting your values, run the tftpdnld command, which will replace the IOS. Listing A provides an example of how I restored a router.
An alternate approach to the tftpdnld command

However, if the tftpdnldcommand doesn't work for some reason, you can use the xmodem command to send the IOS over the serial console line. (Forinstructions for this process, checkout this Cisco documentation.) However, if you decide to take this route,it's a good idea to change the baud rate on the console and your PC to 115,200so it doesn't take more than four hours for an 8-MB IOS file to transfer overthe 9600-baud console.

On a final note, keep in mind that different models of Ciscorouters and different Cisco firmware versions respond differently. For example,these commands performed on a 2600 series router may not work on a 3600 seriesrouter. However, the basic process remains the same.

By David "Davis CCIE, MCSE+I, SCSA"
March 24, 2005, 8:00am PST

No comments:

Post a Comment