Configuring a Cisco Router

In the following sections, I’ll introduce the commands used to do basic router configuration.
You’ll use these commands (or should use them) on every router while you re configuring a Cisco router.

Setting a Router Hostname

 

Router#config t
Router(config)#hostname Kaya
Kaya(config)#

 

Setting Passwords

Here’s an example of setting all your passwords and then encrypting them in the plain configuration file:

Kaya#config t
Kaya(config)#line aux ?
<0-0> First Line number
Kaya(config)#line aux 0
Kaya(config-line)#password aux
Kaya(config-line)#login
Kaya(config-line)#line con 0
Kaya(config-line)#password console
Kaya(config-line)#login
Kaya(config-line)#exit
Kaya(config)#line vty 0 ?
<1-1180> Last Line number
<cr>
Kaya(config)#line vty 0 1180
Kaya(config-line)#password telnet
Kaya(config-line)#login
Kaya(config)#enable password todd
Kaya(config)#enable secret globalnet
Kaya(config)#service password-encryption
Kaya(config)#do show run
Building configuration…
[outut cut]
!
enable secret 5 $1$S0a2$rLcwXpbme3zIrl2.TS1kX.
enable password 7 010709005F
!
[output cut]
!
line con 0
exec-timeout 1 40
password 7 050809013243420C
logging synchronous
login
line aux 0
password 7 03054E13
login
line vty 0 4
password 7 105A0C150B1206
12 Chapter 1  Basic IOS Commands
login
line vty 5 1180
password 7 0010160A0A5E1F
login
!
[output cut]
Kaya(config)#no service password-encryption

Some other console helpful commands include the following. This sets the console timeout in second and minutes from 0-35791:
Kaya(config-line)#exec-timeout ?
This redisplays interrupted console input:
Kaya(config-line)#logging synchronous
Here’s an example of setting the exec-timeout and logging synchronous commands:
Kaya#config t
Kaya(config)#line con 0
Kaya(config-line)#exec-timeout ?
<0-35791> Timeout in minutes
Kaya(config-line)#exec-timeout 0 ?
<0-2147483> Timeout in seconds <cr>
Kaya(config-line)#exec-timeout 0 100
Kaya(config-line)#logging synchronous

 

Router Interface Commands

Kaya(config)#interface fastethernet slot/port  –  Enters interface configuration mode from global configuration mode.
Kaya(config)#interface serial slot/port   –   Same as the previous command, except for serial interface 0/0/0 rather than Fast Ethernet interface.
Kaya(config-if)#shutdown                    –     Shuts down an interface.
Kaya(config-if)#no shutdown              –      Enables an interface that is shut down.
Kaya(config-if)#ip address address mask   –   Configures an interface with an IP address and a subnet mask.
Kaya(config-if)#ip address address mask secondary    –    Adds a secondary IP address to an interface.
Kaya(config-if)#description description     –     Adds a description to an interface.
Kaya(config-if)#clock rate rate               –          Sets the clock rate of a serial interface in bits per second.
Kaya(config-if)#bandwidth rate             –          Sets the bandwidth of an interface in kilobits per second.
Kaya#show interface interface                –          Displays the status and configuration of the Fast Ethernet interface.
Kaya#clear counters interface                 –          Clears the display counters on the serial interface.                            Kaya#sh ip interface interface               –          Displays the layer-3 properties of an interface.
Kaya#sh ip int brief                                  –          Displays the IP interfaces in a summarized table. This is one of the most useful show commands!

