What's new

WANFailover Dual WAN Failover Script

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Yea it is continuing to rebuild the rules with eth0 instead of new wan interface. Not sure if it is hard coded or if they use nvram get wan_ifname from NVRAM, my script does update that value, double check that when you switch to Secondary WAN
Hi,

Thank you very much for tip. The sollution was to edit the YazFi script.

[SOLVED]
The fix for this is to do replacecement of all IFACE_WAN occudences from YazFi script
Original value:
Bash:
IFACE_WAN="$(nvram get wan0_ifname)"

Value in order to make it works on Secondary WAN:
Bash:
IFACE_WAN="$(nvram get wan_ifname)"

Thank you,
amplatfus

PS: initial raised here [SOLVED v2] YazFi - no internet on secondary wan (eth8)
 
Hi,

Thank you very much for tip. The sollution was to edit the YazFi script.

[SOLVED]
The fix for this is to do replacecement of all IFACE_WAN occudences from YazFi script
Original value:
Bash:
IFACE_WAN="$(nvram get wan0_ifname)"

Value in order to make it works on Secondary WAN:
Bash:
IFACE_WAN="$(nvram get wan_ifname)"

Thank you,
amplatfus

PS: initial raised here [SOLVED v2] YazFi - no internet on secondary wan (eth8)
Yea I thought that was the case, glad you got it working!
 
I'm a noob, which adress do I have to enter here?
View attachment 41413
I know my pulbic WAN IP, but I don't know what's a WAN Target IP.
I figured out, the IP adress in the screenshot indicates my WAN Gateway.
Thanks!

Edit:
Added screenshot of overview:
View attachment 41414
You want to put a Target IP for pinging like 8.8.8.8 and then 8.8.4.4 for the second one.
 
You want to put a Target IP for pinging like 8.8.8.8 and then 8.8.4.4 for the second one.
Hi,
It is possible to choose 2 IP's for ping a sigle WAN? Something like: 8.8.8.8, 8.8.4.4?

Thanks,
amplatfus
 
Hi,
It is possible to choose 2 IP's for ping a sigle WAN? Something like: 8.8.8.8, 8.8.4.4?

Thanks,
amplatfus
It is possible to build it that way but 1 target per WAN is simple and easy and less complicated.
 
Script has been updated for v1.4.1. If you are running v1.3.7, you should be able to pass the following command to update.

Code:
/jffs/scripts/wan-failover.sh update

v1.4.1 Notes
- Email Notifications will generate if you have alerts configured under AiProtection > Alert Preferences.
- Redirected all logs to System Log, events will now show up under System Log tab in Web GUI as well as Monitor Mode.
- Monitor mode will now filter logs from System Log
- Log Cleanup Mode has been deprecated. This will now cleanup the Log Clean Mode cron job and delete the old proprietary log file.
- Corrected issue where Monitor Mode would still run in background after it has been exited out.
- Corrected description for Cron Job mode where argument was stated as "cronjob" instead of "cron"
- Replaced ScriptStatus function with file lock.
 
Last edited:
Hi,

I do not understand why, but in my case nvram get wan_ifname stopped to update from eth0 to eth8 while swapping to secondary WAN..

Could you please help to understand?
I saw that sometimes the nvram eth changes for eth_ifnames, other times changes for igmp_ifname, but not anymore for wan_ifname.

Thank you,
amplatfus
 
Last edited:
Hi,

I do not understand why, but in my case nvram get wan_ifname stopped to update from eth0 to etho8 while swapping to secondary WAN..

Could you please help to understand?
I saw that sometimes the nvram eth changes for eth_ifnames, other times changes for igmp_ifname, but not anymore for wan_ifname.

Thank you,
amplatfus
Send me the values you are getting for those settings in NVRAM.
 
Send me the values you are getting for those settings in NVRAM.
In my case yesterday evening I saw that wan_ifname is not changing any more. I discovered that the new changed is eth_ifnames (without any change on my side)
Today I saw that there is no change in eth_ifnames or wan_ifname. Now is about igmp_ifname that is changes.
Please find below the current situation for both states with changes only on igmp_ifname:
Note: nvser is an alias for searching nvram.

While on Primary WAN
Code:
/tmp/home/root#: nvser eth8
size: 78565 bytes (52507 left)
usb_modem_act_dev=eth8
usb_path1_act=eth8
wan1_gw_ifname=eth8
wan1_ifname=eth8

/tmp/home/root#: nvser eth0
size: 78565 bytes (52507 left)
eth_ifnames=eth0
igmp_ifname=eth0
wan0_gw_ifname=eth0
wan0_ifname=eth0
wan_ifname=eth0
wan_ifnames=eth0 usb

While on Secondary WAN
Code:
/tmp/home/root#: nvser eth0
size: 78416 bytes (52656 left)
eth_ifnames=eth0
wan0_gw_ifname=eth0
wan0_ifname=eth0
wan_ifname=eth0
wan_ifnames=eth0 usb

/tmp/home/root#: nvser eth8
size: 78416 bytes (52656 left)
igmp_ifname=eth8
usb_modem_act_dev=eth8
usb_path1_act=eth8
wan1_gw_ifname=eth8
wan1_ifname=eth8

Thank you!
amplatfus
 
