Publish Date: June 22, 2015

Router’s Boot Sequence

When a router is powered on, it performs a series of steps known as boot sequence, to test the hardware and load the necessary software. The boot sequence consists of the following steps:

  1. When router is powered up, it performs Power On Self Test where tests the hardware to verify that all components of the device are present and operational. The POST is stored in and run from ROM (read-only memory).
  2. The bootstrap looks for the Cisco IOS and loads the IOS software. The bootstrap is a program in ROM which is responsible for finding where the IOS program is located and then loading the file. By default, the IOS software is loaded from flash memory in all Cisco routers.
  3. The IOS software looks for a valid configuration file stored in NVRAM. This file is called startup-config and is only there if an administrator copies the running-config file into NVRAM before reloading the router.
  4. If a startup-config file is found in NVRAM, the router will copy this file and place it in main memory (RAM) and the file is known as running-config. The router will use this file in real-time while up and running. The router should now be operational. If a startup-config file is not found in NVRAM, the router will broadcast out any interface to detect for a TFTP host looking for a configuration, and when that fails, router will start the setup mode configuration process.

Managing Configuration Register

Cisco Routers have a 16-bit software register written into NVRAM which is responsible for the behaviour of Router during boot up. By default, the configuration register is set to value 0x2102 which means load the Cisco IOS from flash memory and to load the startup-config file from NVRAM.

To view the configuration register settings you can use the command show version  in User EXEC mode or privilege EXEC mode.

Router#show version                
Cisco IOS Software, 1841 Software (C1841-ADVSECURITYK9-M), Version 12.4(3g), RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Mon 06-Nov-06 01:09 by alnguyen

ROM: System Bootstrap, Version 12.4(13r)T, RELEASE SOFTWARE (fc1)

Router uptime is 6 weeks, 3 days, 54 minutes
System returned to ROM by power-on
System image file is "flash:c1841-advsecurityk9-mz.124-3g.bin"

[output cut]

2 FastEthernet interfaces
1 Serial(sync/async) interface
1 Virtual Private Network (VPN) Module
DRAM configuration is 64 bits wide with parity disabled.
191K bytes of NVRAM.
62720K bytes of ATA CompactFlash (Read/Write)

Configuration register is 0x2102

The configuration register setting is shown in the last line of command output. The value 0x2102 is the default setting of Cisco router.

Changing the Configuration Register

You can change the configuration register value to modify the behavior of router during boot up. The setting of configuration register can be changed in many ways depending upon the state of router.

  • If router is up and running and you can access the router IOS (either via console or terminal), then you can change the register value using config-register global configuration mode command as shown below.
R1#config term
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#config-register 0x2142
R1(config)#^Z
R1#
*Jun 23 09:31:42.783: %SYS-5-CONFIG_I: Configured from console by console
R1#show version
Cisco IOS Software, 7200 Software (C7200-JK9S-M), Version 12.4(13b), RELEASE SOFTWARE (fc3)
[output cut]
4 FastEthernet interfaces
253K bytes of NVRAM.

1024K bytes of ATA PCMCIA card at slot 0 (Sector size 512 bytes).
8192K bytes of Flash internal SIMM (Sector size 256K).
Configuration register is 0x2102 (will be 0x2142 at next reload)

Notice the register value in last line is written 0x2102 but it will be 0x2142 after the      router will reboot. The configuration register setting does not take effect until router is restarted.

  • If you can not access the router because of lost password or any other reason, you   can still change configuration register setting. Note that this method can be used for lost Password Recovery on Cisco router. The default configuration register value is 0x2102. With the default setting, the router will load a
    configuration file stored in NVRAM (startup-config). To recover the router password, you need to set the register value to 0x2142, this will tell the router to ignore the NVRAM contents.

Steps for password recovery are:

  1. Power on the router and interrupt the boot sequence by pressing Ctrl+Break keys within 60 seconds when router is booting. This will take the router to what is known as ROMmon mode. You will see rommon 1> prompt in ROM Monitor mode.
  2. Change the configuration register value to 0x2142 by using confreg 0x2142 command.
  3. Type reset command to reload the router bypassing startup-config.
  4. Press Ctrl+C in order to skip the initial setup procedure. When you see Router> prompt, type enable to enter privileged EXEC mode. You will be taken to Router# prompt.
  5. Type configure memory or copy startup-config running-config in order to copy the startup-config into memory. Keep in mind that you do not run copy running-config startup-config command. This will erase your saved configuration.
  6. Enter into global configuration mode by using configure terminal command.
  7. Now you can set your enable password by using enable secret command and  line passwords by using line vty 0 4 commands.
  8. After setting up the password, change the configuration register value back to default by using config-register 0x2102 command.
  9. Save the running-config to startup-config using copy run start command.
  10. Now restart the router using reload command.

