iBGP default route based on OSPF metrics

Surprisingly I did not get a response to what I thought was a simple question.

I’ll ask again, based on what I want to achieve: I have 4 Point-to-Point links over which 2 iBGP sessions should be established to provide redundant default routes.

The 4 PtP links are wireguard links and connect to two hosts over 2 redundant links (FTTH and WWAN): host1/ftth, host2/ftth, host1/wwan, host2/ftth. The IP addresses of the two iBGP peers (172.20.215.129 and 172.20.215.130) are distributed via OSPF. I believe this is a common setup.

Now with OSPF, I have assigned cost 100 to the FTTH link and 190 to the WWAN link. That means if both of them are up, FTTH will always be preferred over WWAN. So, OSPF takes care that in my FIB that there is only one route to each iBGP peer:

[admin@SunGate2] /ip/route> /ip/route/print detail where dst-address~"172.20.215"
Flags: D - dynamic; X - disabled, I - inactive, A - active; 
c - connect, s - static, r - rip, b - bgp, o - ospf, i - is-is, d - dhcp, v - vpn, m - modem, y - bgp-mpls-vpn; H - hw-offloaded; + - ecmp 

   DAo   dst-address=172.20.215.129/32 routing-table=main gateway=192.0.2.185%wg-bg1-ftth immediate-gw=192.0.2.185%wg-bg1-ftth distance=110 
         scope=20 target-scope=10 suppress-hw-offload=no 

   DAo   dst-address=172.20.215.130/32 routing-table=main gateway=192.0.2.176%wg-bg2-wwan immediate-gw=192.0.2.176%wg-bg2-wwan distance=110 
         scope=20 target-scope=10 suppress-hw-offload=no 

[admin@SunGate2] /ip/route>

In this example, 172.20.215.129 goes over FTTH and 172.20.215.130 goes over WWAN. However, this is not reflected in “distance” (even though OSPF metric is 100 and 190, respectively). Now both peers provide their default routes:

[admin@SunGate2] /ip/route> /ip/route/print detail where dst-address~"0.0.0.0"          
Flags: D - dynamic; X - disabled, I - inactive, A - active; 
c - connect, s - static, r - rip, b - bgp, o - ospf, i - is-is, d - dhcp, v - vpn, m - modem, y - bgp-mpls-vpn; H - hw-offloaded; + - ecmp 

   D b   dst-address=0.0.0.0/0 routing-table=default_myas gateway=172.20.215.129 immediate-gw=192.0.2.185%wg-bg1-ftth distance=200 scope=40 
         target-scope=30 suppress-hw-offload=no 

   DAb   dst-address=0.0.0.0/0 routing-table=default_myas gateway=172.20.215.130 immediate-gw=192.0.2.176%wg-bg2-wwan distance=200 scope=40 
         target-scope=30 suppress-hw-offload=no 

[admin@SunGate2] /ip/route>

But it can be seen that the active default route is via WWAN to 172.20.215.130. However, if multiple options are available, I would always like to prefer the one that goes over FTTH.

In fact, my preference is that if both WWAN and FTTH links are available, FTTH should always be preferred. Between 172.20.215.129 and 172.20.215.130, the latter should always be preferred.



How can I accomplish this?

I feel that if the OSPF metric would be reflected in FIB’s distance, that would be done automatically … because then the distance to 172.20.215.130 would be larger and the default route would automatically be selected via 172.20.215.129. For strangely that’s not the case.

Please do not start new topic in such a situation but stay with just one and “bump it”. It would be better for readers.