Script has been updated for v1.4.1. If you are running v1.3.7, you should be able to pass the following command to update.

Code:
/jffs/scripts/wan-failover.sh update

v1.4.1 Notes
- Email Notifications will generate if you have alerts configured under AiProtection > Alert Preferences.
- Redirected all logs to System Log, events will now show up under System Log tab in Web GUI as well as Monitor Mode.
- Monitor mode will now filter logs from System Log
- Log Cleanup Mode has been deprecated. This will now cleanup the Log Clean Mode cron job and delete the old proprietary log file.
- Corrected issue where Monitor Mode would still run in background after it has been exited out.
- Corrected description for Cron Job mode where argument was stated as "cronjob" instead of "cron"
- Replaced ScriptStatus function with file lock.
This may possibly be just for my situation, I made a variable to only log packetloss above certain amount. Im on Starlink which always has packetloss, so syslog was flooded with reports
 
In my case yesterday evening I saw that wan_ifname is not changing any more. I discovered that the new changed is eth_ifnames (without any change on my side)
Today I saw that there is no change in eth_ifnames or wan_ifname. Now is about igmp_ifname that is changes.
Please find below the current situation for both states with changes only on igmp_ifname:
Note: nvser is an alias for searching nvram.

While on Primary WAN
Code:
/tmp/home/root#: nvser eth8
size: 78565 bytes (52507 left)
usb_modem_act_dev=eth8
usb_path1_act=eth8
wan1_gw_ifname=eth8
wan1_ifname=eth8

/tmp/home/root#: nvser eth0
size: 78565 bytes (52507 left)
eth_ifnames=eth0
igmp_ifname=eth0
wan0_gw_ifname=eth0
wan0_ifname=eth0
wan_ifname=eth0
wan_ifnames=eth0 usb

While on Secondary WAN
Code:
/tmp/home/root#: nvser eth0
size: 78416 bytes (52656 left)
eth_ifnames=eth0
wan0_gw_ifname=eth0
wan0_ifname=eth0
wan_ifname=eth0
wan_ifnames=eth0 usb

/tmp/home/root#: nvser eth8
size: 78416 bytes (52656 left)
igmp_ifname=eth8
usb_modem_act_dev=eth8
usb_path1_act=eth8
wan1_gw_ifname=eth8
wan1_ifname=eth8

Thank you!
amplatfus
My script uses wan1_ifname and wan0_ifname to update wan_ifname. Let me double check those settings and test on my end.
 
This may possibly be just for my situation, I made a variable to only log packetloss above certain amount. Im on Starlink which always has packetloss, so syslog was flooded with reports
Yea as of right now only a single missed ping will flag as packet loss in the log
 
Yea as of right now only a single missed ping will flag as packet loss in the log
Starlink is still in the "better then nothing" phase they called beta. I switched the variable to 25% packet loss.. still getting craploads of log entries
 
Starlink is still in the "better then nothing" phase they called beta. I switched the variable to 25% packet loss.. still getting craploads of log entries
I'll come up with an option for this that you can add to config file to turn on and off.

EDIT:
I already found a way to implement this, tested initially and appears to work well. I will work out small details and update version possibly later tonight or tomorrow.
 
Last edited:
My script uses wan1_ifname and wan0_ifname to update wan_ifname. Let me double check those settings and test on my end.
@amplatfus I confirmed the script is updating wan_ifname in v1.4.1, do this for me. Failover to your 2nd WAN and manually set the value with the following command:
Code:
nvram set wan_ifname=eth8
Monitor the value to see if something is changing it back after you change it manually:
Code:
nvram get wan_ifname
 
I'll come up with an option for this that you can add to config file to turn on and off.
I wasnt complaining about your log, was bitching about how sad starlink is still :)
 
I wasnt complaining about your log, was bitching about how sad starlink is still :)
You’re fine, I like to make this flexible across everyone’s environment.

EDIT:
Check my v1.4.2 release notes ;)
 
Last edited:
v1.4.2 Update Available:
- Added Configuration Mode option to reconfigure configuration file, use argument "config".
- During Installation Mode or Configuration Mode, QoS Download/Upload Bandwidth inputs are now in Mbps instead of Kbps. The script will automatically convert these into Kbps inside the configuration file.
- Added option to configuration for Packet Loss alerts under 100% loss to not be logged, if upgrading from v1.4.1 or older, run Configuration Mode to disable this new option.
- Added checks for configuration input to not allow invalid input(s).
 
Why don't you use email conf from amtm?
As soon as they have been implemented, I stopped using AiProtection email alerts.
 
v1.4.2 Update Available:
- Added Configuration Mode option to reconfigure configuration file, use argument "config".
- During Installation Mode or Configuration Mode, QoS Download/Upload Bandwidth inputs are now in Mbps instead of Kbps. The script will automatically convert these into Kbps inside the configuration file.
- Added option to configuration for Packet Loss alerts under 100% loss to not be logged, if upgrading from v1.4.1 or older, run Configuration Mode to disable this new option.
- Added checks for configuration input to not allow invalid input(s).
You happen to have a link to the last version, this one isnt working at all, doesnt even make the secondary hot. I should of saved it, until I can see whats going on.
EDIT: found it on github
 
Last edited:

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top