Community discussions

MikroTik App
 
User avatar
SoundGuyFYI
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Wed Jun 05, 2013 12:43 am

Default Route from BGP to OSPF

Tue Jun 09, 2015 5:20 pm

All,

I am setting up OSPF as my internal Routing protocol. I have three Fiber providers over a large geographic area.

I am setting up fail over to the point that if one of the providers go down, the traffic normally routed through that provider will go through our internal network and out another provider.

These are public IPs and private that I'm routing over OSPF.

I receive the default router from BGP with all three of my providers.

My simple question is this. How do I distribute the default router that I get from my BGP peers into my ospf network. Yes there would be three, but that is what I want. I already have the metrics in place to manage when and where the default route will be used but when enabling distribute-default=if-installed-as-type-1 I noticed that it will not advertise the router is it is coming from BGP.

I need it to use the route from bgp in someway cause that is how I'm controlling failover.

Any ideas? Thanks!

(sorry for my spelling, sorta in a quick situation)
 
Muqatil
Trainer
Trainer
Posts: 573
Joined: Mon Mar 03, 2008 1:03 pm
Location: London - UK
Contact:

Re: Default Route from BGP to OSPF

Tue Jun 09, 2015 6:38 pm

OSPF will announce default route "if-installed" only if it has a flag "STATIC" (a static route, or a created by DHCP, PPP, etc)
OSPF will not announce BGP default routes.
All you can do, is some netwatch scripting disabling or enabling default-originate option in OSPF istance. Or a static default route with check-gateway option enabled.
 
User avatar
SoundGuyFYI
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Wed Jun 05, 2013 12:43 am

Re: Default Route from BGP to OSPF

Tue Jun 09, 2015 6:46 pm

If I select to redistribute BGP will that include the default route?
 
Muqatil
Trainer
Trainer
Posts: 573
Joined: Mon Mar 03, 2008 1:03 pm
Location: London - UK
Contact:

Re: Default Route from BGP to OSPF

Tue Jun 09, 2015 7:03 pm

It should not.
 
User avatar
SoundGuyFYI
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Wed Jun 05, 2013 12:43 am

Re: Default Route from BGP to OSPF

Tue Jun 09, 2015 7:46 pm

So in theory, there is no way to redistribute the default router from bgp to ospf?

That seams a little odd.
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: Default Route from BGP to OSPF

Fri Jun 12, 2015 2:59 am

You can definitely redistribute the default route from BGP into OSPF. On the router that is doing the redistribution from BGP into OSPF, use the following config and the default will be advertised in OSPF only as long as it exists in BGP.
/routing ospf instance
set [ find default=yes ] distribute-default=if-installed-as-type-1
Here is an example from our lab
[admin@IPA-LAB-OSPF-Customer] > ip route print detail
Flags: X - disabled, A - active, D - dynamic, 
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, 
B - blackhole, U - unreachable, P - prohibit 
 0 ADo  dst-address=0.0.0.0/0 gateway=100.65.0.1 
        gateway-status=100.65.0.1 reachable via  ether5 distance=110 scope=20 
        target-scope=10 ospf-metric=11 ospf-type=external-type-1 

 1 ADC  dst-address=100.65.0.0/30 pref-src=100.65.0.2 gateway=ether5 
        gateway-status=ether5 reachable distance=0 scope=10 
[admin@IPA-LAB-OSPF-Customer] > 
Logs from the BGP/OSPF router when the BGP default is withdrawn in the upstream BGP Internet peer
23:51:57 route,debug Target withdraw  
23:51:57 route,debug     prefix=0.0.0.0/0 
23:51:57 route,debug     previous attributes 
23:51:57 route,debug         protocol=BGP 
23:51:57 route,debug         scope=40 
23:51:57 route,debug         immediate-next-hop= address=100.64.0.1 interface=ether5 
23:51:57 route,debug         next-hop= address=100.64.0.1 
23:51:57 route,debug         origin-type=BGP 
23:51:57 route,debug         origin-instance-id=0 
23:51:57 route,debug         bgp-peer-router-id=1.1.1.2 
23:51:57 route,debug         bgp-peer-flags=0 
23:51:57 route,debug         bgp-router-id=2.2.2.2 
23:51:57 route,debug         bgp-origin=IGP 
23:51:57 route,debug         bgp-as-path=7018 
23:51:57 route,debug         bgp-as-path-len=1 
23:51:57 route,debug         bgp-nexthop=100.64.0.1 
23:51:57 route,debug         use-te-nexthop=yes 
Same as above but as viewed from the OSPF only router
23:40:57 route,debug Target withdraw  
23:40:57 route,debug     prefix=0.0.0.0/0 
23:40:57 route,debug     previous attributes 
23:40:57 route,debug         protocol=OSPF 
23:40:57 route,debug         scope=20 
23:40:57 route,debug         immediate-next-hop= address=100.65.0.1 interface=ethe
r5 
23:40:57 route,debug         next-hop= address=100.65.0.1 
23:40:57 route,debug         origin-type=OSPF 
23:40:57 route,debug         origin-instance-id=0 
23:40:57 route,debug         ospf-metric=11 
23:40:57 route,debug         ospf-type=external-type-1 
Finally, the routing table on the OSPF router after disabling it in the upstream BGP router.
[admin@IPA-LAB-OSPF-Customer] > ip route print detail
Flags: X - disabled, A - active, D - dynamic, 
C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, 
B - blackhole, U - unreachable, P - prohibit 
 0 ADC  dst-address=100.65.0.0/30 pref-src=100.65.0.2 gateway=ether5 
        gateway-status=ether5 reachable distance=0 scope=10 
 
