Configure Redistribution between RIP and OSPF in Cisco IOS Router

These days almost nobody uses RIP anymore, unless their network has to support a legacy machine or an older router model. In this situation, the best practice is to limit RIP network as such and use a newer routing protocol on the rest part of the network, such as OSPF. Cisco IOS Router supports both protocols but the challenge to this implementation is that hosts in RIP network will not be able to talk with hosts in the OSPF network and vice versa. To overcome this, we need to Configure Redistribution between RIP and OSPF in Cisco IOS Router.

How to Configure Redistribution between RIP and OSPF in Cisco IOS Router

Redistribution can be performed between RIP and OSPF. We will use a scenario between three routers (R1, R2, and R3) to demonstrate how to Configure Redistribution between RIP and OSPF in Cisco IOS Router.

Configure Redistribution Between RIP and OSPF in Cisco IOS Router

In the topology above, RIP is used to connect R1-R2 and OSPF is used to connect R2-R3. In this scenario we have an issue where R1 cannot communicate to R3 and vice versa, despite the intermediate router (in this case is R2) knows exactly how to reach both network.

R1#ping 3.3.3.3 sour 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
.....
Success rate is 0 percent (0/5)

The following snippets are the routing configuration for each router in the topology above:

R1#sh run | s router
router rip
 version 2
 network 1.0.0.0
 network 10.0.0.0
 no auto-summary
R2#sh run | s router
router ospf 1
 network 2.2.2.2 0.0.0.0 area 0
 network 192.168.23.2 0.0.0.0 area 0
router rip
 version 2
 network 10.0.0.0
 no auto-summary
R3#sh run | s router
router ospf 1
 network 3.3.3.3 0.0.0.0 area 0
 network 192.168.23.3 0.0.0.0 area 0

To solve this kind of issue, a 2-way redistribution must be done on the intermediate router, or in this case is R2. The command used to redistribute RIP route into OSPF is “redistribute rip subnets” and the implementation shown below:

R2(config)#router ospf 1
R2(config-router)#redistribute rip subnets

Now the command to redistribute OSPF route into RIP is “redistribute ospf [PID] metric [hop count]”. Notice that when we redistribute any external route into RIP, we have to specify the hop count to reach that external network because RIP is a protocol that works based on the hop count. The hop count doesn’t have to be exactly match the real condition but it could be adjusted according to our needs. In this example, we set the hop count to 12 for easy identification purpose:

R2(config)#router rip
R2(config-router)#redistribute ospf 1 metric 12

After adding the above command, notice the change in R1 and R3 routing table:

Before

R1#sh ip route | b Gate
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/8 is variably subnetted, 2 subnets, 2 masks
C      10.12.12.0/24 is directly connected, FastEthernet0/0
L      10.12.12.1/32 is directly connected, FastEthernet0/0
R3#sh ip route | b Gate
Gateway of last resort is not set

     2.0.0.0/32 is subnetted, 1 subnets
O      2.2.2.2 [110/2] via 192.168.23.2, 00:02:14, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
C      3.3.3.3 is directly connected, Loopback0
     192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C      192.168.23.0/24 is directly connected, FastEthernet0/0
L      192.168.23.3/32 is directly connected, FastEthernet0/0

After

R1#sh ip route | b Gate
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
R      2.2.2.2 [120/12] via 10.12.12.2, 00:00:06, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
R      3.3.3.3 [120/12] via 10.12.12.2, 00:00:06, FastEthernet0/0
     10.0.0.0/8 is variably subnetted, 2 subnets, 2 masks
C      10.12.12.0/24 is directly connected, FastEthernet0/0
L      10.12.12.1/32 is directly connected, FastEthernet0/0
R      192.168.23.0/24 [120/12] via 10.12.12.2, 00:00:06, FastEthernet0/0
R3#sh ip route | b Gate
Gateway of last resort is not set

     1.0.0.0/32 is subnetted, 1 subnets
O E2   1.1.1.1 [110/20] via 192.168.23.2, 00:00:17, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
O      2.2.2.2 [110/2] via 192.168.23.2, 00:02:47, FastEthernet0/0
     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
O E2   10.12.12.0 [110/20] via 192.168.23.2, 00:00:17, FastEthernet0/0
     192.168.23.0/24 is variably subnetted, 2 subnets, 2 masks
C      192.168.23.0/24 is directly connected, FastEthernet0/0
L      192.168.23.3/32 is directly connected, FastEthernet0/0

As you can see the route to 3.3.3.3 now has been inserted to R1’s routing table with hop count 12 as specified, and route to 1.1.1.1 has been inserted to R3’s routing table as an OSPF external route. With this, it means we have successfully configured redistribution between RIP and OSPF, and ping between R1 and R3 can now be established

R1#ping 3.3.3.3 sour 1.1.1.1
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
Packet sent with a source address of 1.1.1.1
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 16/48/68 ms

Issue in Redistribution between RIP and OSPF