The whole process is shown below:

monitor: command "boot" aborted due to user interrupt
rommon 1 >
rommon 1 >confreg 0x2142
rommon 2 >reset
--- System Configuration Dialog ---

Would you like to enter the initial configuration dialog? [yes/no]: n


Press RETURN to get started!

Router>enable
Router#copy start run
Destination filename [running-config]? 
506 bytes copied in 3.868 secs (167 bytes/sec)
R1#configure terminal
R1(config)#enable secret NewPassword
R1(config)#line con 0
R1(config-if)#password NewPassword
R1(config)#line vty 0 4
R1(config-if)#password NewPassword
R1(config-if)#end
R1#copy run start
Destination filename [startup-config]? 
Building configuration...
[OK]
R1#reload

Manage Cisco IOS

You can configure your router to boot alternate IOS image if the file in flash is corrupted.
You can configure routers to boot from a TFTP host each time and in this way, you will never have to upgrade each router individually. This may be a smooth way to go because it allows you to just change one file on a TFTP host to perform an upgrade.

See the below configuration commands to configure router to load IOS from flash and if it fails then load IOS from TFTP host.

R1#
R1#config terminal
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#boot
R1(config)#boot ?
  bootldr    Boot loader (RxBoot) image name
  bootstrap  Bootstrap image file
  config     Configuration file
  host       Router-specific config file
  network    Network-wide config file
  system     System image file

R1(config)#boot system ?
  WORD   TFTP filename or URL
  flash  Boot from flash memory
  ftp    Boot from a server via ftp
  mop    Boot from a Decnet MOP server
  rcp    Boot from a server via rcp
  tftp   Boot from a tftp server

R1(config)#boot system flash ?
  WORD  System image filename
  <cr>

R1(config)#boot system flash c1841-advsecurityk9-mz.124-3g.bin
R1(config)#boot system tftp c1841-advsecurityk9-mz.124-3g.bin 192.168.0.10
R1(config)#end
R1#
Backup and Restore of IOS

It is always a good idea to copy the Router’s existing IOS file to a TFTP host as a backup. By default, the router’s flash memory is used to store the Cisco IOS.

Before upgrading the IOS on your router, it is recommended to verify that the flash has enough space to hold the new IOS image file. Look at the size of IOS file and make a note of it. Now you can use show flash command to view the flash memory capacity and free memory. Cisco IOS also supports some commands like dir, copy, delete, erase, cd, pwd, mkdir and rmdir etc. You can use these commands to manipulate the contents of flash.

Router#show flash:                 
-#- --length-- -----date/time------ path
1     17793652 Jul 22 2007 02:57:38 +10:00 c1841-advsecurityk9-mz.124-3g.bin
2         1821 Jul 22 2007 03:13:52 +10:00 sdmconfig-18xx.cfg
3      6036480 Jul 22 2007 03:14:30 +10:00 sdm.tar
4       861696 Jul 22 2007 03:14:54 +10:00 es.tar
5      1164288 Jul 22 2007 03:15:16 +10:00 common.tar
6         1038 Jul 22 2007 03:15:34 +10:00 home.shtml
7       113152 Jul 22 2007 03:15:54 +10:00 home.tar
[output cut]
35311616 bytes available (28700672 bytes used) 
Router#

In the last line of above command output you can see 35311616 bytes free (35MB) and 28700672 bytes used (28MB). This means the router has flash memory of 64 MB.

You can also check the size of flash under show version command as shown below:

Router#show version 
Cisco IOS Software, 1841 Software (C1841-ADVSECURITYK9-M), Version 12.4(3g), RELEASE SOFTWARE (fc2)
Technical Support: http://www.cisco.com/techsupport
Copyright (c) 1986-2006 by Cisco Systems, Inc.
Compiled Mon 06-Nov-06 01:09 by alnguyen

ROM: System Bootstrap, Version 12.4(13r)T, RELEASE SOFTWARE (fc1)

Router uptime is 6 weeks, 3 days, 6 hours, 52 minutes
System returned to ROM by power-on
System image file is "flash:c1841-advsecurityk9-mz.124-3g.bin"
[output cut]
2 FastEthernet interfaces
1 Serial(sync/async) interface
1 Virtual Private Network (VPN) Module
DRAM configuration is 64 bits wide with parity disabled.
191K bytes of NVRAM.
62720K bytes of ATA CompactFlash (Read/Write)