User avatar
SoundGuyFYI
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Wed Jun 05, 2013 12:43 am

Re: Default Route from BGP to OSPF

Fri Jun 12, 2015 6:33 am

Would you be able to see those routes in the LSA tab even if the router has a static route with a better metric?
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: Default Route from BGP to OSPF

Sun Jun 14, 2015 6:28 pm

Yes because OSPF by default, requires all routers in an area to have knowledge of all LSAs in that area. You may need to raise the distance of the static route or put it into another routing table if you don't want it to take priority over the BGP learned defaults for the traffic that is being funneled up to the redistributing router.

When it comes to a redistributed default, the static LSA will look identical to the BGP LSA because both come from a routing protocol external to OSPF and the router advertising them into OSPF is 2.2.2.2 hence the identical originator.

The output below is from disabling the default route in one protocol so that it is clear which protocol is feeding the default. When both BGP and Static default routes are learned, there is only one LSA advertised since the intent is to offer a route to the redistribution point, after the traffic gets there, it can take multiple paths if they are enabled with equal distance (usually requires static routes or OSPF underneath BGP to get ECMP for BGP)
.
Redistributed BGP default LSA
instance=default area=external type=as-external id=0.0.0.0 originator=2.2.2.2 sequence-number=0x80000001 age=76 checksum=0x2D1D options="E" body=
     netmask=0.0.0.0
     forwarding-address=0.0.0.0
     metric=1
     route-tag=0x0
     type1
Redistributed Static Default LSA
instance=default area=external type=as-external id=0.0.0.0 originator=2.2.2.2 sequence-number=0x80000001 age=1 checksum=0x2D1D options="E" body=
     netmask=0.0.0.0
     forwarding-address=0.0.0.0
     metric=1
     route-tag=0x0
     type1
 
User avatar
SoundGuyFYI
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Wed Jun 05, 2013 12:43 am

Re: Default Route from BGP to OSPF

Wed Jun 17, 2015 7:28 am

So here is my situation:

Router configured with BGP receiving DR from peer
OSPF configured to redistribute DR as =if-installed-as-type1

Yet no LSA in OSPF for the default route. What could block that?

Route List of router:
/ip route> print
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit 
 #      DST-ADDRESS        PREF-SRC        GATEWAY            DISTANCE
 2 ADb  0.0.0.0/0                          209.152.151.5            20
 3 X S  0.0.0.0/0                          10.225.0.21              30
 4 ADb  1.0.0.0/24                         209.152.151.5            20
 5 ADb  1.0.4.0/24                         209.152.151.5            20
 6 ADb  1.0.5.0/24                         209.152.151.5            20
 7 ADb  1.0.6.0/24                         209.152.151.5            20
 8 ADb  1.0.7.0/24                         209.152.151.5            20
 9 ADb  1.0.64.0/18                        209.152.151.5            20
 ...
OSPF Instance Config
 /routing ospf instance> print
Flags: X - disabled, * - default 
 0  * name="default" router-id=10.200.0.3 distribute-default=if-installed-as-type-1 redistribute-connected=as-type-1 redistribute-static=as-type-1 
      redistribute-rip=no redistribute-bgp=no redistribute-other-ospf=no metric-default=20 metric-connected=20 metric-static=20 metric-rip=20 metric-bgp=auto 
      metric-other-ospf=auto in-filter=ospf-in out-filter=ospf-out 
I would paste the LSA list but theres not much point since its not in there. All other routes are installing as I expect.

Any other things I need to look out for?
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: Default Route from BGP to OSPF

Wed Jun 17, 2015 4:33 pm

Do you see the LSA for the static route? How disruptive would it be to try a different version of RouterOS? I tested this on 6.29.1 without issues.

Can you post a drawing of the topology?
 
User avatar
SoundGuyFYI
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 74
Joined: Wed Jun 05, 2013 12:43 am

Re: Default Route from BGP to OSPF

Wed Aug 19, 2015 12:00 am

Do you see the LSA for the static route? How disruptive would it be to try a different version of RouterOS? I tested this on 6.29.1 without issues.

Can you post a drawing of the topology?
Sadly I have not had the opportunity to upgrade to that version yet.

I am currently running 6.25. If I can verify that an upgrade will allow me to make this BGP to OSPF default route work than I can justify an upgrade request to my superiors.
 
User avatar
cohprog
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Sat May 23, 2015 4:54 pm
Contact:

Re: Default Route from BGP to OSPF

Wed Aug 19, 2015 9:52 am

You can definitely redistribute the default route from BGP into OSPF. On the router that is doing the redistribution from BGP into OSPF, use the following config and the default will be advertised in OSPF only as long as it exists in BGP.
/routing ospf instance
set [ find default=yes ] distribute-default=if-installed-as-type-1
Doesn't work. Well it work the first time but as soon as default route received by BGP vanish and come back again, it won't work anymore. (Like if the command apply when you enter it only)
Last edited by cohprog on Wed Aug 19, 2015 10:28 am, edited 1 time in total.
 
User avatar
cohprog
Frequent Visitor
Frequent Visitor
Posts: 64
Joined: Sat May 23, 2015 4:54 pm
Contact:

Re: Default Route from BGP to OSPF

Wed Aug 19, 2015 10:01 am

Imho, do a iBGP session between your various BGP routers to distribute the default route received from your upstream providers. In the BGP peer config, set "nexthop choice" to "force self" and "default originate" to "if installed"

Then configure the OSPF sessions on those routers to redistribute default route "always as type-1".

That way:
1. The routers will always distribute their default route by OSPF (if they have one)
2. If a router lose its upstream connection, it will still receive a default route from one of the other router through the iBGP session.
 
fallegretti
newbie
Posts: 33
Joined: Thu Jul 20, 2017 1:23 pm

Re: Default Route from BGP to OSPF

Thu Nov 02, 2017 6:25 pm

Having the same issue, runing version 6.40 into a virtual environment.

Very simple setup a router upstream sending a default route to the MT, route in the routing table.

The MT has a full ospf relation with a router downstream, applied the command but the OSPF router is not getting the default.
 
fallegretti
newbie
Posts: 33
Joined: Thu Jul 20, 2017 1:23 pm

Re: Default Route from BGP to OSPF

Thu Nov 02, 2017 6:40 pm

@SoundGuyFYI

Actually it works but you still have redistribute bgp into ospf, we still need an LSA in the OSPF database right, if we do not redistribute BGP into OSPF, there is no LSA for it.

Once you do that (make sure you have you filter right) you can inject it into OSPF with the command shown above
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Default Route from BGP to OSPF

Thu Nov 02, 2017 6:59 pm

Yo do not need to redistribute all BGP into OSPF. It is bad idea even if you set routing filters.

To redistribute BGP default route into OSPF, jou just need to set
/routing ospf instance
set default distribute-default=if-installed-as-type-1 or type-2

Note that there may be problems if you have other OSPF routers in the network that are distributing default route.
 
fallegretti
newbie
Posts: 33
Joined: Thu Jul 20, 2017 1:23 pm

Re: Default Route from BGP to OSPF

Thu Nov 16, 2017 12:54 pm

Thanks MRZ.

I am aware and agree with you but it does not work if I do not redistribute BGP, I got it set up on GNS3, I can't prove it on the live network.

On the live network I have it setup as you describe below (was hoping it was going to work) but I don't get the OSPF default route.

I read from a previous post on this thread by IPANetEngineer "You can definitely redistribute the default route from BGP into OSPF. On the router that is doing the redistribution from BGP into OSPF"
which implies redistribution is needed; it would be useful if you could clarify.

