Pages

Saturday, January 15, 2011

OSPF-RIP Sub-Optimal problem

OSPF-RIP Sub-Optimal problem

Suboptimal problem can occur when there are 2 or more routers connecting between 2 routing domain, especially OSPF and RIP. The behavior of suboptimal problem is router will use suboptimal path to forward the packets. This example below shows the suboptimal problem and how to solve it if it occurs.

Example

R1 and R2 are routers between 2 routing domain: OSPF and RIP.  R1 and R2 both redistribute RIP routers to OSPF domain. Consider network 10.10.10.0/24 in the routing table of R2 before and after redistribution


Before 
R2#sh 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

     172.16.0.0/24 is subnetted, 2 subnets
O       172.16.1.0 [110/20] via 172.16.2.2, 00:34:13, FastEthernet0/1
C       172.16.2.0 is directly connected, FastEthernet0/1
R    10.0.0.0/8 [120/1] via 192.168.2.2, 00:00:06, FastEthernet0/0
R    192.168.1.0/24 [120/1] via 192.168.2.2, 00:00:06, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet0/0


After redistribution

R2# sh 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

     172.16.0.0/24 is subnetted, 2 subnets
O       172.16.1.0 [110/20] via 172.16.2.2, 00:30:30, FastEthernet0/1
C       172.16.2.0 is directly connected, FastEthernet0/1
O E2 10.0.0.0/8 [110/20] via 172.16.2.2, 00:07:18, FastEthernet0/1
O E2 192.168.1.0/24 [110/20] via 172.16.2.2, 00:07:18, FastEthernet0/1
C    192.168.2.0/24 is directly connected, FastEthernet0/0
R2#


We can see from the before and after routing table of R2 that the optimal path to 10.10.10.0/24 is through R3. However, when doing the redistribution we found out that R2 uses path through R4 in order to reach 10.10.10.0/24 which is called suboptimal path problem.

Suboptimal path



This problem occurs between OSPF and RIP. The reason that R2 chooses R4 as a next-hop to reach 10.10.10.0/24 is R2 received 10.10.10.0/24 information from R1 via OSPF (E2). At this time, R2 has 2 paths to reach 10.10.10.0/24 network via RIP and VIA OSPF(E2). Because the administrative distance of OSFP is better than RIP, R2 therefore choose OSPF path. That caused the suboptimal problem.

Solution of Suboptimal problem

1. AD distance ospf external 180
Set the administrative distance of the external route in OSPF domain from 120 to 180 when redistribute route at R1. R2 will see OSPF(E2) which has AD = 180 and compare with RIP which is 120. Then R2 will choose RIP route to reach 10.10.10.0/24 network since RIP AD is better than 180.

R1#
router ospf 1
distance ospf external 180

R2#sh 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

     172.16.0.0/24 is subnetted, 2 subnets
O       172.16.1.0 [110/20] via 172.16.2.2, 00:00:56, FastEthernet0/1
C       172.16.2.0 is directly connected, FastEthernet0/1
R    10.0.0.0/8 [120/1] via 192.168.2.2, 00:00:22, FastEthernet0/0
R    192.168.1.0/24 [120/1] via 192.168.2.2, 00:00:22, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet0/0
R2#

----------------------

2. Change RIP AD  from 120 to 109
Administrative distance of OSPF is 110 as opposed to RIP which is 120. This solution suggested that we change RIP AD to 109. Therefore, when R2 received 10.10.10.0/24 information from both OSPF and RIP. It will choose RIP since it has better administrative distance.

R1#
router rip
distance 109


R2#sh 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

     172.16.0.0/24 is subnetted, 2 subnets
O       172.16.1.0 [110/20] via 172.16.2.2, 00:00:22, FastEthernet0/1
C       172.16.2.0 is directly connected, FastEthernet0/1
R    10.0.0.0/8 [109/1] via 192.168.2.2, 00:00:11, FastEthernet0/0
R    192.168.1.0/24 [109/1] via 192.168.2.2, 00:00:11, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet0/0
R2#


---------------------------

3. Use distribute list blocking RIP route at R2 from R1
When redistributing RIP into OSPF, we can set a tag on all routes from RIP. In this example, we set tag 100 to RIP routes.



R1#
router ospf 1
redistribute rip subnets tag 100

R2 needs to create a route-map denying routes which has tag 100 into its routing table.

R2
router ospf 1
 router-id 2.1.1.1.1
 log-adjacency-changes
 redistribute rip subnets tag 100
 network 172.16.0.0 0.0.255.255 area 0
 distribute-list route-map no-ospf-tag-100-in in
!
!

R2
// creating a route-map

route-map no-ospf-tag-100-in deny 10
 match tag 100
!
route-map no-ospf-tag-100-in permit 20
!
!

Verify configuration 

R2#sh 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

     172.16.0.0/24 is subnetted, 2 subnets
O       172.16.1.0 [110/20] via 172.16.2.2, 00:00:01, FastEthernet0/1
C       172.16.2.0 is directly connected, FastEthernet0/1
R    10.0.0.0/8 [120/1] via 192.168.2.2, 00:00:19, FastEthernet0/0
R    192.168.1.0/24 [120/1] via 192.168.2.2, 00:00:19, FastEthernet0/0
C    192.168.2.0/24 is directly connected, FastEthernet0/0
R2#

2 comments: