Ospf conditional routing

OSPF conditional routing takes advantage of taking a default route and using that route based off of a route on the local router originating that default route.  Normally conditional routing is used to advertise a default route depending if the originating routers interface facing the service provider is up or not.

Our topology.

OSPFDEFAULT2

Our topology is very simple.  Every router is running OSPF  except for the top two they simply inject a BGP default route.  the CE routers simply have the BGP default route for their rib to pass off the default route into OSPF.  So here is our configuration on the CE routers.

R7

r7#sh ip route 0.0.0.0
Routing entry for 0.0.0.0/0, supernet
Known via “bgp 100”, distance 20, metric 0, candidate default path
Tag 2, type external
Last update from 11.11.11.11 00:25:13 ago
Routing Descriptor Blocks:
* 11.11.11.11, from 11.11.11.11, 00:25:13 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 2

router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 11.11.11.11 remote-as 2
neighbor 11.11.11.11 ebgp-multihop 5
neighbor 11.11.11.11 update-source Loopback0
no auto-summary

router ospf 1
log-adjacency-changes
network 7.7.7.7 0.0.0.0 area 0
network 27.27.27.0 0.0.0.255 area 0
default-information originate

R6

R6#sh ip route 0.0.0.0
Routing entry for 0.0.0.0/0, supernet
Known via “bgp 100”, distance 20, metric 0, candidate default path
Tag 2, type external
Last update from 12.12.13.12 00:41:36 ago
Routing Descriptor Blocks:
* 12.12.13.12, from 12.12.13.12, 00:41:36 ago
Route metric is 0, traffic share count is 1
AS Hops 1
Route tag 2

router bgp 100
no synchronization
bgp log-neighbor-changes
neighbor 12.12.13.12 remote-as 2
neighbor 12.12.13.12 ebgp-multihop 5
neighbor 12.12.13.12 update-source Loopback0
no auto-summary

router ospf 1
log-adjacency-changes
network 6.6.6.6 0.0.0.0 area 0
network 36.36.36.0 0.0.0.255 area 0
default-information originate

Okay so now that we got that out of the way lets check out S2 and see what our default route looks like.

S2#sh ip route 0.0.0.0
Routing entry for 0.0.0.0/0, supernet
Known via “ospf 1”, distance 110, metric 1, candidate default path
Tag 1, type extern 2, forward metric 65
Last update from 32.32.32.3 on Vlan32, 00:00:36 ago
Routing Descriptor Blocks:
32.32.32.3, from 6.6.6.6, 00:00:36 ago, via Vlan32
Route metric is 1, traffic share count is 1
Route tag 1
* 26.26.26.2, from 7.7.7.7, 00:00:36 ago, via Vlan26
Route metric is 1, traffic share count is 1
Route tag 1

ugh oh looks like we have two default routes. Lets check an Upstream router.

R3#sh ip route 0.0.0.0
Routing entry for 0.0.0.0/0, supernet
Known via “ospf 1”, distance 110, metric 1, candidate default path
Tag 1, type extern 2, forward metric 64
Last update from 36.36.36.6 on Serial0/0, 00:01:32 ago
Routing Descriptor Blocks:
* 36.36.36.6, from 6.6.6.6, 00:01:32 ago, via Serial0/0
Route metric is 1, traffic share count is 1
Route tag 1

Its going to load balance the default route due to it being a equal metric you can see that in the drawing.  I really do not want to that due to possible asyncrhonous routing issues.  The most simplistic way to get rid of this is to set the cost on one of the interfaces facing upstream to the CE routers.

R3(config)#int s0/0

R3(config-if)#ip ospf cost 1000

This ill give me one router on S2.

Okay so now the good part here.  I can simple attach the locally connected interface as a prefix-list and tie it in with a route-map.  Then use it in ospf after my default-information originate statement so that if that interface goes down it will traverse the other router. For example.

R7 is Primary its primary interface is Se1/0 71.71.71.0/24

R6 is Secondary due to OSPF cost its interface is Se1/0 62.62.62.0/24

So we will create a prefix list on both routers.  I will simply show R7 to begin with.

ip prefix-list 71 seq 5 permit 71.71.71.0/24

route-map default permit 10
match ip address prefix-list 71

Now before I add anything into OSPF lets check S2 to see where our default route is.

Routing entry for 0.0.0.0/0, supernet
Known via “ospf 1”, distance 110, metric 1, candidate default path
Tag 1, type extern 2, forward metric 65
Last update from 26.26.26.2 on Vlan26, 00:04:58 ago
Routing Descriptor Blocks:
* 26.26.26.2, from 7.7.7.7, 00:04:58 ago, via Vlan26
Route metric is 1, traffic share count is 1
Route tag 1

Great we take the path to R7.  Due to our cost setting we will always take that path.  Now lets go ahead and tie a route-map in on R6 and R7 with our matching prefix lists.

Our default route should still stay the same on S2.  Now lets go ahead and Shut down interface Se1/0 so that there is no RIB match for the Subnet 71.71.71.0/24 if everything works right OSPF will stop advertising a default route originating from R7 and start originating from R6.

r7(config)#int se1/0
r7(config-if)#shut

Now going to S2 if everything worked we should see a default route heading out to R6

S2#sh ip route 0.0.0.0
Routing entry for 0.0.0.0/0, supernet
Known via “ospf 1”, distance 110, metric 1000, candidate default path
Tag 1, type extern 2, forward metric 1001
Last update from 32.32.32.3 on Vlan32, 00:00:20 ago
Routing Descriptor Blocks:
* 32.32.32.3, from 6.6.6.6, 00:00:20 ago, via Vlan32
Route metric is 1000, traffic share count is 1
Route tag 1

This is a nice feature, this can be used the most simplistic ways for conditional routing.  This can also be tied into a IP SLA and other creative routing techniques.

Advertisements
Post a comment or leave a trackback: Trackback URL.

Leave a Reply

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 )

Google+ photo

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

Connecting to %s

%d bloggers like this: