cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3914
Views
5
Helpful
14
Replies

Conditional default route advertisement in OSPF with route-map

cparish17
Level 1
Level 1

I have a router running ospf and BGP. I'm trying to establish the following behavior regarding the default route:
If we learn default from OSPF neighbor, install in routing table
ELSE
If we learn default from BGP, install into routing table and inject into OSPF.
ELSE
inject default from static into routing table.

I'm using "network 0.0.0.0 backdoor" to prefer the ospf route over bgp.
Static route has AD of 210, so BGP preferred over static.

I'm unable to inject default into the routing table. Using a route-map to try to conditionally inject the route:

router ospf 100
default-information originate metric 3000 route-map ospf_def

route-map ospf_def permit 10
description learning quad0 from VSAT
match source-protocol static
set metric 5000
set tag 1010007
!
route-map ospf_def permit 30
description default route from BGP
match source-protocol bgp 65036
set metric 100
!
route-map ospf_def deny 100
!
Not getting the default route into OSPF.

1 Accepted Solution

Accepted Solutions

Hello,

 

after looking at this and trying different setups, it looks like the 'match source-protocol static' won't work in this scenario. So this is what I have come up with (for the OSPF part).

 

In a real world scenario, you would only get the default route from your OSPF neighbor if the link is up. So, you could use IP SLA tracking as configured below. The bogus route is being tracked and is the match condition for the default route injection.

 

ip sla 1
icmp-echo 192.168.1.2 source-ip 192.168.1.1
frequency 5

!

ip sla schedule 1 start-time now life forever
track 1 rtr 1 reachability

!

ip route 169.254.1.1 255.255.255.255 null 0 track 1

!

ip prefix-list default_route seq 10 permit 169.254.1.1/32
route-map ospf_def permit 10
match ip address prefix-list default_route

!

router ospf 100
default-information originate always route-map OSPF_default

 

Another way to locally inject the default route is an EEM script that tracks the existence of the default route in the routing table. If it is removed (no longer received from the OSPF neighbor), the 'default-information originate always' command is added to your OSPF configuration. If it is added (received again from the OSPF neighbor), the command is removed:

 

event manager applet REMOVE_OSPF_DEFAULT
event routing network 0.0.0.0/0 type remove protocol OSPF
trigger occurs 1
action 1.0 cli command "enable"
action 1.5 cli command "conf t"
action 2.0 cli command "router ospf 1"
action 3.0 cli command "default-information originate always"
action 4.0 cli command "end"
action 5.0 cli command "wr mem"

 

event manager applet ADD_OSPF_DEFAULT
event routing network 0.0.0.0/0 type add protocol OSPF
trigger occurs 1
action 1.0 cli command "enable"
action 1.5 cli command "conf t"
action 2.0 cli command "router ospf 1"
action 3.0 cli command "no default-information originate always"
action 4.0 cli command "end"
action 5.0 cli command "wr mem"

View solution in original post

14 Replies 14

Hello,

 

post the configs of the OSPF and BGP neighbors, as well as the full config of the router that runs the BGP and OSPF. You say that you are receiving the OSPF default route from the OSPF neighbor, but you are originating it locally ?

cparish17
Level 1
Level 1

I only want to inject it locally IF I'm not learning it from an OSPF neighbor.

I want to inject it from BGP if available, or else from a static:

ip route 0.0.0.0 0.0.0.0 Null0 210

router ospf 100

default-information originate metric 3000 route-map ospf_def

route-map ospf_def permit 10
description learning quad0 from VSAT
match source-protocol static
set metric 5000
set tag 1010007
!
route-map ospf_def permit 30
description default route from BGP
match source-protocol bgp 65036
set metric 100
!
route-map ospf_def deny 100
!

 

Hello,

 

the first part of your route map needs to match a prefix list:

 

ip prefix-list OSPF_DEFAULT seq 10 permit 0.0.0.0/0
!
route-map OSPF permit 10
!
route-map ospf_def permit 10
match ip address prefix-list OSPF_DEFAULT
set metric 5000
set tag 1010007

 