Let’s take a look at setting both an IP address and a secondary IP address on an interface, and then we’ll verify the configuration:
Kaya#interface fastEthernet 0/0
Kaya#interface serial 0/0/0
Kaya(config-if)#shutdown
Jul 30 15:31:23.542: %LINK-5-CHANGED: Interface Serial0/0/0, changed state to administratively down
Jul 30 15:31:24.542: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to down
Kaya(config-if)#no shutdown
Jul 30 15:31:27.566: %LINK-3-UPDOWN: Interface Serial0/0/0, changed state to up
Jul 30 15:31:28.566: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0/0, changed state to up
Kaya(config-if)#ip address 172.16.10.1 255.255.255.0
Kaya(config-if)#ip address 172.16.20.1 255.255.255.0 ?
secondary Make this IP address a secondary address
<cr>
Kaya(config-if)#ip address 172.16.20.1 255.255.255.0 secondary
Kaya(config-if)#description Serial link to Miami
Kaya(config-if)#clock rate 1000000
Kaya(config-if)#bandwidth 1000
Kaya(config-if)#exit
Kaya(config)#exit
Kaya#show interface s0/0/0

Serial0/0/0 is up, line protocol is up
Hardware is GT96K Serial
Description: Serial link to Miami
Internet address is 172.16.10.1/24
MTU 1500 bytes, BW 1000 Kbit, DLY 20000 usec,
reliability 255/255, txload 1/255, rxload 1/255
Encapsulation HDLC, loopback not set
Keepalive set (10 sec)
Last input 00:00:04, output 00:00:08, output hang never
Last clearing of “show interface” counters 2d05h
Input queue: 0/75/0/0 (size/max/drops/flushes); Total output drops: 0
Queueing strategy: fifo
Output queue: 0/40 (size/max)

5 minute input rate 0 bits/sec, 0 packets/sec
5 minute output rate 0 bits/sec, 0 packets/sec
34632 packets input, 2479012 bytes, 0 no buffer
Received 34031 broadcasts, 0 runts, 0 giants, 0 throttles
0 input errors, 0 CRC, 0 frame, 0 overrun, 0 ignored, 0 abort
34372 packets output, 2303104 bytes, 0 underruns
0 output errors, 0 collisions, 5 interface resets
0 output buffer failures, 0 output buffers swapped out
112 carrier transitions
DCD=up DSR=up DTR=up RTS=up CTS=up

Kaya#clear counters s0/0/0
Clear “show interface” counters on this interface [confirm][enter]
Jul 30 15:39:02.818: %CLEAR-5-COUNTERS: Clear counter on interface Serial0/0/0
by console
Kaya#sh ip interface s0/0/0
Serial0/0/0 is up, line protocol is up

Internet address is 172.16.10.1/24
Broadcast address is 255.255.255.255
Address determined by setup command
MTU is 1500 bytes
Helper address is not set
Directed broadcast forwarding is disabled
Secondary address 172.16.20.1/24
Secondary address 172.16.30.1/24
Outgoing access list is not set
Inbound access list is not set
Proxy ARP is enabled
Local Proxy ARP is disabled
Security level is default
Split horizon is enabled
ICMP redirects are always sent
ICMP unreachables are always sent
ICMP mask replies are never sent
IP fast switching is enabled
IP fast switching on the same interface is enabled
IP Flow switching is disabled
IP CEF switching is enabled
IP CEF Fast switching turbo vector

Kaya#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 192.168.21.1 YES manual up up
FastEthernet0/1 unassigned YES unset administratively down down
Serial0/0/0 172.16.10.1 YES manual up up
Serial0/0/1 unassigned YES unset administratively down down
Kaya#

Viewing, Saving, and Erasing Configurations

Once you have gone to all the work of creating a configuration, you will need to know how to save it, and maybe even delete it.

Commands to Manipulate Configurations

Kaya#copy running-config startup-config      –    Saves the running configuration to NVRAM
Kaya#show running-config      –     Shows the running configuration on the terminal
Kaya#show startup-config      –     Shows the start-up configuration (in NVRAM) on the terminal
Kaya#erase startup-config      –     Erases the configuration stored in NVRAM

 

You can manually save the file from DRAM to NVRAM by using the copy runningconfig startup-config command (you can use the shortcut copy run start also):
Kaya#copy running-config startup-config
Destination filename [startup-config]? [press enter]
Building configuration…
[OK]
Kaya#
Building configuration…
Kaya#show running-config
Building configuration…
Current configuration : 3343 bytes
!
version 12.4

