Failover between 2 wan's

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

it works ok untill default gateway of 4g hotspot(dhcp client) ip 194.1.1.1 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'
	    ...

intresting,
so, with your suggestion i will need to remove the static default route to Wan2 - 0.0.0.0 194.1.1.1 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 ?

Thanks

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

DHCP

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

default via 192.168.1.1 dev wlan1 src 192.168.1.2
default via 194.1.1.1 dev wlan2 src 194.1.1.10 metric 20
192.168.1.0/24 dev wlan1 scope link src 192.168.1.2
192.168.2.0/24 dev br-lan scope link src 192.168.2.1
194.1.1.0/24 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.