I've been looking for a simple and elegant solution to switch between the wan uplink and the 3g modem when the default pppoe-wan disconnects. I know there are some OpenWRT tutorials and solutions, I read them, found them complicated and considered using crond with a simple script to do the failover. Worth mentioning that I'd like to achieve this on both OpenWRT 18.x & 19.x
The ppoe-wan is the default interface, enabled on boot, whereas the 3G interfaced is disabled (Bring up on boot - in LuCI unchecked, otherwise it will connect automatically and register as default interface - default wan route).
I learned that the following checks are unreliable:
# cat /sys/class/net/pppoe-wan/operstate unknown
And that pppoe-wan is somehow "hidden" inside the wan interface:
#ubus list network.interface.* network.interface.lan network.interface.loopback network.interface.wan network.interface.wifi
That's for the OpenWRT system. As for the kernel, all interfaces are listed and available in /proc/net/dev
I created the following script (I'm about to run every minute or so as a cron job):
#!/bin/sh PPPOE=`/bin/grep "pppoe-wan" /proc/net/dev` 3G-UMTS=`/bin/grep "3g-UMTS" /proc/net/dev` if [ -n "$PPPOE" ] ; then if [ -n "$3G-UMTS" ] ; then /sbin/ifdown 3g-UMTS /usr/bin/logger -t FAILOVER PPPoE up - disabling 3G uplink fi else if [ -c "/dev/ttyUSB2" ] ; then /sbin/ifup 3g-UMTS /usr/bin/logger -t FAILOVER PPPoE down - enabling 3G uplink fi fi unset PPPOE unset 3G-UMTS
And learned that I cannot use ifup/ifdown to control the ppoe-wan & 3g-UMTS interfaces.
This guide wasn't really helpful:
I'm stuck now, not knowing how to bring up / down the 3g Interface when needed.
I'll be thankful if someone more "UCI-minded" could provide me some UCI commands (sequences) for activating / deactivating the 3g-UMTS interface when needed, so that I could use them inside my script, substituting the nonfunctional ifup/ifdown.
Thanks in advance.
P.S. I'm only looking for this solution, please don't bother to suggest other alternatives like multi-wan & mwan3 & all the complex stuff I already read in the OpenWRT doc sections. Thank you, but no thank you (don't have time for that stuff).