VRF WAN 1 to LTE Failover Not Working

I have a VRF where WAN 1 is the primary connection and LTE is the backup.

I need both connections to be in the VRF. The issue is that the gateway check does not seem to work correctly in this setup.

When WAN 1 goes down, the router does not automatically switch to LTE. I have to manually change the route.

I know the same setup works fine in the main routing table, but it does not work properly when the routes are in a VRF.

[CPE1] > interface/ethernet/pr
;;; LAN
0 R ether1 1500 enabled switch1
;;; WAN-1
2 ether3 1500 enabled switch1

[CPE01] > ip route/pr de where routing-table=vrf1
0 s dst-address=0.0.0.0/0 routing-table=vrf1 gateway=1.1.1.1 immediate-gw=1.1.1.1%lte1 check-gateway=ping distance=2 scope=30 target-scope=46

1 As dst-address=0.0.0.0/0 routing-table=vrf1 gateway=8.8.8.8 immediate-gw=8.8.8.8%lte1 check-gateway=ping distance=20 scope=30 target-scope=41

2 As dst-address=1.1.1.1/32 routing-table=vrf1 gateway=lte1 immediate-gw=lte1 distance=1 scope=30 target-scope=10

3 Is dst-address=8.8.8.8/32 routing-table=vrf1 gateway=1.2.3.4 immediate-gw="" distance=1 scope=30 target-scope=10

You have two issues:

You should also post the print output of the main routing table. My guess is that currently in the main table, you have some route that can be used for 8.8.8.8 that actively resolves to lte1 as gateway. Even when that route has a high scope (default is 30), it will be picked up by this route entry:

for looking up the gateway 8.8.8.8, because you did not specify 8.8.8.8@vrf1, and because target-scope=41. As a result, you can see immediate-gw=8.8.8.8%lte1 attached to that route.

[CPE01] > ip route/pr detail where dst-address=0.0.0.0/0
DAm dst-address=0.0.0.0/0 routing-table=main gateway=lte1 immediate-gw=lte1
distance=2 scope=30 target-scope=10

The main WAN interface is currently down, and everything has been switched over to LTE.

if i add @vrf1 see what im getting:

ip route/pr de where routing-table=vrf1

NS-CPE01] > ip route/pr de where routing-table=vrf1

0 Is dst-address=0.0.0.0/0 routing-table=vrf1 gateway=1.1.1.1@vrf1 immediate-gw="" check-gateway=ping distance=20 scope=30 target-scope=31

1 Is dst-address=0.0.0.0/0 routing-table=vrf1 gateway=8.8.8.8@vrf1 immediate-gw="" check-gateway=ping distance=10 scope=30 target-scope=32

5 Is dst-address=1.1.1.1/32 routing-table=vrf1 gateway=lte1@vrf1 immediate-gw="" distance=1 scope=30 target-scope=10

6 Is dst-address=8.8.8.8/32 routing-table=vrfSTP gateway=1.2.3.4@vrf1 immediate-gw="" distance=1 scope=30 target-scope=10

In my case, I don't need to specify @vrf1, as LTE is not in the VRF table. I just need to add @main.

The problem is that if I specify check-gateway=ping, the route becomes inactive after about 20 seconds. If I set check-gateway=none, it works fine.

note: onl LTE is runnign , WAN1 main is down atm

I think this is only happening with LTE. I’m pretty sure the WAN was working fine, as I have several setups where this works without any issues. Something seems to be related to the LTE, but I can’t figure out what the issue is.

Yes, lte1 doesn't have a gateway IP address.

Regarding the target-scope, yes, I completely missed that. I’ve now implemented it as well.

MikroTik need to severely improves its example of use of VRFs.

  • Since a the example of home device running in VRF.
  • Passing to a Simple scenario of default main + VRF for failover. (Like this topic).
  • Until scenarios with usage of multidevice Layer3 with "VRF_Management".

I think the key issue is specifically with LTE, where there is no gateway IP. It works fine when check-gateway=none is specified.

When there is a gateway IP that you can specify, check-gateway=ping works fine. I have many setups where this works without any issues.

@CGGXANNX

does that look ok to you:

ip route/pr detail where routing-table=vrf1
Flags: A - ACTIVE; s - STATIC
0 As dst-address=0.0.0.0/0 routing-table=vrf1 gateway=8.8.8.8 immediate-gw=10.0.1.1%e3vl99 distance=1 scope=10 target-scope=30

1 As dst-address=8.8.8.8/32 routing-table=vrf1 gateway=10.0.1.1 immediate-gw=10.0.1.1%e3vl99 distance=1 scope=10 target-scope=11strong text

Hi @nichky.

About scope and target-scope:

  • The 2nd route with dst-address=8.8.8.8/32 should have the default target-scope=10, which then will cause scope to be at least 11. scope must be greater than target-scope, internally, RouterOS will fix that for you so even if you write scope=5 it will silently increase it to 11, which is one more than the value of target-scope=10.

    But it's better if you know about this and explicitly set scope=11 on this route. We choose 11 because it's the strict minimum possible if you've already set target-scope=10.

    So, for this 2nd route it's better (and more correct) to set scope=11 target-scope=10. What you currently wrote:

    Actually means scope=12 target-scope=11, not what you wrote.

  • As for the route with dst-address=0.0.0.0/0, you should give it the default value of scope=30. As for target-scope, if you want to use the 2nd route (the dst-address=8.8.8.8/32 one) to look up the gateway, then target-scope must be at least 11 (which is the real scope value of the 2nd route). This target-scope=11 also satisfy the condition that it is smaller than scope (which we set to 30).

    Of course, you can also pick any value >=11 for target-scope for this route, but we should keep the value as small as possible. If you specify target-scope=30 for example, then the gateway look up might be performed using some other routes, for example one that has dst-address=0.0.0.0/0 scope=30.

    So, for this dst-address=0.0.0.0/0 route, specify scope=30 target-scope=11.

However, as I wrote above, we are in the routing-table=vrf1, but if you wrote

Then the lookup for the nexthop for the gateway will not use the 2nd route! It will instead look up in the main table (will use the best active route in main that can satisfy the destination 8.8.8.8 and has scope small enough). The 2nd route you posted will not be consulted. If you are fine with that then remove that 2nd useless route. If you however really want to force the nexthop lookup to use that 2nd route, then the first route must have gateway=8.8.8.8@vrf1!

My guess for why you currently have target-scope=30 on that 1st route: The best route in main that can resolve 8.8.8.8 is probably some dst-address=0.0.0.0/0 scope=30 route, that's why this route can only work if you put target-scope=30 and not with lower value.

If you correct it to gateway=8.8.8.8@vrf1, then the lookup can use the second route, and you can use target-scope=11 without issue.

Just in case:
Simple recursive failover for bears of little brain