Lab 06: Implementing Static and Dynamic Routing (RIP
& OSPF)
6.1 Objectives:
• Define and describe the concept of routing
• Describe the concept of static routing and dynamic routing
• Configure static and dynamic routing in a given network topology
6.2 Theory:
As with other labs, this lab will also build up on the concepts and techniques of previous labs.
So, make sure you have properly understood the previous lab contents.
Routers use the routing table to forward packets to the intended destinations. When a packet
reaches the router, it looks up the routing table, finds the corresponding output interfaces for
the destination network address, and sends the packet through that interface. The question is
how this routing table is formed in the first place. The answer is either manually configuring
the routing entries or using routing protocols to configure the routes dynamically. The first
approach is static routing, while the second is dynamic routing.
6.2.1 Static Routing
In static routing, the network administrator manually adds the routing entries to the routing
table. The routing entries will not be changed automatically. All changes have to be done man-
ually. If the network condition changes (for example, some link goes down), then the necessary
changes in the routing table must be done manually, whereas this info is updated automatically
in dynamic routing. In practice, static routing is mainly used as a backup to dynamic routing
for large networks. Unlike dynamic routing, static routing requires significantly less compu-
tational resources and bandwidth as no extra packet is required for the routing table update
process. However, as the network administrator needs to know the whole network topology
and network addresses to effectively configure the routing table, static routing is not used as
the only routing mechanism in large-scale networks.
You need to be familiar with some concepts related to static routing before you get your hands
dirty. You know that packets travel from one hop to the next to reach it’s final destination. In
a router’s routing table, the next hop address is associated with a certain destination address.
It is unrealistic to assume that there would be a next-hop entry for every possible destination
network. That’s why a routing entry known as the default route is present in the routing
table. It defines a default exit interface for the packets that don’t have any corresponding route
in the routing table.
When working with CISCO devices, specifically for this lab, you will encounter two types of
static default routes. They are directly connected static default route and next-hop static
default route. The general format of the static routes is as follows:
ip route destination_network_prefix destination_prefix_mask (next-hop_address
1
| interface) [distance_metric]
To configure the directly connected static default routes, you will specify the interface. For
the next-hop static default routes, you will specify the next_hop address. One special use
case of the above command is configuring a primary static default route where both the
destination_network_prefix and Destination_prefix_mask are 0.0.0.0. The IPv4 com-
mand format for specifying the primary static default route is given below:
ip route 0.0.0.0 0.0.0.0 (next-hop_address | interface) [distance_metric]
It means that "packet from any IP address with any subnet mask gets sent to the
specified next-hop address or interface."
Another concept when configuring static routing is the floating static route. A floating route
is nothing but the route that is used to forward a packet to a certain destination when main
route is unavailable. The floating routes are defined by providing a higher distance_metric
to a certain route. The default distance_metric, when it is not manually specified, is 1. The
floating static routes are given higher numbers than 1. Routers always take the route with
lower distance_metric when multiple routes to the same destination are available. That’s why
this floating static route will only be used when the main route (distance_metric is 1) is down
or unavailable.
6.2.2 Dynamic Routing
Dynamic routing lets routers select routes based on the real-time network condition. There
will always be packets traveling around the networks to keep the routers up-to-date about the
present network condition. Then, the routers will select an optimal route to a given destination
based on some set of metrics. There are different types of dynamic routing protocols follow-
ing different algorithms. The two most common ones are Routing Information Protocol
(RIP) following distance-vector algorithm and Open Shortest Path First (OSPF) proto-
col following link state routing algorithm.
Routing Information Protocol (RIP)
RIP is somewhat obsolete due to its limitations and the advent of more modern and sophisti-
cated protocols like OSPF, EIGRP, etc. Still, as this was one of the pioneering dynamic routing
protocols that dominated the networking world for quite some time, you must understand this.
This will help you understand the improvements made in newer protocols. There are two ver-
sions of RIP, namely RIPv1 and RIPv2. RIPv2 is the dominant one and is used in almost
all cases where RIP is used. So, we’ll focus on RIPv2 only for our lab. A major problem of
RIPv1 was that it used to broadcast routing table updates every 30 seconds. You can imagine
the flood of packets every 30 seconds that would take place where millions of networks are
now interconnected, even if they are configured to send updates at random times. RIPv2 was
designed to overcome this issue along with other improvements. You can learn more about
these two versions along with RIPng (for IPv6) here.
Open Shortest Path First (OSPF) Routing Protocol
OSPF uses the Link State Routing (LSR) algorithm. In OSPF, each router sends its link
information to the directly connected routers, known as neighbors, which in turn sends the
info to other neighbors. After that, each router runs the Shortest Path Algorithm on the
received information to determine the optimal route to different networks. The running of the
2
algorithm is one of the reasons why OSPF is a CPU-intensive protocol, as whenever there’s
a change, the algorithm is run. Still, OSPF is better than RIP due to its fast convergence
and better load-balancing. Remember that RIP sends the whole routing table to its neighbors,
whereas OSPF only sends the link information with various optimizations in place. You can
learn more about OSPF here.
There are many terminologies and concepts related to OSPF that one needs to know for a full
understanding of the protocol. Some of the most common ones are listed here. But for our
purpose, we will cover the necessary ones.
• Area: OSPF networks are divided into areas that are a logical collection of routers
and links with the same area identification. A router within an area must maintain a
topological database for the area to which it belongs. The router does not have detailed
information about network topology outside of its area, which thereby reduces the size
of its database. There is a special area called the backbone area (area 0) to which all
other areas must be connected. Different areas can communicate with each other through
area 0.
• Area Border Router (ABR): A router with interfaces in two areas is called an ABR.
This router is the boundary between two areas.
• Autonomous System (AS): OSPF operates within a single Autonomous System which
is a collection of areas. AS is a group of networks running under single administrative
control. It controls how far the routing information should be propagated and facilitates
filtering information for sharing with other AS.
• Designated Router (DR): A router is elected as the Designated Router (DR) and
another as the Backup Designated Router (BDR) on a multi-access network (like LAN) in
OSPF. DR and BDR serve as the central point for exchanging OSPF routing information.
Each non-DR or non-BDR router will exchange routing information only with the DR
and BDR instead of exchanging updates with every router on the network segment. DR
will then distribute topology information to every other router inside the same area,
which significantly reduces OSPF traffic.
• Router ID: Each router running the OSPF protocol is assigned a router ID to uniquely
identify that router within an AS. This is a 32-bit number and can be set manually by
using the router-id command. If the router ID is not set manually, then the highest
IP address of the router’s loopback address will be set as the router ID. If there is no
loopback address, the highest active IP address on any router’s interfaces will set the
router ID. Remember to restart the router to reflect the new router-id assignment. The
reload command will restart the router. Also, the clear ip ospf process command
will work for the new router-id assignment.
• Cost: The cost in OSPF is calculated as Reference Bandwidth / Interface Band-
width. The default value of reference bandwidth is 100 Mbps, but it can be set manu-
ally. The command to manually set the reference bandwidth is auto-cost reference-
bandwidth <value>. Note that value here is in units of Mbps. So, value=100 would
mean 100 Mbps. You can change the interface bandwidth with the bandwidth <value>
command. But, here, the value is in units of kbps.
• Wildcard Mask: The command to configure which networks to advertise is network
<ip_address> <wildcard_mask> area <area_id>. Unlike RIP, the network command
in OSPF supports classless routing, and that support is achieved by the wildcard_mask.
This mask is like an inverted subnet_mask but with a different interpretation. The 0
3
bits in the mask indicate the corresponding bit positions that must match the same bit
positions in the IP address. The 1 bits indicate the corresponding bit positions do not
need to match the same bit positions in the IP address. It is best understood by an
example. Suppose there’s a 10.0.1.0 directly connected subnet to our router that we
want to advertise in the OSPF routing process. The command to include that subnet in
the advertisement would be:
network 10.0.1.0 0.0.0.255 area 0
According to the wildcard_mask used in the above command, the first 24 bits of the
addresses must match, and the remaining 8 bits do not need to match. So, any interface
with an IP address in the format 10.0.1.X will match in this case.
• Process ID: When enabling OSPF in a router, you need to mention a process ID. All
OSPF functions will then be performed under that process. OSPF configuration mode
is entered using the command router ospf <process_id>. You can have more than one
OSPF process in a single router. The process IDs will be different for different processes.
Each OSPF process has its own database, topology table, etc.
Now, let us mention some key concepts in OSPF. OSPF enabled routers to send hello packets
to each other in certain intervals known as the hello interval. This is required to establish a
neighbor relationship and to let other routers know the router’s availability. For example, if the
hello interval is 5 seconds, then each router will send hello packets to the neighboring router
every 5 seconds. There is another interval known as the dead interval, which is usually four
(4) times of the hello interval. If a router does not receive hello packets from its neighbors,
then after this dead interval amount of time, that neighbor will be declared non-operational,
and the routing table will be updated accordingly.
In OSPF, some interfaces are configured as passive interfaces. Passive interfaces don’t send
hello packets. This is usually done for the local LAN-facing interfaces. Note that the network
connected with a passive interface will still be advertised, as OSPF has been enabled in that
interface. Check out this to learn more about passive interfaces.
6.2.3 Route Redistribution
Redistributing routing information refers to the process of sharing routing information be-
tween different routing protocols within a network. This process is important for networks
that adopt various routing protocols in different segments, such as OSPF and RIP, to enable
communication between them. The messages used to advertise or update routing information
are protocol-specific; hence, information from one protocol cannot be directly used by another
to update its routing information. For successful communication in the network, this informa-
tion sharing is crucial.
When redistributing routing information, a router operating under one routing protocol (like
OSPF or RIP) receives routing updates and can then advertise those routes to routers using a
different protocol. Thus, routing information can be shared across the network despite the use
of different routing protocols in various parts.
For example, consider a company with two separate networks: one using OSPF for internal
routing and another using RIP for its branch offices. The routers in the OSPF domain are
unaware of the routes in the RIP domain, and vice versa. To facilitate communication, we can
configure route redistribution on the routers that connect these two networks.
4
For instance, the router at the boundary of the OSPF and RIP networks can be set up to
redistribute routes as follows:
Redistributing OSPF into RIP: When the OSPF router receives a route, it advertises it to
the RIP domain, allowing branch offices using RIP to learn about routes to the internal OSPF
network.
Redistributing RIP into OSPF: Conversely, the router can also redistribute routes learned
from RIP into the OSPF network, ensuring that the internal OSPF network can reach the
branch offices.
By redistributing routing information, both networks can access each other’s resources, im-
proving overall connectivity and redundancy. For example, if a user in the OSPF network
needs to access a server in the RIP network, redistribution allows the necessary routes to be
shared, ensuring that data packets can be routed correctly between the two networks.
6.3 Configuration of Routing with Cisco Devices:
6.3.1 Configure static routing
Figure 6.1: A sample network topology for the configuration of static routing.
a. Configure R1 Interfaces
R1(config)#int g0/0
R1(config-if)#ip add 192.168.1.1 255.255.255.0
R1(config-if)#desc connection-to-PC0
5
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#int s0/1/0
R1(config-if)#ip add 192.168.0.2 255.255.255.252
R1(config-if)#desc connection-to-R3
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#int s0/1/1
R1(config-if)#ip add 192.168.0.6 255.255.255.252
R1(config-if)#desc connection-to-R2
R1(config-if)#clock rate 64000
R1(config-if)#no shutdown
R1(config-if)#exit
b. Configure R2 Interfaces
R2(config)#int s0/1/1
R2(config-if)#ip add 192.168.0.5 255.255.255.252
R2(config-if)#desc connection-to-R1
R2(config-if)#no shutdown
R2(config-if)#exit
R2(config)#int g0/0
R2(config-if)#ip add 192.168.2.1 255.255.255.0
R2(config-if)#desc connection-to-RemoteLAN
R2(config-if)#no shutdown
R2(config-if)#exit
c. Configure R3 Interfaces
R3(config)#int s0/1/0
R3(config-if)#ip add 192.168.0.1 255.255.255.252
R3(config-if)#desc connection-to-R1
R3(config-if)#no shutdown
R3(config-if)#exit
R3(config)#int g0/0
R3(config-if)#ip add 192.168.2.2 255.255.255.0
R3(config-if)#desc connection-to-RemoteLAN
R3(config-if)#no shutdown
R3(config-if)#exit
d. Configure PC0
IP: 192.168.1.10
Mask: 255.255.255.0
Gateway: 192.168.1.1
e. Configure PC1
IP: 192.168.2.10
6
Mask: 255.255.255.0
Gateway: 192.168.2.1
f. Configure static routing to Remote LAN in R1
R1(config)#ip route 192.168.2.0 255.255.255.0 s0/1/1
It’s a directly connected static default route.
R1(config)#ip route 192.168.2.0 255.255.255.0 192.168.0.1 5
It’s a next-hop floating static default route.
g. Configure static routing to Local LAN in R2
R2(config)#ip route 192.168.1.0 255.255.255.0 s0/1/1
It’s a directly connected static default route.
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.0.6 5
It’s a next-hop floating static default route.
h. Configure static routing to Local LAN in R3
R2(config)#ip route 192.168.1.0 255.255.255.0 s0/1/0
It’s a directly connected static default route.
R2(config)#ip route 192.168.1.0 255.255.255.0 192.168.0.2 5
It’s a next-hop floating static default route.
i. Verify
Ping PC1 from PC0
6.3.2 Configure RIP
Figure 6.2: A sample network topology for the configuration of RIP.
a. Configure R1 Interfaces
R1(config)# int g0/0
R1(config-if)# ip address 10.0.1.1 255.255.255.0
7
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# int g0/1
R1(config-if)# ip address 172.16.0.1 255.255.0.0
R1(config-if)# no shutdown
R1(config-if)# exit
R1# copy running-config startup-config
b. Configure R2 Interfaces
R2(config)# int g0/1
R2(config-if)# ip address 192.168.0.1 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)# exit
R2(config)# int g0/0
R2(config-if)# ip address 172.16.0.2 255.255.0.0
R2(config-if)# no shutdown
R2(config-if)# exit
R2# copy running-config startup-config
c. Configure PC0
IP: 10.0.1.10
Mask: 255.255.255.0
Gateway: 10.0.1.1
d. Configure PC1
IP: 192.168.0.10
Mask: 255.255.255.0
Gateway: 192.168.0.1
e. Configure RIP in R1
R1(config)#router rip
R1(config-router)#version 2
R1(config-router)#network 10.0.0.0
R1(config-router)#network 172.16.0.0
f. Configure RIP in R2
R2(config)#router rip
R2(config-router)#version 2
R2(config-router)#network 192.168.0.0
R2(config-router)#network 172.16.0.0
g. Verify
R1# show ip route rip
8
Ping PC1 from PC0
6.3.3 Configure OSPF
The OSPF concepts and the detailed implementation of the OSPF routing protocol can be
found at this link. You are suggested to read the article and practice the commands from the
article for implementation. Below is a simple configuration of OSPF for the given network
topology:
Figure 6.3: A sample network topology for the configuration of OSPF.
a. Configure R1 Interfaces
R1(config)# int g0/0
R1(config-if)# ip address 10.0.1.1 255.255.255.0
R1(config-if)# no shutdown
R1(config-if)# exit
R1(config)# int g0/1
R1(config-if)# ip address 172.16.0.1 255.255.0.0
R1(config-if)# no shutdown
R1(config-if)# exit
R1# copy running-config startup-config
b. Configure R2 Interfaces
R2(config)# int g0/1
R2(config-if)# ip address 192.168.0.1 255.255.255.0
R2(config-if)# no shutdown
R2(config-if)# exit
R2(config)# int g0/0
R2(config-if)# ip address 172.16.0.2 255.255.0.0
R2(config-if)# no shutdown
R2(config-if)# exit
R2# copy running-config startup-config
c. Configure PC0
IP: 10.0.1.10
Mask: 255.255.255.0
Gateway: 10.0.1.1
d. Configure PC1
9
IP: 192.168.0.10
Mask: 255.255.255.0
Gateway: 192.168.0.1
e. Configure OSPF in R1
R1(config)# router ospf 1
R1(config-router)# network 10.0.1.0 0.0.0.255 area 0
R1(config-router)# network 172.16.0.0 0.0.255.255 area 0
f. Configure OSPF in R2
R2(config)# router ospf 1
R2(config-router)# network 192.168.0.0 0.0.0.255 area 0
R2(config-router)# network 172.16.0.0 0.0.255.255 area 0
g. Verify
R1# show ip ospf neighbor
R2# show ip ospf neighbor
Ping PC1 from PC0
6.3.4 Configure Route Redistribution
Figure 6.4: A sample network topology for Route Redistribution.
10
The core router is running three different routing protocols for the connected subnetworks.
Route redistribution is necessary for this network design to enable communication among the
subnetworks. It allows routes from one routing protocol to be advertised in another.
a. Redistribute RIP and Static into OSPF
CoreRouter(config)#router ospf 1
CoreRouter(config-router)#redistribute rip metric 1 subnets
CoreRouter(config-router)#redistribute static metric 1 subnets
b. Redistribute OSPF and Static into RIP
CoreRouter(config)#router rip
CoreRouter(config-router)#redistribute ospf 1 metric 1
CoreRouter(config-router)#redistribute static metric 1
c. Verify
To verify the route redistribution, use the ping messages from PC1 to PC5 after successfully
assigning the ip addresses to the PCs and routers’ interfaces and successfully configuring
routing protocols as shown in Figure 6.4.
11