DHCP WAN with with USB LTE - Failover

Good day,

my current setup is as follows:

Technicolor CGA2121 (bridge mode with CGNAT) —> hap ax^3 (eth1 with DHCP client) - main connection
Alcatel IK41VE1 (LTE) —> hap ax^3 (USB port)

The main problem is that the LTE interface automatically adds a dynamic DHCP Client with a unchangeable route distance (value: 2)
I’ve of course read the manual (https://help.mikrotik.com/docs/pages/viewpage.action?pageId=26476608) but I don’t think this applies here.
Currently I have this working but I think my solution is a bit clunky :stuck_out_tongue:

I’ve created a route with a pref Source (100.95.0.0):

#     DST-ADDRESS        GATEWAY      DISTANCE
;;; wan-failover
0  As 208.67.222.123/32  100.95.0.1          1

and a Netwatch script which pings 208.67.222.123 every 20 seconds and changes the route distance of the primary WAN interface to 3 if it’s unreachable:

:local primaryWanInterface wan-play
/ip dhcp-client set [find interface=$primaryWanInterface] default-route-distance=3
:log warning "Activating backup LTE interface"
:delay 15
/tool e-mail send subject="some message" to="someemail@whatever.com" body="some message"

of course it does the opposite on “Up”

The main problem is that there’s a large delay when the failover occurs.
I’m not an expert with routing so the main question is: is there a more “elegant” way to make this work?

Thanks in advance.

Since its already at default distance of 2, it should work fine.
Simple set the MAIN ROute too

add check-gateway=ping dst-address=0.0.0.0/0 gateway=CGNATgatewayIP routing-table=main.

If CGNAT is not available it will failover over to distance=2 route but keeeps checking if WAN1 is up… and when it is will switch back.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++
If you want to make sure that the issue is the internet and not something in between the router and the internet you could do the following.

add check-gateway=ping dst-address= 0.0.0.0/0 gateway=1.1.1.1 routing table=main scope=10 target-scope=12
add dst-address=1.1.1.1 gateway=CGNATgatewayIP routing-table=main scope=10 target-scope=11

Wow, thank you - that was easy.
Can you please ELI5 how does this exactly work without touching the route distance? I’m guessing all the “magic” happens with target-scope?

Any default route or route created by the user defaults to distance=1.
Thus in the main table the router is always going to choose the manual route we created since all things being equal.

dst address is equal as both use dst-address=0.0.0.0/0
Routing table is the same table
Last item for differentiation is distance…

I do realize I’m pretty late to the party, but I think the information fits here. Although it is not really intuitive, if the LTE device behaves like an autonomous router and DHCP server (like e.g. the IK41VE1), the dynamically added DHCP server uses the use-peer-dns, add-default-route, and default-route-distance parameters of the default APN profile.

I only had a chance to test that on 6.48.6 so far, and there, you can assign a different APN profile to that kind of LTE interface, but such an assignment neither shows up in the configuration nor it makes the dhcp client inherit the a.m. parameters from that user-configured APN profile. However, you cannot remove that profile until you assign some other one to the interface.