Here is what I see on my live network:
/routing ospf instance> /ip address print
Flags: X - disabled, I - invalid, D - dynamic
# ADDRESS NETWORK INTERFACE
0 172.31.254.8/32 172.31.254.8 loopback0
/routing ospf instance> print
Flags: X - disabled, * - default
0 * name="default" router-id=172.31.254.8 distribute-default=if-installed-as-type-1 redistribute-connected=no redistribute-static=as-type-1
redistribute-rip=no redistribute-bgp=no redistribute-other-ospf=no metric-default=1 metric-connected=20 metric-static=20 metric-rip=20 metric-bgp=auto
metric-other-ospf=auto in-filter=ospf-in out-filter=ospf-out
/ip route print
Flags: X - disabled, A - active, D - dynamic, C - connect, S - static, r - rip, b - bgp, o - ospf, m - mme, B - blackhole, U - unreachable, P - prohibit
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 ADb 0.0.0.0/0 172.26.225.189 20

So in theory this should work and yet, when I look at the OSPF neighbors:

asr-hub-01#sh ip ospf nei

Neighbor ID Pri State Dead Time Address Interface
172.31.254.8 1 FULL/DR 00:00:39 172.31.253.35 GigabitEthernet0/0/0.110

asr-hub-01#sh ip ospf database external 0.0.0.0

OSPF Router with ID (172.31.254.11) (Process ID 1000)

Nothing, I don't get the route.

Help would be really appreciated.
Thanks
 
fallegretti
newbie
Posts: 33
Joined: Thu Jul 20, 2017 1:23 pm

Re: Default Route from BGP to OSPF

Thu Nov 16, 2017 4:17 pm

Hi Mrz,
I am seeing very inconsitent behaviours.

This is what I can now replicate almost consistently on GNS3. If I set distribute-default=if-installed-as-type-1 and then I get the default route from BGP then it works, I can shut/unsht the bgp perring and the default gets in and out of OSPF. If I receive the BGP first and then I set distribute-default=if-installed-as-type-1 I do not get the default lsa in the local database and therefore not passed to the other routers.

As said, this seems to be quite consistent on GNS3, so I thought on the live network, I shut down my upstream provider, enable distribute-default=if-installed-as-type-1 and then re-enable bgp to get the default from my provider; unfortunately it did not work.

Would you be able to replicate that in a lab and maybe pass the results to the developers?To summarise my setup:
1) Set up bgp between two routers
2) pass a default route via bgp
3)Configure OSPF between the router receiving the bgp default (with distribute-default=if-installed-as-type-1) and another router

If I follow the above steps in that order, I do not get the LSA for 0.0.0.0 in my database.
If I do 3 first I do get it but only on GNS3 :-(
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Default Route from BGP to OSPF

Thu Nov 16, 2017 4:26 pm

Yes, problem is already reported. We repeated the problem with different test a while ago.
 
fallegretti
newbie
Posts: 33
Joined: Thu Jul 20, 2017 1:23 pm

Re: Default Route from BGP to OSPF

Thu Nov 16, 2017 4:57 pm

Thanks Mrz, at least I know I am not going mad.

I am sure you aleready know this as you say you have been running tests. The other way I can get the lsa for the default to appear is to redistribute bgp into OSPF, I can then take it off and it keeps working, but it seems that OSPF needs a "trigger" after teh distribute-default command is applied to kick in. it would be useful to know when MT believes they'll have a fix for it.

Many Thanks
 
estit
just joined
Posts: 4
Joined: Tue Feb 06, 2018 9:46 pm
Location: Germany; Gescher
Contact:

Re: Default Route from BGP to OSPF

Sat Dec 21, 2019 4:42 pm

Hi,

I'm having the same problem.
Yes, problem is already reported. We repeated the problem with different test a while ago.
@mrz: Should the problem solved meanwhile? Using the latest RouterOS Version.
 
User avatar
mrz
MikroTik Support
MikroTik Support
Posts: 7038
Joined: Wed Feb 07, 2007 12:45 pm
Location: Latvia
Contact:

Re: Default Route from BGP to OSPF

Thu Jan 09, 2020 12:58 pm

Yes, that particular problem from 2017 is fixed. If you have the same symptoms contact support.
 
User avatar
tomasi
Frequent Visitor
Frequent Visitor
Posts: 98
Joined: Fri Oct 03, 2014 6:40 pm
Location: Brazil
Contact:

Re: Default Route from BGP to OSPF

Fri Jun 11, 2021 8:22 pm

Hi,

Today I noticed this bug is still not fixed in version 6.45.9

Even though Redistribute Default Route = if installed (as type 1) was configured, BGP default route was not redistributed to adjacent routers (OSPF).

I needed to create a static Default Route to make it work.

Who is online

Users browsing this forum: No registered users and 15 guests