When we configure redistribution between RIP and OSPF in Cisco IOS router, the problem that commonly occurs is suboptimal routing a.k.a condition where router does not choose the shortest path to reach a destination. In a worse situation, this could also resulting in infinite routing loop. Suboptimal routing usually happens when there are more than one router performing redistribution, for example in a high-availability scenario. To demonstrate the problem, R4 is added to the above same topology.

Configure Redistribution Between RIP and OSPF in Cisco IOS Router - Suboptimal Routing

RIP is configured between R1-R4 and OSPF configured between R3-R4. Also, 2-way redistribution is performed on R4 as well with the configuration shown below:

R4#sh run | s router
router ospf 1
 redistribute rip subnets
 network 4.4.4.4 0.0.0.0 area 0
 network 192.168.34.4 0.0.0.0 area 0
router rip
 version 2
 redistribute ospf 1 metric 12
 network 10.0.0.0
 no auto-summary

In our case, suboptimal routing happens on R4 for route to R1. See R4 routing table and trace result below:

R4#show ip route 1.1.1.1
Routing entry for 1.1.1.1/32
 Known via "ospf 1", distance 110, metric 20, type extern 2, forward metric 2
 Redistributing via rip
 Advertised by rip metric 12
 Last update from 192.168.34.3 on FastEthernet0/0, 00:08:53 ago
 Routing Descriptor Blocks:
 * 192.168.34.3, from 2.2.2.2, 00:08:53 ago, via FastEthernet0/0
   Route metric is 20, traffic share count is 1
R4#trace 1.1.1.1 sour 4.4.4.4
Type escape sequence to abort.
Tracing the route to 1.1.1.1
VRF info: (vrf in name/id, vrf out name/id)
1 192.168.34.3 20 msec 12 msec 24 msec
2 192.168.23.2 40 msec 32 msec 52 msec
3 10.12.12.1 48 msec 56 msec 60 msec

It can be seen that R4 choose the route to R1 via R3 then R2, despite that R4 can actually reach R1 directly. This is because R4 receive route to R1 that has been redistributed through OSPF in R2-R3, and R4 choose to trusts this route more than the RIP route that it already knows because OSPF route has lower AD value (110) than RIP (120).

Using Distribute-List to Prevent Redistribution Issue

To prevent the above issue from happening, we can use a configuration called distribute-list. A distribute-list can be used to control incoming route information on an interface or control an outgoing route information from an interface. The command to use distribute-list is “distribute-list [access-list_ID] [in/out] [interface_name]“, and as can be seen on this command that a distribute-list command needs an access-list as a reference.

In our example, what we are going to do is preventing R4 to receive incoming route information to 1.1.1.1/32 on its OSPF-connected interface so when RIP is redistributed to OSPF on R2 and the information forwarded to R4, R4 will not consider this information but will trust its own RIP routing table instead. In reverse, we also need to do the same on R2 so that it will not consider the RIP route that is redistributed to OSPF on R4.

So we will first create the access-list on both R2 and R4:

R2(config)#access-list 10 deny 1.1.1.1 0.0.0.0
R2(config)#access-list 10 permit any
R4(config)#access-list 10 deny 1.1.1.1 0.0.0.0
R4(config)#access-list 10 permit any

Then refer the above access-list on both R2 and R4 OSPF config using the distribute-list command:

R2(config)#router ospf 1
R2(config-router)#distribute-list 10 in f0/1
R4(config)#router ospf 1
R4(config-router)#distribute-list 10 in f0/0

*f0/1 is the OSPF-connected interface on R2 while f0/0 is the OSPF-connected interface on R4.

With this command we have successfully eliminate the suboptimal routing issue, as can be seen in the output below that R4 now choose the RIP route to reach R1, and this means R4 can now reach R1 directly without having to go through R3-R2.

R4(config)#do sh ip route 1.1.1.1
Routing entry for 1.1.1.1/32
 Known via "rip", distance 120, metric 1
 Redistributing via rip, ospf 1
 Advertised by ospf 1 subnets
 Last update from 10.14.14.1 on FastEthernet0/1, 00:00:14 ago
 Routing Descriptor Blocks:
 * 10.14.14.1, from 10.14.14.1, 00:00:14 ago, via FastEthernet0/1
   Route metric is 1, traffic share count is 1

And that’s all the basic you need to know regarding how to configure redistribution between RIP and OSPF in Cisco IOS router.

The following two tabs change content below.
Arranda Saputra

Arranda Saputra

ITIL Certified, CCNA, CCDA, VCP6-DCV, MCSA Administering Windows Server 2012
I am IT practitioner in real life with specialization in network and server infrastructure. I have years of experience in design, analysis, operation, and optimization of infrastructure solutions for enterprise-scaled network. You can send me a message on LinkedIn or email to arranda.saputra@outlook.com for further inquiry regarding stuffs that I wrote or opportunity to collaborate in a project.
scroll to top