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 ?
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 ?
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
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