Community discussions

MikroTik App
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

OSPF overwrite static default-gateway. Possible ?

Tue Mar 03, 2015 3:44 pm

Hello.

Is it possible to "overwrite" locally inserted default-gateway with the one got via ospf ?

I mean if I have 2 mikrotiks with ospf running and both boxes have different default-gateways. I want all the traffic go through only one of them until it goes down.

RGDS
 
Muqatil
Trainer
Trainer
Posts: 573
Joined: Mon Mar 03, 2008 1:03 pm
Location: London - UK
Contact:

Re: OSPF overwrite static default-gateway. Possible ?

Tue Mar 03, 2015 4:24 pm

Sure!
Your default route should be set as "distribute-default=if-installed-as-type1" and the static gateways should have check-gateway=ping to disable it if it's not reachable. Of course if the gateway is a ADSL router, you should use a recursive gateway to ensure the check gateway to work properly.
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Tue Mar 03, 2015 5:42 pm

It doesn't work.

I put 2 mikrotik boxes, both 6.27.

Each has it's own default-gateway - both are different ones. Both have OSPF running.
All works fine until I turn on "redistributedefult route" on second router. After that is use ONLY it's own static default-gw. Ospf injection does't work :(
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 11:55 am

Here configs

1. R1 configuration
/interface ethernet
set [ find default-name=ether1 ] name=ether1-OUT1
set [ find default-name=ether2 ] name=ether2-R2

/routing ospf instance
set [ find default=yes ] distribute-default=if-installed-as-type-1 name=R1 \
    redistribute-connected=as-type-1 router-id=255.255.255.255

/ip address
add address=192.168.0.2/24 interface=ether1-OUT1 network=192.168.0.0
add address=10.255.0.6/30 interface=ether2-R2 network=10.255.0.4
add address=192.168.90.1/24 interface=ether4 network=192.168.90.0
/ip route
add distance=1 gateway=192.168.0.1

/routing ospf network
add area=backbone network=10.255.0.4/30

/system identity
set name=R1

2. R2 configuration
/interface ethernet
set [ find default-name=ether5 ] name=ether5-OUT2
set [ find default-name=ether6 ] name=ether6-R1

/routing ospf area
set [ find default=yes ] name=R2
/routing ospf instance
set [ find default=yes ] distribute-default=if-installed-as-type-1 \
    metric-default=100  name=R2 redistribute-connected=\
    as-type-1

/ip address
add address=192.168.88.1/24 interface=ether8 network=192.168.88.0
add address=10.255.0.5/30 interface=ether6-R1 network=10.255.0.4
add address=192.168.1.23/24 interface=ether5-OUT2 network=192.168.1.0
/ip route
add check-gateway=ping distance=200 gateway=192.168.1.1

/routing ospf network
add area=R2 network=10.255.0.4/30


/system identity
set name=R2
But on R2 we see
[admin@R2] > routing ospf neighbor pr

 0 instance=R2 router-id=255.255.255.255 address=10.255.0.6 interface=ether6-R1 
   priority=1 dr-address=10.255.0.6 backup-dr-address=10.255.0.5 state="Full" 
   state-changes=6 ls-retransmits=0 ls-requests=0 db-summaries=0 
   adjacency=13m54s 
[admin@R2] > 
But R2 uses it's own default gw!
[admin@R2] > ip rou pr
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 A S  0.0.0.0/0                          192.168.1.1             200
 1 ADC  10.255.0.4/30      10.255.0.5      ether6-R1                 0
 2 ADo  192.168.0.0/24                     10.255.0.6              110
 3 ADC  192.168.1.0/24     192.168.1.23    ether5-OUT2               0
 4  DC  192.168.88.0/24    192.168.88.1    ether8                  255
[admin@R2] > 
Just for info
[admin@R2] > routing ospf route pr
 # DST-ADDRESS        STATE          COST         GATEWAY         INTERFACE    
 0 0.0.0.0/0          imported-ext-1 100         
 1 10.255.0.4/30      intra-area     10           0.0.0.0         ether6-R1    
 2 192.168.0.0/24     ext-1          30           10.255.0.6      ether6-R1    
 3 192.168.1.0/24     imported-ext-1 100         
[admin@R2] > 
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 2:36 pm

Is the OSPF learned default route you are trying to use being imported from another routing table (VRF/Route Mark)?
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 2:42 pm

Nope.

You see the whole configuration of mikrotiks - they are just standing on my table.
 
DLNoah
Member Candidate
Member Candidate
Posts: 144
Joined: Fri Nov 12, 2010 5:33 pm

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 3:41 pm

In my experience, working with ROS v6.17 (and a few earlier versions of 6), it's sort of possible to get this to happen, but it will require manual (or scripted) intervention after network topology changes.

On R1 (the primary out), you would continue as you have it set up -- the static default route has a cost of less than 110 and is set to check gateway (ping or arp, depending on how the gateway is setup), OSPF is set up to redistribute if installed (as either t1 or t2, doesn't make any difference in a 2 default route setup).

On R2 (the secondary out), you set up the static route with a cost of more than 110 and check gateway, set up OSPF to redistribute if installed. But, in order to get it to actually install the OSPF route in the local router's routing table, you must disable the static route first. If the static default route is disabled, OSPF will install its learned default route in the local routing table. After the OSPF route installs, you can then enable the static default route, which will sit there unused (and not redistribute into OSPF) until the R1 route fails.

However, you will have to manually disable the static default route on R2 after every time it becomes active -- once R1 comes back up, you'll still have both static routes active until the R2 route is disabled & re-enabled as above.
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 3:51 pm

I already found this circus with manual enable/disable default route on R2 but I think that's incorrect!

BTW do you have a working script to mange this issue ?
 
DLNoah
Member Candidate
Member Candidate
Posts: 144
Joined: Fri Nov 12, 2010 5:33 pm

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 4:03 pm

The only place I use it at, manual intervention is sufficient for my needs, so I haven't done any scripting work towards trying to automate the recovery.
 
User avatar
StubArea51
Trainer
Trainer
Posts: 1739
Joined: Fri Aug 10, 2012 6:46 am
Location: stubarea51.net
Contact:

Re: OSPF overwrite static default-gateway. Possible ?

Wed Mar 04, 2015 11:29 pm

Please post the output of
routing ospf lsa print detail
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 10:18 am

[admin@R2] > routing ospf lsa pr de
 instance=R2 area=R2 type=router id=192.168.88.1 originator=192.168.88.1 
   sequence-number=0x80000006 age=32 checksum=0x3F67 options="E" 
   body=
     flags=EXTERNAL
         link-type=Transit id=10.255.0.2 data=10.255.0.1 metric=10

 instance=R2 area=R2 type=router id=192.168.89.1 originator=192.168.89.1 
   sequence-number=0x80000002 age=953 checksum=0x3D6C options="E" body=
     flags=
         link-type=Transit id=10.255.0.2 data=10.255.0.2 metric=10

 instance=R2 area=R2 type=router id=255.255.255.255 
   originator=255.255.255.255 sequence-number=0x80000003 age=951 
   checksum=0xB76E options="E" body=
     flags=EXTERNAL
         link-type=Transit id=10.255.0.6 data=10.255.0.6 metric=10

 instance=R2 area=R2 type=network id=10.255.0.2 originator=192.168.89.1 
   sequence-number=0x80000001 age=953 checksum=0xC83E options="E" 
   body=
     netmask=255.255.255.252
         routerId=192.168.89.1
         routerId=192.168.88.1

 instance=R2 area=R2 type=network id=10.255.0.6 originator=255.255.255.255 
   sequence-number=0x80000001 age=951 checksum=0x6B1F options="E" 
   body=
     netmask=255.255.255.252
         routerId=255.255.255.255
         routerId=192.168.88.1

 instance=R2 area=external type=as-external id=0.0.0.0 
   originator=192.168.88.1 sequence-number=0x80000001 age=963 checksum=0x6771 
   options="E" body=
     netmask=0.0.0.0
     forwarding-address=0.0.0.0
     metric=10000
     route-tag=0x0
     type2

 instance=R2 area=external type=as-external id=0.0.0.0 
   originator=255.255.255.255 sequence-number=0x80000001 age=993 
   checksum=0x69E8 options="E" body=
     netmask=0.0.0.0
     forwarding-address=0.0.0.0
     metric=1
     route-tag=0x0
     type1

 instance=R2 area=external type=as-external id=192.168.0.0 
   originator=255.255.255.255 sequence-number=0x80000001 age=993 
   checksum=0x765F options="E" body=
     netmask=255.255.255.0
     forwarding-address=0.0.0.0
     metric=20
     route-tag=0x0
     type1

 instance=R2 area=external type=as-external id=192.168.1.0 
   originator=192.168.88.1 sequence-number=0x80000001 age=1003 
   checksum=0xEE23 options="E" body=
     netmask=255.255.255.0
     forwarding-address=0.0.0.0
     metric=20
     route-tag=0x0
     type1
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 11:40 am

Hello.

Is it possible to "overwrite" locally inserted default-gateway with the one got via ospf ?

I mean if I have 2 mikrotiks with ospf running and both boxes have different default-gateways. I want all the traffic go through only one of them until it goes down.

RGDS

On R2, set the distance to 200 on your static default gateway.
(double check this - note the distance on other routes learned by OSPF, and make sure that your backup default GW statement is a higher number than that distance)

You don't need scripts, etc.
The problem is the metric for your static default gateway.
By default, static routes are "better" than dynamic routes.

DLNoah's solution is correct. One thing I would add is to make sure that your test pings from R1 cannot successfully go out R2, and cause R1 to think it is still connected to the Internet. Your connection will flap up and down while the connection on R1 is broken. (Filter them on R2, or make /32 route on R1 forcing ISP1)


Another thing you can do in your design (if you have other routers R3, R4, R5, etc) is to make R2 generate default information with a "worse" metric than R1 so that in case both routers are announcing default routes into your network, the network will prefer the ones from R1. Remember: OSPF chooses Type 1 external routes before Type 2 no matter what the metrics are.
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 12:14 pm

On R2, set the distance to 200 on your static default gateway.
(double check this - note the distance on other routes learned by OSPF, and make sure that your backup default GW statement is a higher number than that distance)
No help anyway.
[admin@R2] > ip rou pr
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 A S  0.0.0.0/0                          192.168.1.1             200
 1 ADC  10.255.0.0/30      10.255.0.1      ether7-R3                 0
 2  DC  10.255.0.4/30      10.255.0.5      ether6-R1               255
 3 ADC  192.168.1.0/24     192.168.1.23    ether5-OUT2               0
 4  DC  192.168.88.0/24    192.168.88.1    ether8                  255
[admin@R2] >
DLNoah's solution is correct. One thing I would add is to make sure that your test pings from R1 cannot successfully go out R2, and cause R1 to think it is still connected to the Internet. Your connection will flap up and down while the connection on R1 is broken. (Filter them on R2, or make /32 route on R1 forcing ISP1)
Both boxes are on the table connected with 1 m cable only. So pings are going without any problems.
Another thing you can do in your design (if you have other routers R3, R4, R5, etc) is to make R2 generate default information with a "worse" metric than R1 so that in case both routers are announcing default routes into your network, the network will prefer the ones from R1. Remember: OSPF chooses Type 1 external routes before Type 2 no matter what the metrics are.
I know that. But the goal is to force R2 to mandatory use R1 as a default gw while R1 has default gw installed.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 12:55 pm

I know that. But the goal is to force R2 to mandatory use R1 as a default gw while R1 has default gw installed.
That part was an "extra" - how to get purely ospf routers to decide automatically....

Anyway, I just thought of something that might be the problem with this:
Scope.
(Route scope is something that hasn't just clicked in my head yet, but I'm trying)

Static routes go into scope 10, and igp protocols like OSPF work in scope 20.
I wonder if you made the floating backup static route use scope 20, if that would fix the problem....
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 12:59 pm

I know that. But the goal is to force R2 to mandatory use R1 as a default gw while R1 has default gw installed.
That part was an "extra" - how to get purely ospf routers to decide automatically....

Anyway, I just thought of something that might be the problem with this:
Scope.
(Route scope is something that hasn't just clicked in my head yet, but I'm trying)

Static routes go into scope 10, and igp protocols like OSPF work in scope 20.
I wonder if you made the floating backup static route use scope 20, if that would fix the problem....
You loose!
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 A S  dst-address=0.0.0.0/0 gateway=192.168.1.1 
        gateway-status=192.168.1.1 reachable via  ether5-OUT2 
        check-gateway=ping distance=200 scope=20 target-scope=20 

 1 ADC  dst-address=10.255.0.0/30 pref-src=10.255.0.1 gateway=ether7-
        gateway-status=ether7-R3 reachable distance=0 scope=10 

 2  DC  dst-address=10.255.0.4/30 pref-src=10.255.0.5 gateway=ether6-
        gateway-status=ether6-R1 unreachable distance=255 scope=10 

 3 ADC  dst-address=192.168.1.0/24 pref-src=192.168.1.23 gateway=ethe
        gateway-status=ether5-OUT2 reachable distance=0 scope=10 

 4  DC  dst-address=192.168.88.0/24 pref-src=192.168.88.1 gateway=eth
        gateway-status=ether8 unreachable distance=255 scope=10 
[admin@R2] > 
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 1:09 pm

Rats! I was sure that was it. :?

If you disable the static to get the OSPF route, what scope does it get?
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 1:14 pm

Rats! I was sure that was it. :?

If you disable the static to get the OSPF route, what scope does it get?
[admin@R2] > ip rou pr de
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=10.255.0.6 
        gateway-status=10.255.0.6 reachable via  ether6-R1 distance=110 
        scope=20 target-scope=10 ospf-metric=11 ospf-type=external-type-1 

 1   S  dst-address=0.0.0.0/0 gateway=192.168.1.1 
        gateway-status=192.168.1.1 reachable via  ether5-OUT2 
        check-gateway=ping distance=200 scope=20 target-scope=20 

 2  DC  dst-address=10.255.0.0/30 pref-src=10.255.0.1 gateway=ether7-R3 
        gateway-status=ether7-R3 unreachable distance=255 scope=10 

 3 ADC  dst-address=10.255.0.4/30 pref-src=10.255.0.5 gateway=ether6-R1 
        gateway-status=ether6-R1 reachable distance=0 scope=10 

 4 ADo  dst-address=192.168.0.0/24 gateway=10.255.0.6 
        gateway-status=10.255.0.6 reachable via  ether6-R1 distance=110 
        scope=20 target-scope=10 ospf-metric=30 ospf-type=external-type-1 

 5 ADC  dst-address=192.168.1.0/24 pref-src=192.168.1.23 gateway=ether5-OUT2 
        gateway-status=ether5-OUT2 reachable distance=0 scope=10 

 6  DC  dst-address=192.168.88.0/24 pref-src=192.168.88.1 gateway=ether8 
        gateway-status=ether8 unreachable distance=255 scope=10 

[admin@R2] > 
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 1:35 pm

This is one thing about Mikrotik that frustrates me - some things that "just work" in other platforms either do not work, or require some strange configuration in Mikrotik.

Don't get me wrong, I love the platform, but sometimes I just end up pulling my hair.
When I get to my office later this morning, I'm going to try some experimentation on this matter.
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 1:38 pm

This is one thing about Mikrotik that frustrates me - some things that "just work" in other platforms either do not work, or require some strange configuration in Mikrotik.

Don't get me wrong, I love the platform, but sometimes I just end up pulling my hair.
When I get to my office later this morning, I'm going to try some experimentation on this matter.
I can send you mk configs if you wish to.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 2:18 pm

I can send you mk configs if you wish to.
If I get different results than you do, I'll have a look at you configs.
I'm running v6.27 as well, so results should be similar.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 5:28 pm

It worked for me, right away.

My Topology:
Drawing1.png
Here are my full /export compact configurations.
To save space, I removed some meaningless configs having to do with the /system lcd section.
Other than that, these are the entire configurations:
[admin@R1] > export compact
# mar/05/2015 14:57:18 by RouterOS 6.27
# software id = xxxx-yyyy
#
/interface bridge
add name=bridge1
/port
set 0 name=serial0
/routing ospf instance
set [ find default=yes ] distribute-default=if-installed-as-type-2
/ip address
add address=1.1.1.1/32 interface=bridge1 network=1.1.1.1
add address=10.1.2.1/24 interface=ether1 network=10.1.2.0
add address=1.0.0.1/24 interface=ether5 network=1.0.0.0
add address=192.168.0.2/24 interface=ether2 network=192.168.0.0
/ip route
add distance=1 gateway=192.168.0.1
/routing ospf network
add area=backbone network=1.0.0.0/8
add area=backbone network=10.0.0.0/8
/system identity
set name=R1


[admin@R2] > export compact
# mar/05/2015 14:57:40 by RouterOS 6.27
# software id = xxxx-yyyy
#
/interface bridge
add name=bridge1
/port
set 0 name=serial0
/ip address
add address=2.2.2.2/32 interface=bridge1 network=2.2.2.2
add address=10.1.2.2/24 interface=ether1 network=10.1.2.0
add address=192.168.1.2/24 interface=ether2 network=192.168.1.0
add address=2.0.0.1/24 interface=ether5 network=2.0.0.0
/ip route
add distance=200 gateway=192.168.1.1
/routing ospf network
add area=backbone network=2.0.0.0/8
add area=backbone network=10.0.0.0/8
/system identity
set name=R2



Here is the route table on R2 when R1 has its default GW enabled:
[admin@R2] /ip route> print where dst-address=0.0.0.0/0
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 ADo  0.0.0.0/0                          10.1.2.1                110
 1   S  0.0.0.0/0                          192.168.1.1             200
Here is R2 when I set the static default GW disabled on R1:
[admin@R1] /ip route> print where dst-address=0.0.0.0/0
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 A S  0.0.0.0/0                          192.168.0.1               1
[admin@R1] /ip route> disable 0

[admin@R2] /ip route> print where dst-address=0.0.0.0/0
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 A S  0.0.0.0/0                          192.168.1.1             200
When I re-activate on R1, R2 reverts to the first version above.
It also works when the default information from R1 is type-1. (in stead of type 2)
You do not have the required permissions to view the files attached to this post.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 6:25 pm

OK - I figured out what's happening, but not how to fix it. (yet)

I got the problem when I added a 3rd router, and set R2 to conditionally originate default-gw information.

If OSPF is advertising default GW, then it ignores other default GW prefixes in OSPF
(I'm going to compare this with Cisco's behavior)
If OSPF is configured to conditionally originate default-information, then the default route must come from other protocol (bgp, rip, static route, etc)

See the problem? When R2 advertises default, it ignores LSA from R1 when R1 regains internet connection, even though this new route is better than the existing static route. I'm 100% sure that Cisco will notice that new default route LSA is better than static route, and will override the static, and then stop its own advertisement for default GW.

Your work-around would be to remove the default-origination on R2, and to put floating static backup default GW on R1.
You can just put a static default GW on R3 because it only has one way to go.


EDIT: Confirmed. Cisco router will accept the new default route from OSPF and then withdraw its own LSA for default route. This is even true when R1 uses type 2 and R2 uses type 1.

Basically, it looks like in Mikrotik, OSPF does not compare default-route LSAs against the RIB at all, whereas it should compare non-local default LSAs.
Last edited by ZeroByte on Thu Mar 05, 2015 6:40 pm, edited 1 time in total.
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 6:38 pm


Your work-around would be to remove the default-origination on R2, and to put floating static backup default GW on R1.
You can just put a static default GW on R3 because it only has one way to go.
That's not an option :( IRL it`ll be more then one R3. And topology is complex.

Do you know how to write a simple script that will see is there is .0.0.0.0 LSA originated NOT from itself preset and disables static default-gw ?
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 7:05 pm

That's not an option :( IRL it`ll be more then one R3. And topology is complex.

Do you know how to write a simple script that will see is there is .0.0.0.0 LSA originated NOT from itself preset and disables static default-gw ?
Well, since I'm not a developer for routing protocols, there might be some case I'm not thinking of, but it seems that it might be more complicated than just "non-local LSA for default GW" . . .

However, if your can say this about R2: "It will only use its static default GW if there is not any OSPF default gateway at all ; if there is even one such route in OSPF, no matter who originates it, then use OSPF and not static." then it should be safe to use that logic.

I recommend hard-coding the router ID for R2 so that you can guarantee it will always be the same for your script. (The ID doesn't even need to be a reachable IP address on the router - it's just a label) - e.g. 2.2.2.2

Script logic would be (pseudocode)
If (/routing ospf lsa find where id=0.0.0.0 and originator != 2.2.2.2) > 0
and (/ip route find where dst-address=0.0.0.0/0 and ospf) = 0
  then
    /ip route disable where dst-address=0.0.0.0/0 and static
    sleep 1
   /ip route enable where dst-address=0.0.0.0/0 and static
end if
If that runs every minute, then you would have automatic normalization.
(God, I hate things like this - it seems such a kludge)
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 8:08 pm

Can you also open case by mikrotik support ?
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Thu Mar 05, 2015 8:37 pm

Can you also open case by mikrotik support ?
I suppose I can. (I've been playing with using iBGP but found that OSPF won't override that either)

I wonder if Quaga or Zebra have the same behavior.....

(in other words, is this a Lunux thing or a Mikrotik thing?)
 
Dmitri
Frequent Visitor
Frequent Visitor
Topic Author
Posts: 51
Joined: Tue Feb 25, 2014 11:54 am

Re: OSPF overwrite static default-gateway. Possible ?

Fri Mar 13, 2015 2:55 pm

I managed to write simple script to check if there is a static default-gw active and if lsa with id 0.0.0.0 from R1 (id 255.255.255.255) present it will disable and enable static default-gw.

If guru`s know better way to do this - welcome!
:foreach i in=[/ip route find where active=yes static=yes and dst-address="0.0.0.0/0"] do={
	:foreach j in=[/routing ospf lsa find where id=0.0.0.0 and originator=255.255.255.255 ] do={
		ip route dis $i;
		:delay 2
		ip route enable $i;
	}
}
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Fri Mar 13, 2015 3:39 pm

I managed to write simple script to check if there is a static default-gw active and if lsa with id 0.0.0.0 from R1 (id 255.255.255.255) present it will disable and enable static default-gw.

If guru`s know better way to do this - welcome!
:foreach i in=[/ip route find where active=yes static=yes and dst-address="0.0.0.0/0"] do={
	:foreach j in=[/routing ospf lsa find where id=0.0.0.0 and originator=255.255.255.255 ] do={
		ip route dis $i;
		:delay 2
		ip route enable $i;
	}
}
I'm definitely not a script guru, but I think that's a clever use of :foreach. :)
Sad that a script has to suffice for now.


Oh - and support replied that this will be fixed in ROS v7.
We shall see. . . . .
 
pmurdock
newbie
Posts: 43
Joined: Sun Jul 03, 2005 7:39 am
Location: Herriman, Utah
Contact:

Re: OSPF overwrite static default-gateway. Possible ?

Thu Jul 12, 2018 7:47 pm

I can confirm this script works a treat.. I can't believe we're here 3 years later with no other viable resolution to the core problem.
 
User avatar
ZeroByte
Forum Guru
Forum Guru
Posts: 4047
Joined: Wed May 11, 2011 6:08 pm

Re: OSPF overwrite static default-gateway. Possible ?

Mon Jul 16, 2018 5:46 pm

I can confirm this script works a treat.. I can't believe we're here 3 years later with no other viable resolution to the core problem.
This is why our core network is still 100% Cisco routers. We use Mikrotik as CPE routers, but given their 'quirky' behavior in dynamic routing protocols, I don't want to use them in the core production network, especially as BGP border routers.

Who is online

Users browsing this forum: No registered users and 8 guests