I seems like that would inject the route whenever the default route was present.. It that were my objective, I wouldn't need a route-map.

Am I missing something?

I'll look into it...

Hello,

 

after looking at this and trying different setups, it looks like the 'match source-protocol static' won't work in this scenario. So this is what I have come up with (for the OSPF part).

 

In a real world scenario, you would only get the default route from your OSPF neighbor if the link is up. So, you could use IP SLA tracking as configured below. The bogus route is being tracked and is the match condition for the default route injection.

 

ip sla 1
icmp-echo 192.168.1.2 source-ip 192.168.1.1
frequency 5

!

ip sla schedule 1 start-time now life forever
track 1 rtr 1 reachability

!

ip route 169.254.1.1 255.255.255.255 null 0 track 1

!

ip prefix-list default_route seq 10 permit 169.254.1.1/32
route-map ospf_def permit 10
match ip address prefix-list default_route

!

router ospf 100
default-information originate always route-map OSPF_default

 

Another way to locally inject the default route is an EEM script that tracks the existence of the default route in the routing table. If it is removed (no longer received from the OSPF neighbor), the 'default-information originate always' command is added to your OSPF configuration. If it is added (received again from the OSPF neighbor), the command is removed:

 

event manager applet REMOVE_OSPF_DEFAULT
event routing network 0.0.0.0/0 type remove protocol OSPF
trigger occurs 1
action 1.0 cli command "enable"
action 1.5 cli command "conf t"
action 2.0 cli command "router ospf 1"
action 3.0 cli command "default-information originate always"
action 4.0 cli command "end"
action 5.0 cli command "wr mem"

 

event manager applet ADD_OSPF_DEFAULT
event routing network 0.0.0.0/0 type add protocol OSPF
trigger occurs 1
action 1.0 cli command "enable"
action 1.5 cli command "conf t"
action 2.0 cli command "router ospf 1"
action 3.0 cli command "no default-information originate always"
action 4.0 cli command "end"
action 5.0 cli command "wr mem"

the EEM script worked as advertised. Doesn't give me exactly the control I wanted in terms of distinguishing BGP route from static route, and basing metric on that information... but it works.

Thanks.

Hello

as stated previously can post you current topology Awhich would assist in providing alternate solutions

 

res

paul


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Hello

So you have a ebgp connection and IGP(ospf) connection on the same router and you wish traffic take the OSPF path via its default route instead of the external bgp path default route but utilize the bgp default incase the ospf default is not available?

res
Paul


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

Yes.

If OSPF advertises a default route me, I  just want to accept it an do nothing.

If I'm no longer receiving the default route from OSPF, I want to inject one.

If I'm not learning it from OSPF I can be learning it from BGP, or if not from BGP, from a floating static (admin distance 210). When injecting the default in these circumstances, I like to set different tag and metric, depending on whether I learned from BGP or from static.

 

Hello

There a few ways to accomplish this  but first can you elaborate on your topology ?

Can you share a diagram so to validate your network in relation to the bgp and ospf peering, how many routes are you advertising etc..

 

I assume you just want use IGP for local subnets between the two sites and bgp default for all wan traffic?

res
Paul


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

The thing is: you cannot inject a default route into OSPF based on a non-existent static route, you have to match something that is actually there. What about the IP SLA config with the bogus route ? Is that an option ?

Hello Georg

That's not necessarily correct - you can utilize the NON-EXIST map in bgp to advertise or Inject certain prefix(s) if routes referenced by the NON-EXIST map are not in the bgp table

 

res
Paul

 


Please rate and mark as an accepted solution if you have found any of the information provided useful.
This then could assist others on these forums to find a valuable answer and broadens the community’s global network.

Kind Regards
Paul

I was referring to the original post where OP tries to use a route map to inject a default route into OSPF with the 'default-information originate' and a route map attached...

Unless of course there is a way to do this in OSPF...

Review Cisco Networking for a $25 gift card