Configuration register is 0x2102
          
Router#

The text in Red color is showing the size of installed flash module which is approx. 64MB.

Notice that the filename in this example is c1841-advsecurityk9-mz.124-3g.bin. The main difference in the output of the show flash and show version commands is that the show flash command displays all files stored in flash memory but the show version command shows the actual name of the file router is using. You can keep more than one IOS files in flash if it has enough room but the router can use only one at a time. This can be configured by boot system command as discussed earlier.

Backup IOS Software

Once you have determined the free space in flash and filename of IOS software, now you can go ahead to backup the existing IOS software to TFTP server which can be restored back if new IOS software does not work properly due to any reason.

Before starting backup, you need to verify the connectivity to TFTP server by using ping command.

Router#ping 192.168.0.10 repeat 100
Type escape sequence to abort.
Sending 100, 100-byte ICMP Echos to 192.168.0.10, timeout
is 2 seconds:
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Success rate is 100 percent (100/100), round-trip min/avg/max
= 4/4/8 ms

100 percent success means you have solid connectivity for backup. Now you can use copy flash tftp command to copy the IOS file to the TFTP server. To avoid any typo, copy the name of IOS file from output of show version command.

Router#copy flash tftp
Source filename []?c1841-advsecurityk9-mz.124-3g.bin
Address or name of remote host []?192.168.0.10
Destination filename [c1841-advsecurityk9-mz.124-3g.bin]?[enter]
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
17793652 bytes copied in 62.15 secs (458535 bytes/sec)
Router#
Restore or Upgrade the Router IOS

The process of restore or upgrade is similar as of backup. Copy the new IOS file to TFTP server if you want to upgrade the IOS and run copy tftp flash command. You need to type the IP address of TFTP server and the file name. You can see the process of restoring IOS file with the same file name, the router will prompt you that the file with same name already exists. You need to type y to overwrite.

Router#copy tftp flash
Address or name of remote host []?192.168.0.10
Source filename []?c1841-advsecurityk9-mz.124-3g.bin
Destination filename [c1841-advsecurityk9-mz.124-3g.bin]?[enter]
%Warning: There is a file already existing with this name
Do you want to over write? [confirm][enter]
Accessing tftp://192.168.0.10/c1841-advsecurityk9-mz.124-3g.bin...
Loading c1841-advsecurityk9-mz.124-3g.bin from 192.168.0.10 (via
FastEthernet0/1): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 17793652 bytes]
17793652 bytes copied in 85.50 secs (291855 bytes/sec)
Router#

In above example, we just restored the same IOS version. If you are upgrading the IOS version on router, make sure the size of new IOS file is smaller than capacity of flash memory. In some cases if flash memory does not have enough space to hold both IOS images, you have to delete the old IOS file before running copy tftp flash command.

Backup and Restore of Configuration Files

When the router is up and running, any changes made to its configuration is saved in running-config. This is the file router uses in real-time. But when you need to reload the router, the contents of running-config got erased because it is stored in RAM. In order to retain the contents of running-config even after restart, you need to copy the running-config file to startup-config file by using copy running-config startup-config command or  copy run start for short. You can also use legacy command write-memory. The startup-config file is stored in NVRAM which is non-volatile unlike RAM.

You can also backup and restore the running-config and startup-config files to TFTP server similarly as IOS images. The command is copy running-config tftp.

Router#copy running-config tftp
Address or name of remote host []?192.168.0.10
Destination filename [router-confg]?router-confg
!!!!
789 bytes copied in 0.800 secs (980 bytes/sec)
Router#

While restoring the configuration, run the command copy tftp running-config.

Erasing the Configuration

To delete the startup-config file on router, use the command erase startup-configas shown below:

Router#erase startup-config
Erasing the nvram filesystem will remove all configuration files!
Continue? [confirm][enter]
[OK]
Erase of nvram: complete
Router#reload
System configuration has been modified. Save? [yes/no]:n
Proceed with reload? [confirm][enter]
*Jun 23 11:30:20.039: %SYS-5-RELOAD: Reload requested by console.
Reload Reason: Reload Command.

This command deletes the contents of NVRAM on the router. If you type reload at privileged mode and say no to saving changes, the router will reload and start into what is known as setup mode.

Back



Microsoft Certified | Cisco Certified