Failover between 2 wan's

I have the following setup:
Lan(>openWrt router ----> Wan1( -->ISP internet
_____________ _______________----> Wan2( hotspot) -->4G internet
static routes: 10 20

it works ok untill default gateway of 4g hotspot(dhcp client) ip changes,
then of course this static route to Wan2 breaks.

I can not use mwan3 since of router disk limitations.

Is there any creative dynamic way to find the new default gateway ip address of Wan2(4g hotspot dhcp client) and change the default static route for Wan2 with the new ip default gateway ?

Detect the downed link, do a network restart?

thanks for your reply
but that will not update wan2 default route

Why do you create a static route if the interface is configured via DHCP?
Just set the interface metric and everything should be done automatically.

config interface 'wan2'
        option proto 'dhcp'
        option metric '20'

so, with your suggestion i will need to remove the static default route to Wan2 - 20
and set the option metric '20' on the interface and it will allow the lan traffic to use wan2 default route
in case wan1 link is down ?


By setting `option metric' the second default gateway will be automatically set in the routing table with the corresponding metric. It will be also automatically updated if the DHCP settings change.

nop sorry,
i have tested it-
i setup option metric '20' for wan2 interface and reload
remove static default route to wan2
stop wan1
and traffic now not passing to internet via wan2

Post the output of ip -4 route


Mwan3 isn't big.
Do yourself a favour and spend ~$35 on a new 16/128 router.

default via dev wlan1 src
default via dev wlan2 src metric 20 dev wlan1 scope link src dev br-lan scope link src dev wlan2 scope link metric 20

this looks so far possibole solution for my setup-

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.