Search

How to configure Static Routes and Default Routes

If you are familiar with Static Routes and Default Routes, click the following link to view an introduction to Static Routes and Default Routes.

How to configure Static Routes

Static Route can be configured by the following IOS commands.

• Router(config)#ip route destination_network subnet_mask default_gateway [administrative_distance] [permanent]

OR

• Router(config)# ip route destination_network subnet_mask interface_to_exit [administrative_distance] [permanent]

The permanent keyword will keep the static route in the routing table even when the interface the router uses for the static route fails.

Static Routing - Lab Practice

The following diagram shows our lab setup. We have three routers, three switches and three hosts connected as below. The host names, IP addresses and the interfaces of the routers are shown in diagram. The IP addresses of the hosts are also shown in the diagram.

 

CCNA Routing Lab Setup

If you are not familiar with a router console connection, click the following link to learn how to connect the serial port of your computer to router console port.

Click the following link to learn how to connect to the console port of the router if there is no serial port in your computer.

Click the following links to learn how to use HyperTerminal terminal emulator and PuTTY terminal emulator to configure router.

Hostname and IP address configuration in Router01

Connect to Router01 console and use the following IOS commands to configure host name as Router01.

Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname Router01
Router01(config)#

Use the following IOS commands to open the fast ethernet interface Fa0/0 configuration mode on Router01 and configure IP address as 172.16.0.1/16.

Router01>enable
Router01#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router01(config)#interface fa0/0
Router01(config-if)#ip address 172.16.0.1 255.255.0.0
Router01(config-if)#no shutdown

Use the following IOS commands to open the serial interface S0/0 configuration mode on Router01 and configure IP address as 172.17.0.1/16. You have to set a clock rate also using the "clock rate" command on S0/0 interface, since this is the DCE side.

Router01>enable
Router01#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router01(config)#interface s0/0
Router01(config-if)#clock rate 64000
Router01(config-if)#ip address 172.17.0.1 255.255.0.0
Router01(config-if)#no shutdown

Do remember to run the "copy running-config startup-config" command from enable mode, if you want to save the changes you have made in the router.

Hostname and IP address configuration in Router02

Connect to Router02 console and use the following IOS commands to configure host name as Router02.

Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname Router02
Router02(config)#

Use the following IOS commands to open the fast ethernet interface Fa0/0 configuration mode on Router02 and configure IP address as 172.18.0.1/16.

Router02>enable
Router02#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router02(config)#interface fa0/0
Router02(config-if)#ip address 172.18.0.1 255.255.0.0
Router02(config-if)#no shutdown

Use the following IOS commands to open the serial interface S0/0 configuration mode on Router02 and configure IP address as 172.17.0.2/16.

Router02>enable
Router02#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router02(config)#interface s0/0
Router02(config-if)#ip address 172.17.0.2 255.255.0.0
Router02(config-if)#no shutdown

Use the following IOS commands to open the serial interface S0/1 configuration mode on Router02 and configure IP address as 172.19.0.1/16. You have to set a clock rate also using the "clock rate" command on S0/1 interface, since this is the DCE side.

Router02>enable
Router02#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router02(config)#interface s0/1
Router02(config-if)#clock rate 64000
Router02(config-if)#ip address 172.19.0.1 255.255.0.0
Router02(config-if)#no shutdown

Do remember to run the "copy running-config startup-config" command from enable mode, if you want to save the changes you have made in the router.

Hostname and IP address configuration in Router03

Connect to Router03 console and use the following IOS commands to configure host name as Router03.

Router>enable
Router#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname Router03
Router03(config)#

Use the following IOS commands to open the fast ethernet interface Fa0/0 configuration mode on Router03 and configure IP address as 172.20.0.1/16.

Router03>enable
Router03#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router03(config)#interface fa0/0
Router03(config-if)#ip address 172.20.0.1 255.255.0.0
Router03(config-if)#no shutdown

Use the following IOS commands to open the serial interface S0/1 configuration mode on Router03 and configure IP address as 172.19.0.2/16.

Router03>enable
Router03#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router03(config)#interface s0/1
Router03(config-if)#ip address 172.19.0.2 255.255.0.0
Router03(config-if)#no shutdown

Do remember to run the "copy running-config startup-config" command from enable mode, if you want to save the changes you have made in the router..

Static Routing configuration in Router01

Connect to Router01 console and use the following IOS commands to configure static routing in Router01. The "ip route" commands shown below states that to reach 172.18.0.0/16, 172.19.0.0/16 and 172.20.0.0/16 networks, handover the packets to the gateway ip address 172.17.0.2. The networks 172.16.0.0/16 and 172.17.0.0/16 are conneted directly to Router01.

Router01>enable
Router01#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router01(config)#ip route 172.18.0.0 255.255.0.0 172.17.0.2
Router01(config)#ip route 172.19.0.0 255.255.0.0 172.17.0.2
Router01(config)#ip route 172.20.0.0 255.255.0.0 172.17.0.2

Do remember to run the "copy running-config startup-config" command from enable mode, if you want to save the changes you have made in the router.

To view the routing table in Router01, run "show ip route" command in Router01 as shown below.

Router01#show ip route
Codes: C - connected, S - static, I - IGRP, 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
C    172.16.0.0/16 is directly connected, FastEthernet0/0
C    172.17.0.0/16 is directly connected, Serial0/0
S    172.18.0.0/16 [1/0] via 172.17.0.2
S    172.19.0.0/16 [1/0] via 172.17.0.2
S    172.20.0.0/16 [1/0] via 172.17.0.2

The "S" character at the beginning of a line in routing table shows that it is a static route and "C" character shows that it is a directly connected network.

Static Routing configuration in Router02

Connect to Router02 console and use the following IOS commands to configure static routing in Router02. The "ip route" commands shown below states that to reach 172.16.0.0/16 network, handover the packets to the gateway ip address 172.17.0.1 and to reach 172.20.0.0/16 network, handover the packets to the gateway ip address 172.19.0.2. The networks 172.17.0.0/16, 172.18.0.0/16 and 172.19.0.0/16 are connected directly to Router02.

Router02>enable
Router02#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router02(config)#ip route 172.16.0.0 255.255.0.0 172.17.0.1
Router02(config)#ip route 172.20.0.0 255.255.0.0 172.19.0.2

Do remember to run the "copy running-config startup-config" command from enable mode, if you want to save the changes you have made in the router.

To view the routing table in Router02, run "show ip route" command in Router02 as shown below.

Router02#show ip route
Codes: C - connected, S - static, I - IGRP, 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
S    172.16.0.0/16 [1/0] via 172.17.0.1
C    172.17.0.0/16 is directly connected, Serial0/0
C    172.18.0.0/16 is directly connected, FastEthernet0/0
C    172.19.0.0/16 is directly connected, Serial0/1
S    172.20.0.0/16 [1/0] via 172.19.0.2

The "S" character at the beginning of a line in routing table shows that it is a static route and "C" character shows that it is a directly connected network.

Static Routing configuration in Router03

Connect to Router03 console and use the following IOS commands to configure static routing in Router03. The "ip route" commands shown below states that to reach 172.16.0.0/16, 172.17.0.0/16 and 172.18.0.0/16 networks, handover the packets to the gateway ip address 172.19.0.1. The networks 172.19.0.0/16 and 172.20.0.0/16 are conneted directly to Router03.

Router03>enable
Router03#configure terminal
Enter configuration commands, one per line.  End with CNTL/Z.
Router03(config)#ip route 172.16.0.0 255.255.0.0 172.19.0.1
Router03(config)#ip route 172.17.0.0 255.255.0.0 172.19.0.1
Router03(config)#ip route 172.18.0.0 255.255.0.0 172.19.0.1

Do remember to run the "copy running-config startup-config" command from enable mode, if you want to save the changes you have made in the router.

To view the routing table in Router03, run "show ip route" command in Router03 as shown below.

Router03#show ip route
Codes: C - connected, S - static, I - IGRP, 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
S    172.16.0.0/16 [1/0] via 172.19.0.1
S    172.17.0.0/16 [1/0] via 172.19.0.1
S    172.18.0.0/16 [1/0] via 172.19.0.1
C    172.19.0.0/16 is directly connected, Serial0/1
C    172.20.0.0/16 is directly connected, FastEthernet

The "S" character at the beginning of a line in routing table shows that it is a static route and "C" character shows that it is a directly connected network.

Verify the connectivity between networks using the ping command

To verify the static routes which we have configured and the connectivity between networks, run the ping command from Host01 (IP address: 172.16.0.10/16) to Host03 (IP address: 172.20.0.10/16).

C:\>ping 172.20.0.10

Pinging 172.20.0.10 with 32 bytes of data:

Reply from 172.20.0.10: bytes=32 time=172ms TTL=125
Reply from 172.20.0.10: bytes=32 time=235ms TTL=125
Reply from 172.20.0.10: bytes=32 time=187ms TTL=125
Reply from 172.20.0.10: bytes=32 time=187ms TTL=125

Ping statistics for 172.20.0.10:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 172ms, Maximum = 235ms, Average = 195ms

The ping reply from Host03 (IP address: 172.20.0.10/16) shows that the static routes are configured well in three routers and there is network connectivity between different networks.

How to configure Default Routes

Default Route can be configured by the following IOS commands.

• Router(config)#ip route 0.0.0.0 0.0.0.0 default_gateway [administrative_distance] [permanent]

OR

• Router(config)# ip route 0.0.0.0 0.0.0.0 interface_to_exit [administrative_distance] [permanent]

Related Tutorials
• Introduction to Static Routes and Default Routes
• What is Dynamic Routing and different types of Dynamic Routing
• What is Routing Metric Value
• What is Convergence of Routing Tables
• Introduction to Distance Vector Routing Protocols
• Introduction to Routing Information Protocol (RIP)
• How to configure Routing Information Protocol (RIP)
• Introduction to Interior Gateway Routing Protocol (IGRP)
• How to configure Interior Gateway Routing Protocol (IGRP)
• What is Routing Loop and how to avoid Routing Loop
• Introduction to Link State Routing Protocols
• Introduction to Open Shortest Path First (OSPF) Protocol
• How to configure Open Shortest Path First (OSPF)
• Introduction to Hybrid Routing Protocols
• Introduction to Enhanced Interior Gateway Routing Protocol (EIGRP)
• How to configure Enhanced Interior Gateway Routing Protocol (EIGRP)