I have searched these forums high and low, and cannot find anybody discussing the same (or similar) issue.
Here is the scenario:
Customer has 2 ISPs. One ISP provides 2 gateways – both exposed to the customer on the same L2 and within the same subnet – and uses BGP with private ASN for failover (only default route is announced by the provider). The other ISP just uses straight IPoE, static address, no BGP or other routing protocol or tunneling. As a result, there are 3 default routes in the RIB: 2 from the same BGP instance, and one static route. The first ISP is the preferred default and the second is just as a backup if the first is completely down, so the static default route is configured with a higher distance than the BGP-added routes.
This works fine at first:
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 ADb 0.0.0.0/0 192.168.111.3 192.168.111.1 20
1 S 0.0.0.0/0 192.168.254.254 25
2 Db 0.0.0.0/0 192.168.111.3 192.168.111.2 20
…up until the BGP session that the current active default was learned from dies. At that point, I would expect the second BGP default route to be chosen as active, since it has a lower distance. However, this is not what happens:
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 A S 0.0.0.0/0 192.168.254.254 25
1 Db 0.0.0.0/0 192.168.111.3 192.168.111.2 20
The static route with higher distance is selected as the active one, even though the gateway for the BGP route is seen to be “reachable”. If I enable verbose logs, RouterOS tells me that it selected this route, but does not explain why:
21:44:23 route,debug,calc Begin calculation
21:44:23 route,debug,calc Select route
21:44:23 route,debug,calc dst-address=0.0.0.0/0
21:44:23 route,debug,calc attributes
21:44:23 route,debug,calc protocol=STATIC
21:44:23 route,debug,calc distance=25
21:44:23 route,debug,calc scope=30
21:44:23 route,debug,calc target-scope=10
21:44:23 route,debug,calc next-hop= address=192.168.254.254
21:44:23 route,debug,calc comment=
21:44:23 route,debug,calc origin-type=STATIC
21:44:23 route,debug,calc End calculation
However! If I disable the static route, the remaining BGP route is selected (as one would expect), and when I re-enable the static route, the remaining BGP route remains the active route! OR if I disable and re-enable the remaining BGP session while the static route is active, when BGP re-adds the default route to the table, it instantly is chosen as the active one:
02:39:36 route,debug,calc Begin calculation
02:39:36 route,debug,event Added candidate route
02:39:36 route,debug,event dst-prefix=0.0.0.0/0
02:39:36 route,debug,event attributes
02:39:36 route,debug,event protocol=BGP
02:39:36 route,debug,event scope=40
02:39:36 route,debug,event preferred-source=192.168.111.3
02:39:36 route,debug,event next-hop= address=192.168.111.2
02:39:36 route,debug,event origin-type=BGP
02:39:36 route,debug,event origin-instance-id=0
02:39:36 route,debug,event bgp-peer-router-id=172.26.255.1
02:39:36 route,debug,event bgp-peer-flags=0
02:39:36 route,debug,event bgp-router-id=172.26.255.2
02:39:36 route,debug,event bgp-origin=INCOMPLETE
02:39:36 route,debug,event bgp-as-path=64999
02:39:36 route,debug,event bgp-as-path-len=1
02:39:36 route,debug,event bgp-nexthop=192.168.111.2
02:39:36 route,debug,event bgp-localpref=90
02:39:36 route,debug,event use-te-nexthop=yes
02:39:36 route,debug,calc Select route
02:39:36 route,debug,calc dst-address=0.0.0.0/0
02:39:36 route,debug,calc attributes
02:39:36 route,debug,calc protocol=BGP
02:39:36 route,debug,calc scope=40
02:39:36 route,debug,calc preferred-source=192.168.111.3
02:39:36 route,debug,calc next-hop= address=192.168.111.2
02:39:36 route,debug,calc origin-type=BGP
02:39:36 route,debug,calc origin-instance-id=0
02:39:36 route,debug,calc bgp-peer-router-id=172.26.255.1
02:39:36 route,debug,calc bgp-peer-flags=0
02:39:36 route,debug,calc bgp-router-id=172.26.255.2
02:39:36 route,debug,calc bgp-origin=INCOMPLETE
02:39:36 route,debug,calc bgp-as-path=64999
02:39:36 route,debug,calc bgp-as-path-len=1
02:39:36 route,debug,calc bgp-nexthop=192.168.111.2
02:39:36 route,debug,calc bgp-localpref=90
02:39:36 route,debug,calc use-te-nexthop=yes
02:39:36 route,debug,calc End calculation
# DST-ADDRESS PREF-SRC GATEWAY DISTANCE
0 ADb 0.0.0.0/0 192.168.111.3 192.168.111.2 20
1 S 0.0.0.0/0 192.168.254.254 25
I have also reproduced this problem with prefixes other than 0.0.0.0/0. It happens in any situation where you have 2 BGP routes and 1 static route for the same prefix, where the static route has a higher distance, and the active BGP route is removed from the table.
Do I smell a bug here? Or am I missing something obvious? This is RouterOS 6.34.6 on a CCR.
Thanks,
– Nathan