I will be using the same Topology for this lab to demonstrate 4 different ways to Redistribute OSPF routes, using the same Topology as before as follows:
I removed the static route from R5 as a return route to RIP land, and will now be doing 2 way redistribution between the routing domains, but first wanted to touch on sub-optimal routing and routing loops in general to the extent of my understanding this far into Redistribution studies.
First, Routing Loops can occur when you do not plan your redistributing carefully, and bring in unnecessary routes or enter blanket redistribution statements like “redistribute connected subnets” or “redistribute static subnets” when you have none that currently need to be Redistributed. This can lead to someone in the future entering a static route, not knowing it is being Redistributed, and thus creating a routing loop without knowing it.
This can also lead to sub-optimal routing situations, like the one we will see when I introduce RIP routes in the OSPF routing domain, as the routing table will always bring in the route with the lowest Administrative Distance as the preferred route to a destination network if there are matching routes so we need to know how to manipulate those to overcome sub-optimal routing!
There are several ways of changing Administrative Distance for protocols to overcome sub-optimal routing, including the following different approaches:
- Changing the AD for an entire Routing Protocol
- Changing the AD for all routes from a specific protocol, from a specific source
- Changing the AD for specific routes via access-list
- Changing the AD for OSPF External, Inter-Area, and Intra-Area routes
***One thing to note, these will always (at this time in my studies) be configured on Boarder Routers or ABR’s, and not on the ASBR doing the Redistribution.***
First let’s look at R2’s full routing table to see where it’s routes are pointing, and what is happening BEFORE we introduce two-way Redistribution injecting RIP routes into the OSPF routing domain:
R2#show ip route
[Route codes redacted]
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback2
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:11, Serial0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 01:04:49, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 01:04:49, FastEthernet0/0
172.12.0.0/24 is subnetted, 1 subnets
C 172.12.123.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 172.12.123.1, 00:00:12, Serial0/0
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, FastEthernet0/0
To begin I removed the Static route from the R5 as the return route to the RIP domain, and now I will perform two-way Redistribution:
R3(config-router)#redistribute rip subnets
R3(config-router)#
ASR#2
[Resuming connection 2 to r2 … ]
R2#show ip route
[Route codes redacted]
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback2
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:12, Serial0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 00:00:19, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 00:00:19, FastEthernet0/0
172.12.0.0/24 is subnetted, 1 subnets
C 172.12.123.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [110/20] via 30.1.1.3, 00:00:21, FastEthernet0/0
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, FastEthernet0/0
The Loopback on R1 of 10.1.1.0/24 is now showing as an External OSPF route, which means traffic going through R2 towards R1’s loopback network will be forced to take R2-R3-R1, rather than directly from R2-R1 over the NBMA network – This is the beginning of sub-optimal routing. To address this, the AD for OSPF routes needs to be made to be higher than RIPs AD of 120, so it will be changed to 121 on the ABR firstly to see what happens.
This first method I will try will be changing the AD directly on the ABR, so that all OSPF routes learned by the router will have an AD of 121:
R2(config-router)#distance 121
R2(config-router)#
*Mar 1 09:40:04.746: %SYS-5-CONFIG_I: Configured from console by console
R2#show ip route
[Route codes redacted]
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback2
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:08, Serial0/0
4.0.0.0/32 is subnetted, 1 subnets
R 4.4.4.4 [120/3] via 172.12.123.3, 00:00:08, Serial0/0
5.0.0.0/32 is subnetted, 1 subnets
R 5.5.5.5 [120/3] via 172.12.123.3, 00:00:08, Serial0/0
172.12.0.0/24 is subnetted, 1 subnets
C 172.12.123.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 172.12.123.1, 00:00:09, Serial0/0
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, FastEthernet0/0
We have solved one problem, R2 is now has the optimal network path to the 10.1.1.0/24 network as a RIP route, but we have introduced a new problem of all the OSPF loopbacks turning into RIP routes as well – So traffic destined for those networks passing through R2 will now be sent to R3 before reaching R4 or R5. So we will need to take that command off, and review options on how we can tweak the Admin Distance on the ABR R2.
I will attempt to change only the AD for OSPF route learned from a particular source:
R2(config)#router ospf 1
R2(config-router)#no distance 121
R2(config-router)#distance ?
<1-255> Administrative distance
ospf OSPF distance
R2(config-router)#distance 121 ?
A.B.C.D IP Source address
<cr>
R2(config-router)#distance 121 30.1.1.3 ?
A.B.C.D Wildcard bits
R2(config-router)#distance 121 30.1.1.3 0.0.0.0 ?
<1-99> IP Standard access list number
<1300-1999> IP Standard expanded access list number
WORD Standard access-list name
<cr>
R2(config-router)#distance 121 30.1.1.3 0.0.0.0
R2(config-router)#do show ip route
[Route codes redacted]
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback2
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:22, Serial0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 00:00:24, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 00:00:24, FastEthernet0/0
172.12.0.0/24 is subnetted, 1 subnets
C 172.12.123.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [110/20] via 30.1.1.3, 00:00:25, FastEthernet0/0
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, FastEthernet0/0
The route table seems to be back to square one, however given the syntax, it appears it should be giving OSPF Process 1 routes learned from IP 30.1.1.3 the AD of 121 – So what happened? What happened was the command actually requires the source routers RID IP, not the actual OSPF interface IP address, so to get the RID we can use “sh ip ospf nei”:
R2(config-router)#do sh ip ospf nei
Neighbor ID Pri State Dead Time Address Interface
3.3.3.3 1 2WAY/DROTHER 00:00:34 30.1.1.3 FastEthernet0/0
4.4.4.4 1 FULL/BDR 00:00:30 30.1.1.4 FastEthernet0/0
5.5.5.5 1 FULL/DR 00:00:39 30.1.1.5 FastEthernet0/0
Now I will remove the old statement, ALWAYS remove old statements with Redistribution, and enter it again using the RID and the host wildcard mask of 0.0.0.0:
R2(config-router)#no distance 121 30.1.1.3 0.0.0.0
R2(config-router)#distance 121 3.3.3.3 0.0.0.0
R2(config-router)#do sh ip route
[Route codes redacted]
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback2
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:19, Serial0/0
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 00:01:11, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 00:01:11, FastEthernet0/0
172.12.0.0/24 is subnetted, 1 subnets
C 172.12.123.0 is directly connected, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 172.12.123.1, 00:00:21, Serial0/0
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, FastEthernet0/0
And there we have it, the traffic destined for R1’s loopback from R2 will now go out the RIP enabled interface, taking the optimal path to the network. If the RIP enabled interface were to go down, it will put the O E2 route back in as a backup path, for example:
R2(config)#int s0/0
R2(config-if)#shut
R2(config-if)#
*Mar 1 11:14:34.456: %LINK-5-CHANGED: Interface Serial0/0, changed state to administratively down
*Mar 1 11:14:35.458: %LINEPROTO-5-UPDOWN: Line protocol on Interface Serial0/0, changed state to down
R2(config-if)#do sh ip route
[Route codes redacted]
Gateway of last resort is not set
2.0.0.0/32 is subnetted, 1 subnets
C 2.2.2.2 is directly connected, Loopback2
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 00:06:32, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 00:06:32, FastEthernet0/0
172.12.0.0/24 is subnetted, 1 subnets
O E2 172.12.123.0 [121/20] via 30.1.1.3, 00:00:18, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [121/20] via 30.1.1.3, 00:00:18, FastEthernet0/0
30.0.0.0/24 is subnetted, 1 subnets
C 30.1.1.0 is directly connected, FastEthernet0/0
Now not only is the path to the 10.1.1.0/24 network using the Redistributed route as a backup route, but now all traffic headed for the NBMA network will be routed to R3 as a network learned via OSPF Redistribution.
I will now turn back on S0/0 on R2, and add a couple of loopbacks to R1 to be Redistributed into OSPF over to R2, and we will see how we can change just particular routes by creating an Access-List to define the source traffic to be affected by the AD command. For this I will be using “show ip route rip” and “show ip route ospf” instead of the full routing table now that we get how funky things can get very quickly.
After configuring 15.1.1.0/24 and 20.1.1.0/24 on R1, let’s look at R2’s route table for them:
R2#show ip route rip
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:00, Serial0/0
R2#show ip route ospf
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 00:00:41, FastEthernet0/0
20.0.0.0/24 is subnetted, 1 subnets
O E2 20.1.1.0 [110/20] via 30.1.1.3, 00:00:41, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 00:00:41, FastEthernet0/0
10.0.0.0/24 is subnetted, 1 subnets
O E2 10.1.1.0 [110/20] via 30.1.1.3, 00:00:41, FastEthernet0/0
15.0.0.0/24 is subnetted, 1 subnets
O E2 15.1.1.0 [110/20] via 30.1.1.3, 00:00:41, FastEthernet0/0
Now we will use these multiple O E2 routes to demonstrate a couple of things, but first we (for whatever reason) want the newly added 15.1.1.0/24 and 20.1.1.0 /24 networks to remain O E2 routes, however we want the 10.1.1.0 /24 network to take RIP over the NBMA rather than going through the ASBR R3. To do this, we will need to use the same distance command, using the same RID of the ASBR as before, except we will continue the command with the access-list output we saw previously in configurations above.
First, we must make an access-list to use in the distance command, defining our network(s) that we want to change the AD for:
R2(config)#access-list 25 permit 10.1.1.0 0.0.0.255
R2(config)#router ospf 1
R2(config-router)#distance 121 3.3.3.3 0.0.0.0 ?
<1-99> IP Standard access list number
<1300-1999> IP Standard expanded access list number
WORD Standard access-list name
<cr>
R2(config-router)#distance 121 3.3.3.3 0.0.0.0 25 ?
<cr>
R2(config-router)#distance 121 3.3.3.3 0.0.0.0 25
I did leave the output for after the ? to show the ACL is called out by the ACL Name or Number created for it, and now that it is already applied to the “distance …” command, when I look at the RIP routing table only that destination network from R1’s loopbacks should be in the RIP table, along with R3’s connected Loopback 3.3.3.3 that I brought into RIP with “redist connected”:
R2(config-router)#do sh ip route rip
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:13, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 172.12.123.1, 00:00:13, Serial0/0
And there it is, simple as that. Now what if we want any O E2 routes hitting this router to be preferred by the RIP routing domain you may ask, as it’s next hop will always be the best path as it is a Boarder Router – Let’s find out! First I will remove the current distance command, and review the other option after “distance” in OSPF router config mode:
R2(config-router)#distance ?
<1-255> Administrative distance
ospf OSPF distance
R2(config-router)#distance ospf ?
external External type 5 and type 7 routes
inter-area Inter-area routes
intra-area Intra-area routes
R2(config-router)#distance ospf
And there is the key to the recipe, if you use “distance ospf [external | inter-area | intra-area] 121” you can force either the O E2, IA, or O routes to change their AD on this router. You can either do one of the three, or all three in the same line, and I’ve about beat this topic to death so I will only be configuring this for External / O E2 routes on R2 after of course remove the previous Administrative Distance configurations for OSPF Process 1:
R2(config-router)#distance ospf external 121
R2(config-router)#do sh ip route ospf
4.0.0.0/32 is subnetted, 1 subnets
O IA 4.4.4.4 [110/2] via 30.1.1.4, 00:01:55, FastEthernet0/0
5.0.0.0/32 is subnetted, 1 subnets
O IA 5.5.5.5 [110/2] via 30.1.1.5, 00:01:55, FastEthernet0/0
R2(config-router)#do sh ip route rip
3.0.0.0/32 is subnetted, 1 subnets
R 3.3.3.3 [120/2] via 172.12.123.3, 00:00:00, Serial0/0
20.0.0.0/24 is subnetted, 1 subnets
R 20.1.1.0 [120/1] via 172.12.123.1, 00:00:00, Serial0/0
10.0.0.0/24 is subnetted, 1 subnets
R 10.1.1.0 [120/1] via 172.12.123.1, 00:00:00, Serial0/0
15.0.0.0/24 is subnetted, 1 subnets
R 15.1.1.0 [120/1] via 172.12.123.1, 00:00:00, Serial0/0
And there we have it! If any traffic destined for the RIP domain is processed by R2, is will send it directly to the Hub R1 rather than taking the LAN to R3, then being relayed up to the Hub Router.
This concludes OSPF Redistribution for now, next up will be EIGRP Redistribution! Woo!
One thought on “OSPF to RIP, 4 ways to change AD, Sub-Optimal Routing & Route Loops”