10-27-2017 11:44 AM - edited 03-08-2019 12:31 PM
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.
Solved! Go to Solution.
10-28-2017 12:20 PM
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"
10-27-2017 12:19 PM
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 ?
10-27-2017 01:15 PM
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
!
10-27-2017 02:19 PM
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
10-27-2017 02:39 PM
10-27-2017 02:50 PM
I'll look into it...
10-28-2017 12:20 PM
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"
10-31-2017 09:14 AM
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.
10-31-2017 09:25 AM
Hello
as stated previously can post you current topology Awhich would assist in providing alternate solutions
res
paul
10-28-2017 12:57 PM
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
10-30-2017 07:24 AM
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.
10-30-2017 01:10 PM
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
10-30-2017 01:18 PM
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 ?
10-30-2017 01:24 PM
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
10-30-2017 01:33 PM
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...
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide