X

How to Add and Configure Static Routes on Cisco Router

Adding and Configuring Static Routes

There are two types of routing in networking, Dynamic routing and Static routing. In dynamic routing routing protocols are configured which automatically add different routes to the routers routing table, whereas static routing is the process of manually adding routing paths to the router’s routing table by network administrator/network engineer.

Static routing is done in networks which are not complex where dynamic routing is the best choice for large and complex networks.

Static Routing:

By default any router can direct or send packets to the subnets which are directly connected to its interfaces (that have an up and up status). If we want router1 to send packets to a subnet which is not directly connected or not in the routing table then we will have to add that subnet as a static route.

By adding a static route, a router can be told how to send or forward packets to the subnets that are not directly attached.

We will demonstrate adding static routes with the help of two routers, router R1 and router R2, and three subnets 12.0.0.0, 1.0.0.0 and 2.0.0.0 .

Basic configuration of R1:

You should note that when connecting two routers through serial cable, the serial interface of one router must be configured as DCE(Data Communication Equipment). DCE interface provides the clocking to the routers connected through it. We have explained the functionality of DCE and DTE in more details in how to set clock rate on Cisco router.

Router> enable
Router# configure terminal
Router(config)# hostname R1
R1(config)# interface serial 1/0
R1(config)# ip address 12.1.1.1  255.0.0.0
R1(config-if)# clock rate 64000
R1(config-if)# encapsulation hdlc
R1(config-if)#  no shutdown
R1(config-if)#  exit
R1(config)# interface loopback 0
R1(config-if)# ip address 1.1.1.1 255.0.0.0
R1(config-if)# exit

Basic configuration of Router1

Checking Routing Table of router R1:

R1#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 1.0.0.0/8 is directly connected, Loopback0
C 12.0.0.0/8 is directly connected, Serial0/1/0

Routing table of router R1

Routing table of R1 shows that subnets 1.0.0.0 and 12.0.0.0 are directly connected and can be pinged but subnet 2.0.0.0 cannot be accessed as it is directly connected to R2 and not to R1. If we want R1 to forward packets to subnet 2.0.0.0 then we need to configure a static route.

Basic Configuration of R2:

Router> enable
Router# configure terminal
Router(config)# hostname R2
R2(config)# interface serial 1/1
R2(config)# ip address 12.1.1.2  255.0.0.0
R2(config-if)# encapsulation hdlc
R2(config-if)#  no shutdown
R2(config-if)#  exit
R2(config)# interface loopback 0
R2(config-if)# ip address 2.2.2.2  255.0.0.0
R2(config-if)# exit

Basic configuration of Router2

Check Routing Table of router R2:

R2#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 2.0.0.0/8 is directly connected, Loopback0
C 12.0.0.0/8 is directly connected, Serial0/1/1

Routing table of router R2

Routing table of R2 shows that subnets 2.0.0.0 and 12.0.0.0 are directly connected and can be pinged but subnet 1.0.0.0 cannot be accessed as it is directly connected to R1 and not to R2. If we want R2 to forward packets to subnet 2.0.0.0 then we need to configure a static route.

Configuring Static Route on R1:

R1(config)#
R1(config)#ip route 2.0.0.0 255.0.0.0 12.1.1.2
R1(config)#exit
R1#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 1.0.0.0/8 is directly connected, Loopback0
S 2.0.0.0/8 [1/0] via 12.1.1.2
C 12.0.0.0/8 is directly connected, Serial0/1/0

Static Route Added to R1

Notice the “S” in R1 routing table, it denotes static route, 2.0.0.0/8 is the network which is accessible through 12.1.1.2. R1 will forward al the packets intended for 2.0.0.0 network to its next hop address which is 12.1.1.2.

Configuring Static Route on R2:

R2>enable
R2#config terminal
Enter configuration commands, one per line. End with CNTL/Z.
R2(config)#ip route 1.0.0.0 255.0.0.0 12.1.1.1
R2(config)#exit
R2#
%SYS-5-CONFIG_I: Configured from console by console
R2#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 1.0.0.0/8 [1/0] via 12.1.1.1
C 2.0.0.0/8 is directly connected, Loopback0
C 12.0.0.0/8 is directly connected, Serial0/1/1

Static Route Added to R2

Notice the “S” in R2 routing table, it denotes static route, 1.0.0.0/8 is the network which is accessible through 12.1.1.1. R2 will forward al the packets intended for 1.0.0.0 network to its next hop address which is 12.1.1.1.

For verification you  can ping 1.1.1.1 from router R2 and 2.2.2.2 from router R1.

If you do have any questions related to configuring Static Routes on a Cisco router, do ask in comments.

 

One thought on “How to Add and Configure Static Routes on Cisco Router

Leave a Reply

Your email address will not be published. Required fields are marked *


8300 Views