Cisco

Restore the Cisco IOS to a router

Have you ever accidentally wiped out the IOS on your router? If you're not paying attention, it can be an easy mistake to make. While you have a few options for rectifying this, your best bet is to take the IOS from an existing router and restore it on the nonworking router. David Davis tells you how.

Want to learn more about router and switch management? Automatically sign up for our free Cisco Routers and Switches newsletter, delivered each Friday!

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 mistake to make. All it takes is making a typo in the destination filename when you're trying to save a change.

Here's an example:

router# copy running-config startp-config
Destination 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 too quickly wipe out the IOS. If you don't realize the mistake in time, rebooting the 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 on the router. As the Cisco IOS grows larger, having to upgrade your flash is a very common task. But when you install the new flash, it has no IOS, leaving you in the same position as if you had accidentally erased the flash.

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

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

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

Install a TFTP server

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

Run the TFTP server on a PC

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

If your working router is up on your network, you can just download the 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, and replace c2600 with the name of your IOS. (You can locate the name of the IOS on the working router using the show flash command.)

This saves the IOS on the PC in the directory configured by the TFTP server. Figure A shows an example of what it looks like while downloading. Make sure to note the directory in which you'll save the IOS.

Download the IOS to the nonworking router

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

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

rommon>

Verify the necessary settings

On the console of the nonworking router while in ROMmon mode, use the set command to display the current settings, which the program will use to download the IOS via TFTP. (For a Cisco example of these steps, check out this Cisco documentation.)

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

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

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

rommon 9 > set
PS1=rommon ! > 
BSI=0
RET_2_RUTC=0
RET_2_RTS=
?=1

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

For example, to set the IP address of the broken router, you would 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 tftpdnld command doesn't work for some reason, you can use the xmodem command to send the IOS over the serial console line. (For instructions for this process, check out 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,200 so it doesn't take more than four hours for an 8-MB IOS file to transfer over the 9600-baud console.

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

David Davis has worked in the IT industry for 12 years and holds several certifications, including CCIE, MCSE+I, CISSP, CCNA, CCDA, and CCNP. He currently manages a group of systems/network administrators for a privately owned retail company and performs networking/systems consulting on a part-time basis.

0 comments

Editor's Picks

Figure A