Workflows
Find configured interfaces
Run show ip interface brief to list each interface with its IP address and status in a single table. Use this command to check which interfaces have addresses and which are up. An interface with no IP address shows unassigned in the IP-Address column. An interface that’s shut down shows administratively down in the Status column. The example uses the abbreviated form, sh ip int brief.
R1#sh ip int brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 10.10.10.1 YES manual up up
GigabitEthernet0/1 unassigned YES unset administratively down down
GigabitEthernet0/2 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
Find an interface MAC address
Run show interface <interface> to display an interface’s status and hardware details, including its MAC address. Find the line that begins with Hardware is. The value after address is is the MAC address the interface currently uses. The bia value in parentheses is the burned-in address, which the manufacturer assigned. The two values match unless someone configures a different MAC address on the interface.
R1#show interface g0/0
GigabitEthernet0/0 is up, line protocol is up (connected)
Hardware is CN Gigabit Ethernet, address is 0090.2b82.ab01 (bia 0090.2b82.ab01)
...
View and clear the MAC address table
Run show mac address-table dynamic to list the MAC addresses the switch has learned and the port where it learned each one. Each entry maps a MAC address to a VLAN and a port. A port with several entries, like Fa0/24 in this example, often connects to another switch or router.
SW1#show mac address-table dynamic
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
1 0001.9626.8970 DYNAMIC Fa0/24
1 000c.cf84.8418 DYNAMIC Fa0/24
1 0060.2fb3.9152 DYNAMIC Fa0/2
1 0090.2b82.ab01 DYNAMIC Fa0/1
1 00d0.9701.02a9 DYNAMIC Fa0/24
Run clear mac address-table dynamic to remove all dynamic entries. Clear the table when you want the switch to relearn addresses, for example after you move a device to a different port. The table stays empty until the switch receives new frames.
SW1#clear mac address-table dynamic
SW1#show mac address-table dynamic
Mac Address Table
-------------------------------------------
Vlan Mac Address Type Ports
---- ----------- -------- -----
View and add routes
Run show ip route to view the routes the router uses to forward packets. At the start, R1 has only a connected (C) route and a local (L) route for its one configured interface, G0/0. The connected route covers the interface’s subnet. The local route is a /32 host route for the interface’s own IP address.
R1>show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C 10.10.10.0/24 is directly connected, GigabitEthernet0/0
L 10.10.10.1/32 is directly connected, GigabitEthernet0/0
To add connected and local routes, assign an IP address to an interface and enable it with no shutdown. When the interface comes up, the router adds both routes for the new subnet. Run do show ip route to check the routing table without leaving configuration mode.
R1>enable
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int g0/1
R1(config-if)#ip address 10.10.20.1 255.255.255.0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/1, changed state to up
R1(config-if)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 4 subnets, 2 masks
C 10.10.10.0/24 is directly connected, GigabitEthernet0/0
L 10.10.10.1/32 is directly connected, GigabitEthernet0/0
C 10.10.20.0/24 is directly connected, GigabitEthernet0/1
L 10.10.20.1/32 is directly connected, GigabitEthernet0/1
A static route tells the router how to reach a remote subnet that has no connected route. Configure static routes in small networks, or for a stub network with only one path out, where you don’t need a routing protocol to learn routes. Run ip route in global configuration mode:
ip route <network> <mask> {<next-hop-ip> | <exit-interface>}
<network>and<mask>: The destination subnet.<next-hop-ip>: The IP address of the next router. R1 must already have a route to this address. In this example, the connected route for 10.10.10.0/24 reaches 10.10.10.2.<exit-interface>: The local interface that sends the packets. Use this option on point-to-point links.
The router marks the route with S. In [1/0], 1 is the administrative distance and 0 is the metric. A static route has a default administrative distance of 1, so the router prefers it over a route to the same subnet that a routing protocol learns.
R1(config-if)#exit
R1(config)#ip route 10.10.30.0 255.255.255.0 10.10.10.2
R1(config)#do show ip route
Codes: L - local, C - connected, S - static, R - RIP, M - mobile, B - BGP
D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area
N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2
E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP
i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area
* - candidate default, U - per-user static route, o - ODR
P - periodic downloaded static route
Gateway of last resort is not set
10.0.0.0/8 is variably subnetted, 5 subnets, 2 masks
C 10.10.10.0/24 is directly connected, GigabitEthernet0/0
L 10.10.10.1/32 is directly connected, GigabitEthernet0/0
C 10.10.20.0/24 is directly connected, GigabitEthernet0/1
L 10.10.20.1/32 is directly connected, GigabitEthernet0/1
S 10.10.30.0/24 [1/0] via 10.10.10.2
Configure a DNS server
Run ip name-server <ip-address> in global configuration mode to set the DNS server that the router queries to resolve hostnames. With a DNS server configured, you can use hostnames instead of IP addresses in commands such as ping and telnet.
R1(config)#ip name-server 10.10.10.10
Run show hosts to verify the configuration. The Name servers are line lists the configured DNS server. The table at the bottom lists cached hostname-to-address mappings and is empty until the router resolves a name.
R1(config)#do show hosts
Default Domain is not set
Name/address lookup uses domain service
Name servers are 10.10.10.10
Codes: UN - unknown, EX - expired, OK - OK, ?? - revalidate
temp - temporary, perm - permanent
NA - Not Applicable None - Not defined
Host Port Flags Age Type Address(es)
View the ARP table
Run show arp to list the IP-to-MAC address mappings the router has learned on its connected subnets. Use this command to confirm that the router can reach a neighbor at Layer 2, such as its next-hop router or a server. The Age (min) column shows how many minutes ago the router learned each entry. A - in that column marks the router’s own interface address.
R1#show arp
Protocol Address Age (min) Hardware Addr Type Interface
Internet 10.10.10.1 - 0090.0CD7.0D01 ARPA FastEthernet0/0
Internet 10.10.10.2 2 0004.9A96.A9A5 ARPA FastEthernet0/0
Internet 10.10.10.10 2 0090.21C6.D284 ARPA FastEthernet0/0
Troubleshoot an unreachable host
To troubleshoot an unreachable host:
- Run
pingto confirm that the host is unreachable. - Run
tracerouteto find the router where the path fails. - On that router, run
show ip interface briefto check interface status. - Fix the fault. For example, run
no shutdownon an interface that’s shut down. - Run
tracerouteagain to confirm that the router forwards traffic. - If a ping by hostname fails, check the
Translatingline for the DNS server address. - Replace a wrong DNS server with
no ip name-serverandip name-server. - Ping the host by hostname to confirm the fix.
Isolate the fault and check each layer
These steps follow a general method that applies to any reachability problem. First, isolate the device where the path fails. Then check that device from the bottom of the stack up. Use traceroute or a series of pings from the source toward the destination to find the last router that responds. The fault is usually on that router or the next hop after it. On that router, work through these checks in order:
| Check | Command | What to look for |
|---|---|---|
| Interface status | show ip interface brief | administratively down means the interface is shut down. down/down points to a physical problem. up/down points to a data link problem. |
| Addressing | show ip interface <interface> | An IP address and mask in the same subnet as the neighbor. |
| Routing | show ip route | A route to the destination subnet. |
| Next-hop neighbor | show arp | An ARP entry for the next-hop address. |
| Name resolution | show hosts | The correct DNS server address. |
Follow these rules as you work:
- Read the failure codes.
Ufrompingor!Hfromtraceroutemeans a router reported that it can’t forward the packet. A.or*means no reply arrived, which can also mean a missing return route. - Test with IP addresses before hostnames. If a ping by IP address succeeds but a ping by hostname fails, the problem is name resolution, not routing.
- Check both directions. A ping fails if the destination has no route back to the source. Check the routing table on each router in the return path too.
- Change one thing at a time. Test again after each change so you know which change fixed the problem.
Example: Restore R3’s connection to the DNS server
Confirm that the host is unreachable
In this example, R3 can’t reach the DNS server at 10.10.10.10. Both telnet and ping fail. In the ping output, each U means a router on the path returned an ICMP destination unreachable message. The . entries alternate with the U entries because IOS rate-limits the unreachable messages it sends.
R3>enable
R3#telnet 10.10.10.10
Trying 10.10.10.10 ...
% Connection timed out; remote host not responding
R3#ping 10.10.10.10
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.10, timeout is 2 seconds:
U.U.U
Success rate is 0 percent (0/5)
Find where the path fails
Run traceroute to find where the path fails. Traceroute sends probes with a time-to-live (TTL) of 1, then increases the TTL by 1 for each hop. Each router that decrements a probe’s TTL to 0 drops the probe and returns an ICMP time exceeded message, which identifies that router. IOS sends three probes per hop and displays one line per hop: the hop number, the address of the router that replied, and the round-trip time for each probe. An asterisk (*) means a probe timed out. A code such as !H means the router returned an error instead of forwarding the probe.
In this output, R2 (10.10.20.2) answers at the first hop, then returns !H (host unreachable) at the second hop. R2 has no route to 10.10.10.0/24, so the fault is on R2.
R3#traceroute 10.10.10.10
Type escape sequence to abort.
Tracing the route to 10.10.10.10
1 10.10.20.2 20 msec 0 msec 0 msec
2 10.10.20.2 !H * !H
3 * *
Bring up the interface on R2
On R2, run show ip interface brief. F0/0 (10.10.10.2) is administratively down, so R2 has no connected route to 10.10.10.0/24. Run no shutdown on the interface to bring it up and restore the connected route.
R2>enable
R2#show ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.10.10.2 YES NVRAM administratively down down
FastEthernet0/1 unassigned YES NVRAM administratively down down
FastEthernet1/0 10.10.20.2 YES NVRAM up up
FastEthernet1/1 unassigned YES NVRAM administratively down down
Vlan1 unassigned YES unset administratively down down
R2#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#int f0/0
R2(config-if)#no shutdown
R2(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config-if)#do sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.10.10.2 YES NVRAM up up
FastEthernet0/1 unassigned YES NVRAM administratively down down
FastEthernet1/0 10.10.20.2 YES NVRAM up up
FastEthernet1/1 unassigned YES NVRAM administratively down down
Vlan1 unassigned YES unset administratively down down
Verify the path with traceroute
Run traceroute from R3 again. R2 no longer returns !H, so it now forwards the probes toward 10.10.10.0/24.
R3#traceroute 10.10.10.10
Type escape sequence to abort.
Tracing the route to 10.10.10.10
1 10.10.20.2 0 msec 0 msec 0 msec
2 * * *
3 * * 0 msec
Fix the DNS server on R3
Next, ping R1 by hostname from R3. The ping fails because the Translating line shows R3 sending DNS queries to 10.10.10.1, which is R1, not the DNS server. Run no ip name-server 10.10.10.1 to remove the wrong server. Then run ip name-server 10.10.10.10 to point R3 to the correct DNS server. The ping by hostname then succeeds, which confirms that R3 can resolve names and reach the 10.10.10.0/24 subnet.
R3#ping R1
Translating "R1"...domain server (10.10.10.1)
% Unrecognized host or address or protocol not running.
R3#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R3(config)#no ip name-server 10.10.10.1
R3(config)#ip name-server 10.10.10.10
R3(config)#do ping R1
Translating "R1"...domain server (10.10.10.10)
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.10.10.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 0/2/9 ms
Set the hostname and assign an interface IP address
Run hostname <name> in global configuration mode to name the device. The prompt changes to the new name as soon as you press Enter. To assign an IP address, enter interface configuration mode and run ip address <address> <mask>. The Method column in show ip interface brief changes to manual for the configured interface. Router interfaces are shut down by default, so F0/0 stays administratively down until you run no shutdown.
Router>enable
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#hostname R2
R2(config)#do sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
R2(config)#int f0/0
R2(config-if)#ip address 10.10.10.2 255.255.255.0
R2(config-if)#
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.10.10.2 YES manual administratively down down
FastEthernet0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
To enable the interface, run no shutdown in interface configuration mode. The router logs the link and line protocol state changes, and show ip interface brief shows the interface as up/up. This example shows the same step on R1.
R1(config)#int f0/0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config-if)#do sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 10.10.10.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
Assign a management IP address to a switch
A Layer 2 switch forwards frames without an IP address, but it needs one before you can manage it remotely, for example with Telnet or SSH. Assign the address to a switch virtual interface (SVI), a logical Layer 3 interface for a VLAN. Every switch port is in VLAN 1 by default, so hosts on any port can reach the VLAN 1 SVI (Vlan1).
Run show vlan brief to see which ports belong to each VLAN. In this output, all ports are in VLAN 1. Then run show ip interface brief to check the interfaces. The physical ports are down/down, which means they have no link. Vlan1 is administratively down.
Switch>enable
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#hostname SW1
SW1(config)#do sh vlan brief
VLAN Name Status Ports
---- -------------------------------- --------- -------------------------------
1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4
Fa0/5, Fa0/6, Fa0/7, Fa0/8
Fa0/9, Fa0/10, Fa0/11, Fa0/12
Fa0/13, Fa0/14, Fa0/15, Fa0/16
Fa0/17, Fa0/18, Fa0/19, Fa0/20
Fa0/21, Fa0/22, Fa0/23, Fa0/24
Gig0/1, Gig0/2
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
SW1(config)#do sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/1 unassigned YES manual down down
...
Vlan1 unassigned YES manual administratively down down
To assign the address, run interface vlan 1, then ip address <address> <mask>. To show only the SVI, pipe show ip interface brief to include Vlan1. The SVI has its address but stays administratively down until you run no shutdown. The log messages at the end show Fa0/1 and Fa0/2 coming up as devices connect to them.
SW1(config)#int vlan1
SW1(config-if)#ip address 10.10.10.10 255.255.255.0
SW1(config-if)#
SW1#
%SYS-5-CONFIG_I: Configured from console by console
SW1#sh ip int brief | include Vlan1
Vlan1 10.10.10.10 YES manual administratively down down
To enable the SVI, run no shutdown in interface configuration mode.
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#int Vlan1
SW1(config-if)#no shutdown
The switch also needs a default gateway to reply to management traffic from other subnets. Run ip default-gateway <address> in global configuration mode. In this example, the gateway is R2 at 10.10.10.2. To verify the setting, run show running-config | include default-gateway. The output shows the configured gateway address.
SW1(config)#ip default-gateway 10.10.10.2
SW1(config)#do sh running-config | include default-gateway
ip default-gateway 10.10.10.2
Add an interface description
Run description <text> in interface configuration mode to label an interface. A description records what the interface connects to, so you and other administrators can identify links without tracing cables. The description has no effect on how the interface forwards traffic. It appears in show running-config, show interfaces, and show interfaces description.
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int f0/0
R1(config-if)#description Link to SW1
Find an interface’s speed and duplex
Run show interfaces <interface> to check the speed and duplex that an interface is using. Find the line that shows the duplex setting and speed, such as Full-duplex, 100Mb/s. Both ends of a link must use the same duplex setting. Don’t confuse this line with the BW value, which is a configurable bandwidth that routing protocols use to calculate metrics. The Description line shows the label you set with the description command.
SW1#sh int f0/1
FastEthernet0/1 is up, line protocol is up (connected)
Hardware is Lance, address is 00e0.8fd6.8901 (bia 00e0.8fd6.8901)
Description: Link to R1
BW 100000 Kbit, DLY 100 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation ARPA, loopback not set
Keepalive set (10 sec)
Full-duplex, 100Mb/s
Set an interface’s speed and duplex
By default, Ethernet interfaces autonegotiate speed and duplex with the device on the other end of the link. To set them manually, run duplex <full|half> and speed <10|100|1000> in interface configuration mode. Configure both values on both ends of the link. If you set both values on one end only, that end stops autonegotiating. The other end can sense the speed but defaults to half duplex at 10 or 100 Mbps, which causes a duplex mismatch.
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#int f0/2
SW1(config-if)#duplex full
SW1(config-if)#speed 100
Discover neighbors with CDP
Cisco Discovery Protocol (CDP) is a Cisco-proprietary Layer 2 protocol that Cisco devices use to advertise themselves to directly connected neighbors. CDP is enabled by default. Use it to confirm which device and port sit on the other end of a link without tracing cables. Run show cdp neighbors to list each neighbor’s hostname (Device ID), your local interface, the neighbor’s platform, and the neighbor’s port (Port ID). The Holdtme column shows how many seconds the device keeps the entry if no new advertisement arrives.
In this output, R1’s Fa0/0 connects to SW1’s Fa0/1:
R1>enable
R1#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
SW1 Fas 0/0 22 S 2960 Fas 0/1
CDP advertisements reveal device details such as the hostname, platform, and IOS version. Disable CDP on interfaces that connect to devices you don’t manage. To disable CDP on one interface, run no cdp enable in interface configuration mode. Here, SW1 lists R1 and R2 as neighbors, then disables CDP on Fa0/1, its link to R1:
SW1>enable
SW1#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
R2 Fas 0/2 172 R C2800 Fas 0/0
R1 Fas 0/1 172 R C2800 Fas 0/0
SW1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
SW1(config)#int f0/1
SW1(config-if)#no cdp enable
To disable CDP on every interface, run no cdp run in global configuration mode. To enable it again, run cdp run:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#no cdp run
R1(config)#cdp run
R1 runs CDP again, but its neighbor table is empty. The no cdp run command cleared the table, and R1 rebuilds it only as new advertisements arrive:
R1#show cdp neighbors
Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge
S - Switch, H - Host, I - IGMP, r - Repeater, P - Phone
Device ID Local Intrfce Holdtme Capability Platform Port ID
Reset a router and save its configuration
Run show running-config | exclude ! to view the running configuration without the ! separator lines. The exclude filter hides every line that contains the string you specify, so the output is shorter and easier to scan:
R1#sh running-config | exclude !
Building configuration...
Current configuration : 700 bytes
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
hostname R1
ip cef
no ipv6 cef
license udi pid CISCO2911/K9 sn FTX152447Z1
spanning-tree mode pvst
interface GigabitEthernet0/0
ip address 10.10.10.1 255.255.255.0
duplex auto
speed auto
interface GigabitEthernet0/1
no ip address
duplex auto
speed auto
shutdown
interface GigabitEthernet0/2
no ip address
duplex auto
speed auto
shutdown
interface Vlan1
no ip address
shutdown
ip classless
ip flow-export version 9
line con 0
line aux 0
line vty 0 4
login
end
To reset the router to a blank configuration, run write erase to erase the startup configuration from NVRAM. Then run reload to restart the router. The router boots with no saved configuration:
R1#write erase
Erasing the nvram filesystem will remove all configuration files! Continue? [confirm]y[OK]
Erase of nvram: complete
%SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram
R1#reload
Proceed with reload? [confirm]ySystem Bootstrap, Version 15.1(4)M4, RELEASE SOFTWARE (fc1)
The exec-timeout command sets how long an idle console session stays open before the router logs you out. The first value is minutes and the second is seconds, so exec-timeout 30 0 sets a 30-minute timeout. After you change the configuration, run copy run start to save the running configuration to the startup configuration. Changes you don’t save are lost when the router reloads:
R1(config)#line con 0
R1(config-line)#exec-timeout 30 0
R1(config-line)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
Recover a lost enable password
If you lose the enable password, you can’t enter privileged EXEC mode. To recover access without losing the saved configuration, you change the configuration register so the router ignores the startup configuration at boot. The configuration register is a 16-bit value that controls how the router boots. You then load the saved configuration, remove or replace the password, and set the register back to its default.
These are the general steps:
- Boot the router into ROMMON.
- Set the configuration register to
0x2142withconfreg, then restart withreset. - Answer
noto the initial configuration dialog. - Load the saved configuration with
copy start run. - Remove or replace the enable secret.
- Run
no shutdownon G0/0. - Set the configuration register back to
0x2102. - Save the configuration and reload.
How the configuration register controls booting
| Value | Boot behavior |
|---|---|
0x2102 | Default. Loads IOS and the startup configuration. |
0x2142 | Loads IOS but ignores the startup configuration. |
0x2120 | Boots into ROMMON instead of IOS. |
The last hex digit is the boot field. A 0 boots the router into ROMMON. The 4 in 0x2142 tells the router to ignore the startup configuration in NVRAM.
Set a password to recover
This example first sets an enable secret and saves it, so there’s a password to recover. The do prefix runs a privileged EXEC command from configuration mode:
R1(config)#enable secret Flackbox1
R1(config)#do copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
Boot into ROMMON
Set the configuration register to 0x2120 and reload. The router boots into ROMMON (ROM monitor), a minimal environment that runs before IOS loads. On a real router you’re locked out of, you can’t run config-register. Instead, you send a break signal from the console during boot to reach ROMMON:
R1(config)#config-register 0x2120
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#reload
Bypass the startup configuration
In ROMMON, confreg 0x2142 sets the register to ignore the startup configuration, and reset restarts the router. IOS boots with a blank running configuration, so the router starts the initial configuration dialog. Answer no:
rommon 1 > confreg 0x2142
rommon 2 > reset
Would you like to enter the initial configuration dialog? [yes/no]: no
The running configuration is blank. The hostname is the default Router, and G0/0 has no IP address:
Router#sh run | exclude !
Building configuration...
Current configuration : 695 bytes
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
hostname Router
no ip cef
no ipv6 cef
license udi pid CISCO2911/K9 sn FTX152447Z1
spanning-tree mode pvst
interface GigabitEthernet0/0
no ip address
duplex auto
speed auto
shutdown
The startup configuration is still in NVRAM. It contains the hostname R1, the enable secret, and the G0/0 address:
Router#sh start
Using 771 bytes
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
hostname R1
enable secret 5 $1$mERr$J2XZHMOgpVVXdLjC9lYtE1
no ip cef
no ipv6 cef
license udi pid CISCO2911/K9 sn FTX152447Z1
spanning-tree mode pvst
interface GigabitEthernet0/0
ip address 10.10.10.1 255.255.255.0
duplex auto
speed auto
interface GigabitEthernet0/1
no ip address
duplex auto
speed auto
shutdown
interface GigabitEthernet0/2
no ip address
duplex auto
speed auto
shutdown
interface Vlan1
no ip address
shutdown
ip classless
ip flow-export version 9
line con 0
exec-timeout 30 0
line aux 0
line vty 0 4
login
end
Restore the saved configuration
Run copy start run to load the startup configuration into the running configuration. The prompt changes to R1 because the router applies the saved hostname:
Router#copy start run
Destination filename [running-config]?
771 bytes copied in 0.416 secs (1853 bytes/sec)
R1#
The copy start run command merges the startup configuration into the running configuration instead of replacing it. G0/0 gets its IP address, but it keeps the shutdown command from the blank configuration because the startup configuration contains no no shutdown to remove it. G0/0 is administratively down:
R1#sh ip int brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 10.10.10.1 YES manual administratively down down
GigabitEthernet0/1 unassigned YES unset administratively down down
GigabitEthernet0/2 unassigned YES unset administratively down down
Vlan1 unassigned YES unset administratively down down
R1#sh run
Building configuration...
Current configuration : 781 bytes
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
hostname R1
enable secret 5 $1$mERr$J2XZHMOgpVVXdLjC9lYtE1
no ip cef
no ipv6 cef
license udi pid CISCO2911/K9 sn FTX152447Z1
spanning-tree mode pvst
interface GigabitEthernet0/0
ip address 10.10.10.1 255.255.255.0
duplex auto
speed auto
shutdown
Remove the password and restore the register
Bring up G0/0 with no shutdown, then remove the forgotten password with no enable secret. IOS accepts the global command from interface configuration mode and returns you to global configuration mode. Set the configuration register back to 0x2102 so the router loads the startup configuration on the next boot. If you leave it at 0x2142, the router ignores the saved configuration every time it reloads. Save the configuration and reload:
R1#conf t
Enter configuration commands, one per line. End with CNTL/Z.
R1(config)#int g0/0
R1(config-if)#no shutdown
R1(config-if)#
%LINK-5-CHANGED: Interface GigabitEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface GigabitEthernet0/0, changed state to up
R1(config-if)#no enable secret
R1(config)#config-register 0x2102
R1(config)#end
R1#
%SYS-5-CONFIG_I: Configured from console by console
R1#copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
R1#reload
Proceed with reload? [confirm]
Verify the recovery
After the reload, R1 loads its saved configuration. The enable command doesn’t prompt for a password, the running configuration has no enable secret, and G0/0 is up/up. The NVRAM method shows that G0/0 got its address from the startup configuration:
R1>en
R1#sh run
Building configuration...
Current configuration : 722 bytes
version 15.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
hostname R1
no ip cef
no ipv6 cef
license udi pid CISCO2911/K9 sn FTX152447Z1
spanning-tree mode pvst
interface GigabitEthernet0/0
ip address 10.10.10.1 255.255.255.0
duplex auto
speed auto
R1#sh ip int brief
Interface IP-Address OK? Method Status Protocol
GigabitEthernet0/0 10.10.10.1 YES NVRAM up up
Back up the configuration to flash and a TFTP server
Back up the configuration before you make major changes so you can restore it if something goes wrong. You can save a copy to the router’s flash memory or to a server on the network.
Run copy run flash to save the running configuration as a file in flash. At the prompt, enter a filename. Then run show flash to confirm that the file exists. The output lists each file with its size in bytes. Here, bak1 is 722 bytes, and the IOS image c2900-universalk9-mz.SPA.151-4.M4.bin is stored in the same directory:
R1#copy run flash
Destination filename [running-config]? bak1
Building configuration...
[OK]
R1#show flash
System flash directory:
File Length Name/status
6 722 bak1
3 33591768 c2900-universalk9-mz.SPA.151-4.M4.bin
4 696 demo
5 722 running-config
2 28282 sigdef-category.xml
1 227537 sigdef-default.xml
[33849727 bytes used, 221894273 available, 255744000 total]
249856K bytes of processor board System flash (Read/Write)
A backup in flash is lost if the router fails. To keep a copy off the router, run copy start tftp to send the startup configuration to a Trivial File Transfer Protocol (TFTP) server. Enter the server’s address and a filename. The router suggests R1-confg as the default name. This example saves the file as bak2 on the server at 10.10.10.10:
R1#copy start tftp
Address or name of remote host []? 10.10.10.10
Destination filename [R1-confg]? bak2
Writing startup-config....!!
[OK - 722 bytes]
722 bytes copied in 3.028 secs (238 bytes/sec)
Restore a deleted IOS image from a TFTP server
The router loads IOS from an image file in flash. If that file is deleted or corrupted, the router can’t boot IOS and stops at ROMMON (ROM monitor), a minimal environment with no IOS commands and no interface configuration. ROMMON’s tftpdnld command downloads an IOS image from a TFTP server and writes it to flash. To use it, you need a copy of the image on a TFTP server before the failure happens.
These are the general steps:
- Back up the configuration to flash and to the TFTP server.
- Copy the IOS image to the TFTP server with
copy flash tftp. - Delete the image and reload. The router can’t boot and stops at ROMMON.
- Set the ROMMON variables that tell
tftpdnldhow to reach the TFTP server. - Run
tftpdnldto download the image to flash. - Run
resetto boot the restored image.
Back up the configuration
Save the running configuration to flash as Backup-1:
R1#copy run flash
Destination filename [running-config]? Backup-1
Building configuration...
[OK]
R1#show flash
System flash directory:
File Length Name/status
5 728 Backup-1
Save the startup configuration to the TFTP server at 10.10.10.10 as Backup-2. This copy matters most. The tftpdnld warning later in this workflow says it erases all data on flash, which includes Backup-1:
R1#copy start tftp
Address or name of remote host []? 10.10.10.10
Destination filename [R1-confg]? Backup-2
Writing startup-config....!!
[OK - 698 bytes]
698 bytes copied in 3.007 secs (242 bytes/sec)
Back up the IOS image
Run show flash to find the IOS image filename. Here it’s c2900-universalk9-mz.SPA.151-4.M4.bin. Then run copy flash tftp and enter the source filename, the server address, and the destination filename. Press Enter at the destination prompt to keep the original name:
R1#show flash
System flash directory:
File Length Name/status
5 728 Backup-1
3 33591768 c2900-universalk9-mz.SPA.151-4.M4.bin
2 28282 sigdef-category.xml
1 227537 sigdef-default.xml
[33848315 bytes used, 221895685 available, 255744000 total]
249856K bytes of processor board System flash (Read/Write)
R1#copy flash tftp
Source filename []? c2900-universalk9-mz.SPA.151-4.M4.bin
Address or name of remote host []? 10.10.10.10
Destination filename [c2900-universalk9-mz.SPA.151-
4.M4.bin]?
Delete the image and reload
This lab deletes the IOS image to simulate a lost or corrupted file. After the reload, the router finds no bootable image and stops at the rommon 1 > prompt:
R1#delete flash:c2900-universalk9-mz.SPA.151-4.M4.bin
Delete filename [c2900-universalk9-mz.SPA.151-4.M4.bin]?
Delete flash:/c2900-universalk9-mz.SPA.151-4.M4.bin?
[confirm]
R1#reload
Proceed with reload? [confirm]
Boot process failed...
The system is unable to boot automatically. The BOOT
environment variable needs to be set to a bootable
image.
rommon 1 >
Set the ROMMON variables
ROMMON doesn’t read the IOS configuration, so it doesn’t know the router’s IP address or where the TFTP server is. You supply that information with environment variables. Set each one with VARIABLE=value:
| Variable | Value in this example | Purpose |
|---|---|---|
IP_ADDRESS | 10.10.10.1 | IP address the router uses for the download |
IP_SUBNET_MASK | 255.255.255.0 | Subnet mask for IP_ADDRESS |
DEFAULT_GATEWAY | 10.10.10.1 | Gateway to reach a server on another subnet |
TFTP_SERVER | 10.10.10.10 | Address of the TFTP server |
TFTP_FILE | c2900-universalk9-mz.SPA.151-4.M4.bin | Image filename on the TFTP server |
The TFTP server is on the router’s own subnet, so the router reaches it directly and doesn’t use the gateway. This example sets DEFAULT_GATEWAY to the router’s own address.
Download the image with tftpdnld
Run tftpdnld. ROMMON lists the variables so you can check them, then warns that the command erases all data on flash. Enter y to continue:
rommon 2 > IP_ADDRESS=10.10.10.1
rommon 3 > IP_SUBNET_MASK=255.255.255.0
rommon 4 > DEFAULT_GATEWAY=10.10.10.1
rommon 5 > TFTP_SERVER=10.10.10.10
rommon 6 > TFTP_FILE=c2900-universalk9-mz.SPA.151-4.M4.bin
rommon 7 > tftpdnld
IP_ADDRESS: 10.10.10.1
IP_SUBNET_MASK: 255.255.255.0
DEFAULT_GATEWAY: 10.10.10.1
TFTP_SERVER: 10.10.10.10
TFTP_FILE: c2900-universalk9-mz.SPA.151-4.M4.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
Boot the restored image
After the download finishes, run reset to restart the router. The router boots the restored IOS image from flash:
rommon 8 > reset
Upgrade the IOS image on a switch
To upgrade a switch, copy the new IOS image from a TFTP server to flash, point the switch at the new image, and reload. Run show version before and after the upgrade to confirm which version the switch runs.
These are the general steps:
- Check the current IOS version with
show version. - Copy the new image from the TFTP server to flash with
copy tftp flash. - Set the image the switch boots with
boot system. - Save the configuration with
copy run start. - Reload the switch.
- Confirm the new version with
show version.
Run show version to see which IOS version the switch runs now:
SW1>en
SW1#sh version
Run copy tftp flash and enter the TFTP server address and the image filename. Press Enter at the destination prompt to keep the same filename in flash:
SW1#copy tftp flash
Address or name of remote host []? 10.10.10.10
Source filename []? c2960-lanbasek9-mz.150-2.SE4.bin
Destination filename [c2960-lanbasek9-mz.150-2.SE4.bin]?
If flash holds more than one image, use the boot system command to tell the switch which one to load. Save the configuration with copy run start so the boot system command persists through the reload. Then reload the switch:
SW1#config t
SW1(config)#boot system c2960-lanbasek9-mz.150-2.SE4.bin
SW1(config)#end
SW1#copy run start
SW1#reload
After the reload, show version confirms that the switch runs Version 15.0(2)SE4, the image you copied:
SW1>en
SW1#show version
Cisco IOS Software, C2960 Software (C2960-LANBASEK9-M), Version 15.0(2)SE4, RELEASE SOFTWARE (fc1)
...