The sh start command—one of the shortcuts for the show startup-config command— shows you the configuration that will be used the next time the router is reloaded. It also tells you how much NVRAM is being used to store the startup-config file. Here’s an example:
Kaya#show startup-config
Using 1978 out of 245752 bytes
!
version 12.4

Kaya#erase startup-config
Erasing the nvram filesystem will remove all configuration files!
Continue? [confirm][enter]
[OK]
Erase of nvram: complete
Kaya#
*Feb 28 23:51:21.179: %SYS-7-NV_BLOCK_INIT: Initialized the geometry of nvram
Kaya#sh startup-config
startup-config is not present
Kaya#reload
Proceed with reload? [confirm]System configuration has been modified.
Save? [yes/no]: n

 

Using the show Command

show running config        –                 This shows the configuration that router is using.
show startup-config        –                This shows the configuration that the router will use when the
router is reload.
show interface          –                 This shows the status of all interfaces.                                                                            show ip interface           –                This shows the default IP configuration on all interfaces.
show ip interface brief          –                 This command provides a quick overview of the router’s interfaces, including the logical address and status.
show protocols          –                 This shows the status of layers 1 and 2 of each interface as well as the IP addresses used.
show controllers           –                This shows whether an interface is a DCE or DTE interface.

 

The show running-config command is important and could very well be one of the most used commands on a Cisco router. The show running-config command shows the configuration that the router is running. The show startup-config shows the backup config, or the configuration that will be used the next time the router is booted.
The show interface command is important, and that’s what I’ll discuss in this section.
Here’s what it looks like:
Router#sh int s0/0/0
Serial0/0 is up, line protocol is down

If you see that the line is up but the protocol is down, as shown earlier, you’re experiencing a clocking (keepalive) or framing problem—possibly an encapsulation mismatch. Check the keepalives on both ends to make sure that they match, that the clock rate is set (if needed), and that the encapsulation type is the same on both ends. The previous output would be considered a Data Link layer problem.
If you discover that both the line interface and the protocol are down, it’s a cable or interface problem. The following output would be considered a physical layer problem:

Router#sh int s0/0/0
Serial0/0 is down, line protocol is down
If one end is administratively shut down (as shown next), the remote end would present as down and down:

Router#sh int s0/0/0
Serial0/0 is administratively down, line protocol is down
To enable the interface, use the command no shutdown from interface configuration mode while you re configuring a Cisco router :

Router#config t
Router(config)#int s0/0/0
Router(config-if)#no shutdown

You can get a nice brief overview of the interfaces with the show interface brief command:
Router#sh ip int brief
Interface IP-Address OK? Method Status Protocol
FastEthernet0/0 unassigned YES unset up up
FastEthernet0/1 unassigned YES unset up up
Serial0/0/0 unassigned YES unset up down
Serial0/0/1 unassigned YES unset up up
Serial0/1/0 unassigned YES unset administratively down down

Kaya#sh protocols
Global values:
Internet Protocol routing is enabled
FastEthernet0/0 is up, line protocol is up
Internet address is 192.168.21.1/24
FastEthernet0/1 is administratively down, line protocol is down
Serial0/0/0 is up, line protocol is up
Internet address is 172.16.10.1/24
Serial0/0/1 is administratively down, line protocol is down
Kaya#
The show controllers command displays information about the physical interface itself. It’ll also give you the type of serial cable plugged into a serial port. Usually, this will be only a DTE cable that plugs into a type of data service unit (DSU).

Router#sh controllers serial 0/0
HD unit 0, idb = 0x1229E4, driver structure at 0x127E70
buffer size 1524 HD unit 0, V.35 DTE cable
cpb = 0xE2, eda = 0x4140, cda = 0x4000
Router#sh controllers serial 0/1
HD unit 1, idb = 0x12C174, driver structure at 0x131600
buffer size 1524 HD unit 1, V.35 DCE cable
cpb = 0xE3, eda = 0x2940, cda = 0x2800