Configure Static Routing on Cisco Routers using GNS3 LAB

Static routing involves manual configuration of a routing table on the router. It is the simplest method for adding routes to router route tables. In some cases, static routes are preferred over routes learned via dynamic routing protocols. In this blog, we will configure a LAB with static routing. We have three routers, R1, R2 and R3, as shown below. . Each router is configured with Loopback 0 interface. Below LAB is created in GNS3

Before we continue with the lab, let me discuss some points regarding static routing.

Static routes require manual configuration of the routing table. For small networks, the configuration can be done quickly and easily. But if we decide to use static routing to set up a large network, then it’s a long process and there’s also the possibility of running through mistakes.

If the topology changes, a manual intervention is needed to account for the router changes.

We have more control over routes.

Now, let’s discuss the lab. As you can see from the diagram, we have three routers, R1, R2 and R3. There is a direct connection between R1 and R2 and R2 to R3. Here, our first step is to configure unique hostnames on all three routers. The following hostnames are configured on routers: It is always a good practice to identify each network device in the network with a unique hostname.

R1

R1(config)#hostname LABRouter1
LABRouter1(config)#exi
LABRouter1#
*Mar  1 00:02:28.435: %SYS-5-CONFIG_I: Configured from console by console
LABRouter1#copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
LABRouter1#

R2

R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#hostname LABRouter2
LABRouter2(config)#exi
LABRouter2#c
*Mar  1 00:05:06.163: %SYS-5-CONFIG_I: Configured from console by console
LABRouter2#copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
LABRouter2#

R3\

R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#hostname LABRouter3
LABRouter3(config)#exi
LABRouter3#copy
*Mar  1 00:06:09.087: %SYS-5-CONFIG_I: Configured from console by console
LABRouter3#copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
LABRouter3#

The router discovers route information and stores it in its routing table in three ways.

-The first way is to acquire information from its directly connected network or subnets.
-The second way is to enter information manually with the help of static routes.
-The route table is automatically shared and discovered between router as the method of learning about route information. This involves the use of dynamic routing protocols.

Routers have prior knowledge of their directly connected network or subnets. To know more about these details, let’s configure interfaces on all routers.

Interfaces to be configured on R1(LABRouter1)
F0/0 and Loopback 0

Interfaces to be configured on R2(LABRouter2)
F0/0, F0/1 and Loopback 0

Interfaces to be configured on R3(LABouter3
F0/1 and Loopback 0

R2 requires configuration on two interfaces, as this router is connected to R1 via F0/0 and R3 via F0/1.

Before we start configuring IP addresses on the interfaces, we need to identify subnet or the network between routers, such as we are using subnet 10.1.1.0/24 between R1 and R2, and 10.2.2.0/24 between R2 and R3. Here, one thing that may be noted is that we use a /24 subnet mask, which is not necessary if we are directly connecting two routers. We only need two IP addresses to connect two routers on the same or directly connected segment. The first IP address of the subnet shall be configured on one router and the second IP address on the other router. Using the/24 subnet between routers is a waste of IP addresses, and should be avoided with good network planning. In our example, a /24 subnet mask is used to introduce a static route configuration.

In our GNS3 LAB, subnet 10.1.1.0/24 is used between R1 and R2. We will configure router R1’s F0/0 interface with IP address 10.1.1.1/24, and router R2’s F0/0 with IP address 10.1.1.2/24. In the same way, R2’s F0/1 interface will be configured with an IP address of 10.2.2.1/24 and R3’s F0/0 interface with 10.2.2.2/24 

R1 interface IP address
F0/0 : 10.1.1.1 255.255.255.0
Loopbak 0 : 1.1.1.1 255.255.255.255

R2 Interfaces IP address
F0/0 : 10.1.1.2 255.255.255.0
F0/1 : 10.2.2.2 255.255.255.0
Loopback 0 : 2.2.2.2 255.255.255.255

R3 Interface IP address
F0/1 : 10.2.2.2 255.255.255.0
Loopback 0 : 3.3.3.3 255.255.255.255

Let’s begin configuring IP addresses on each router. We will start from R1, then R2 and finally R3.

R1 (LABRouter1)

LABRouter1(config)#interface fastEthernet 0/0
LABRouter1(config-if)#ip address 10.1.1.1 255.255.255.0
LABRouter1(config-if)#no shutdown
LABRouter1(config-if)#exit
LABRouter1(config)#interface loopback 0
LABRouter1(config-if)#ip address 1.1.1.1 255.255.255.255
LABRouter1(config-if)#exit
LABRouter1(config)#exit
LABRouter1#
LABRouter1#copy run start
Destination filename [startup-config]?
Building configuration...
[OK]
LABRouter1#

R2 (LABRouter2)

LABRouter2(config)#interface fastEthernet 0/1

LABRouter2(config-if)#ip address 10.2.2.2 255.255.255.0
LABRouter2(config-if)#no shut
LABRouter2(config-if)#exi
t
LABRouter2(config)#interface fastEthernet 0/0
LABRouter2(config-if)#ip address 10.1.1.2 255.255.255.0
LABRouter2(config-if)#no shut
LABRouter2(config-if)#exit
LABRouter2(config)#interface loopback 0
LABRouter2(config-if)#ip address 2.2.2.2 255.255.255.255

LABRouter2(config-if)#exit

R3 (LABRouter3)

LABRouter3(config)#interface fastEthernet 0/1

LABRouter3(config-if)#ip address 10.2.2.2 255.255.255.0
LABRouter3(config-if)#no shut
LABRouter3(config-if)#exi
t
LABRouter3(config)#interface loopback 0
LABRouter3(config-if)#ip address 3.3.3.3 255.255.255.255
LABRouter3(config-if)#no shut
LABRouter3(config-if)#exit

Use the command ip address to configure IP on the interface. You can use the “no shut” or “no shutdown” command to activate or enable the interface. By default, all interfaces are administratively disabled, so to activate an interface, use the “no shut” command. Once you apply the “no shutdown” command on the interface, you will begin to see below messages.

*Mar 1 01:15:21.439: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar 1 01:15:22.439: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
*Mar 1 01:22:25.427: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up

We can use “show ip interface brief” command to display IP address and status for all interfaces. Below is the output from Router R1 (LABRouter1).

LABRouter1#show ip interface brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            10.1.1.1        YES manual up                    up
FastEthernet0/1            unassigned      YES unset  administratively down down
FastEthernet1/0            unassigned      YES unset  administratively down down
Loopback0                  1.1.1.1         YES manual up                    up
LABRouter1#

Now, let’s check the routing table of a router using the show ip route command. The following result displays the “show ip route” command of the R1(LABRouter1) router..

LABRouter1#show ip route
Codes: 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
       i - IS-IS, su - IS-IS summary, 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

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.1.1.0 is directly connected, FastEthernet0/0

“C” in the output indicate a directly connected network. R1 (LABRouter1) consists of two directly connected network, 1.1.1.1/32 and 10.1.1.0/24. In a similar way, there are directly connected networks on R2 (LABRouter2) and R3 (LABRouter3).

R2(LABRouter2)

LABRouter2#show ip route
Codes: 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
       i - IS-IS, su - IS-IS summary, 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

     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 2 subnets
C       10.2.2.0 is directly connected, FastEthernet0/1
C       10.1.1.0 is directly connected, FastEthernet0/0

R3 (LABRouter3)

LABRouter3#show ip route
Codes: 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
       i - IS-IS, su - IS-IS summary, 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

     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     10.0.0.0/24 is subnetted, 1 subnets
C       10.2.2.0 is directly connected, FastEthernet0/1

Based on the output, we can determine that R2 has 3 directly connected subnet, while R3 has 2.

The following table shows the directly connected networks to all routers in our GNS 3 LAB..

RouterDirectly Connected Subnets
R1(LABRouter1)1.1.1.1/32 , 10.1.1.0/24
R2(LABRouter2)2.2.2.2/32 , 10.1.1.0/24 , 10.2.2.0/24
R3(LABRouter3)3.3.3.3/24 , 10.2.2.0/24

Using the ip route command for the directly connected network is of no use, because these subnets are already present in the routing table of a router. Let’s say, for example, there is no need to write an ip route statement for subnet 10.1.1.0/24 on the R1 router. We need to write an IP route statement on the R1 router for subnets that are not directly connected. From R1, we can’t reach 2.2.2.2, 3.3.3.3, or any IP address on subnet 10.2.2.0.

LABRouter1#ping 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
LABRouter1#ping 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
LABRouter1#ping 10.2.2.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.2.1, timeout is 2 seconds:
.....
Success rate is 0 percent (0/5)
LABRouter1#

How to add a static route to the router

To add a static route on the router, use the command ip route followed by the destination address, subnet mask, and the IP address of the next hop router; an alternative is to use the exit interface. We will configure the command on R1 (LABRouter1) for the subnets that are not reachable.

LABRouter1(config)#ip route 2.2.2.2 255.255.255.255 10.1.1.2
LABRouter1(config)#ip route 3.3.3.3 255.255.255.255 10.1.1.2
LABRouter1(config)#ip route 10.2.2.0 255.255.255.0 10.1.1.2

The above configuration includes the IP address of a next-hop router, and it is the R2 router. Routes can also be added using the exit interface. Following configuration uses exit interface fastEthernet 0/0 of the R1 router.

LABRouter1(config)#ip route 2.2.2.2 255.255.255.255 fastEthernet 0/0
LABRouter1(config)#ip route 3.3.3.3 255.255.255.255 fastEthernet 0/0
LABRouter1(config)#ip route 10.2.2.0 255.255.255.0 fastEthernet 0/0

Perform the same configuration on the remaining routers.

R2 (LABRouter2)

Networks such as 1.1.1.1 and 3.3.3.3 are not directly connected to R2, whereas 10.1.1.0 and 10.2.2.0 are linked directly. To make 1.1.1.1 and 3.3.3.3 reachable from R2, we need to write the ip route command.

LABRouter2(config)#ip route 1.1.1.1 255.255.255.255 10.1.1.1
LABRouter2(config)#ip route 3.3.3.3 255.255.255.255 10.2.2.2

R3 (LABRouter3)

LABRouter3(config)#ip route 1.1.1.1 255.255.255.255 10.2.2.1
LABRouter3(config)#ip route 2.2.2.2 255.255.255.255 10.2.2.1
LABRouter3(config)#ip route 10.1.1.0 255.255.255.0 10.2.2.1

Lets check the routing table on R1 (LABRouter1) by using the command “show ip route”.

LABRouter1#show ip route
Codes: 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
       i - IS-IS, su - IS-IS summary, 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

     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
S       2.2.2.2 [1/0] via 10.1.1.2
                is directly connected, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
S       3.3.3.3 [1/0] via 10.1.1.2
                is directly connected, FastEthernet0/0
     10.0.0.0/24 is subnetted, 2 subnets
S       10.2.2.0 [1/0] via 10.1.1.2
                 is directly connected, FastEthernet0/0
C       10.1.1.0 is directly connected, FastEthernet0/0

We have added three static routes on the R1 router for 2.2.2.2, 3.3.3.3, and 10.2.2.0/4. The “S” in the above command indicates that the route is added using the ip route command. Let’s see whether we can reach 3.3.3.3, 2.2.2.2, and 10.2.2.2 IP addresses from R1

LABRouter1#ping 2.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 40/48/64 ms
LABRouter1#ping 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 64/70/80 ms
LABRouter1#ping 10.2.2.2

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 10.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 72/83/96 ms
LABRouter1#
Advertisement

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s