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!

Try adding this IP Rule and see if it helps.

ip rule add from all to 10.100.10.1 lookup 200

Hooray! Works! Thanks! :) And where to add it so that it starts automatically, in nat-start? Or somewhere in the script?

I'm testing beta13 on all my routers, everything is fine, the only thing when there is a problem on wan1, you get a lot of email notifications and not 1 ;)
For a couple of minutes I turned off the 4g modem (to which you made access :) ), during this time I received 6 emails
 
Last edited:
I republished beta13 to add some logic to Monitor Mode to help it dynamically find the System Log File, reinstall and give it a try, thank you.
It seems that is not working fine with my location /opt /var /log /messages:
Code:
Aug 11 11:58:00 src@B88X wan-failover.sh: Debug - PATH: /sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/home/vZM7dLQ9:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin
Aug 11 11:58:00 src@B88X wan-failover.sh: Debug - System Log located at /tmp/syslog.log
Thank you very much!
 
And please, the email notification can be disabled?
10q
 
It seems that is not working fine with my location /opt /var /log /messages:
Code:
Aug 11 11:58:00 src@B88X wan-failover.sh: Debug - PATH: /sbin:/bin:/usr/sbin:/usr/bin:/opt/bin:/opt/sbin:/bin:/usr/bin:/sbin:/usr/sbin:/home/vZM7dLQ9:/mmc/sbin:/mmc/bin:/mmc/usr/sbin:/mmc/usr/bin:/opt/sbin:/opt/bin:/opt/usr/sbin:/opt/usr/bin
Aug 11 11:58:00 src@B88X wan-failover.sh: Debug - System Log located at /tmp/syslog.log
Thank you very much!

In the script, swap paths, put your path higher.

 
v1.5.6-beta13 Release: ***Disclaimer: This is a beta release and has been untested***

Manually upgrade to this beta by running the following command" ***Allow for cronjob to relaunch the script***
Clean installation:
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta13.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh install

Upgrade from previous installation:
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta13.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh restart

To revert back to Production Release:
Code:
/jffs/scripts/wan-failover.sh update

Beta Readme

***WARNING*** There are some major changes from v1.5.6-beta9 so if you experience issues please collect debug logs and forward to me via DM!

***WARNING*** If you are using an RT-AX88U, read release notes!


***HIGHLIGHT*** Script will now send emails in Failover Mode if the Primary or Secondary WAN fails or is disabled.

***HIGHLIGHT*** Script will now create an alias as "wan-failover", once script is updated and restarted. Consoles can now use the new alias instead of the full script path "/jffs/scripts/wan-failover.sh". Consoles open while the script is updated may need to be restarted or the following command executed.

Code:
source /jffs/configs/profile.add

Release Notes:
v1.5.6-beta13
- General optimization
- Added a confirmation prompt to Restart Mode.
- Fixed visual bugs when running Restart Mode.
- Load Balance Monitor now triggers Service Restart function during failover events.
- YazFi trigger during service restart will no longer run process in the background to prevent issues with script execution of YazFi.
- IP Rules should no longer create conflict with other scripts such as VPNMON.
- Target IPs for both interfaces can now be the same the Target IP.
- Added Recursive Ping Check feature. If packet loss is not 0% during a check, the Target IP Addresses will be checked again based on the number of iterations specified by this setting before determing a failure or packet loss. RECURSIVEPINGCHECK (Value is in # of iterations). Default: 1
- Resolved issues that prevented 4G USB Devices from properly working in Failover Mode.
- Moved WAN0_QOS_OVERHEAD, WAN1_QOS_OVERHEAD, WAN0_QOS_ATM, WAN1_QOS_ATM, BOOTDELAYTIMER, PACKETLOSSLOGGING and WANDISABLEDSLEEPTIMER to Optional Configuration and no longer are required to be set during Config or Installation. They will be given Default values that can be modified in the Configuration file.
- Created new Optional Configured Option to specify the ping packet size. PACKETSIZE specifes the packet size in Bytes, Default: 56 Bytes.
- Resolve issue where script would loop from WAN Status to Load Balance Monitor when an interface was disabled.
- Load Balance Mode will now dynamically update resolv.conf (DNS) for Disconnected WAN Interfaces.
- Fixed Cron Job deletion during Uninstallation.
- Corrected issue with Failure Detected log not logging if a device was unplugged or powered off from the Router while in Failover Mode.
- Modified Restart Mode logic to better detect PIDs of running instances of the script.
- Created Alias for script as wan-failover to shorten length of commands used in console.
- Fixed issue where if the USB Device is unplugged and plugged back in, script will now leave Disabled State to go back to WAN Status.
- Enhanced WAN Disabled Logging, will relog every 5 minutes the condition causing the script to be in the Disabled State.
- Added additional logging throughout script.
- Email function will check if DDNS is enabled before attempting to use saved DDNS Hostname
- Added cleanup function for when script exits to perform cleanup tasks.
- Service Restarts now include restarting enabled OpenVPN Server Instances.
- Target IP Rules will now compensate for the RT-AX88U however this can create conflicts if the Target IPs are the same or are used for other services/scripts.
- Fixed issue in DNS Switch in Load Balance Mode where WAN1 was using the Status of WAN0.
- Switch WAN Mode will now prompt for confirmation before switching.
- Fixed issue where Switch WAN Mode would fail due to missing Status parameters acquired in Run or Manual Mode.
- Fixed issue where WAN Interface would not come out of Cold Standby during WAN Status Check.
- Script will now reset VPNMON-R2 if it is installed and running during Failover
- Enhanced Ping Monitoring to improve failure/packet loss detection time.
- If an amtm email alert fails to send, an email attempt will be made via AIProtection Alerts if properly configured.
- An email notification will now be sent if the Primary or Secondary WAN fails or is disabled while in Failover Mode.
- Fixed issue in Load Balance Mode when a Disconnected WAN Interface would cause WAN Failover to error and crash when creating OpenVPN rules when OpenVPN Split Tunneling is Disabled.
- If IPv6 6in4 Service is being used, wan6 service will be restarted during failover events.

Running Beta 13, and noticed that the QoS settings in the conf file wasn't being applied on Failover/Failback.

Guess should enable debug logs and pass it over, or is this something easily reproduced?

Primary: 400 up/down (prefer to disable QoS on this one if possible once running)
Secondary: 150/15 (must have QoS on this one)

Conf file snippet

Code:
WAN0_QOS_IBW=409600
WAN1_QOS_IBW=153600
WAN0_QOS_OBW=409600
WAN1_QOS_OBW=15360
WAN0_QOS_OVERHEAD=44
WAN1_QOS_OVERHEAD=18
WAN0_QOS_ATM=0
WAN1_QOS_ATM=0

I was running on secondary and QoS settings were showing in the GUI and being enforced from my Bufferbloat tests. When I switched to Primary, all was smooth but noticed I was being capped by the 150/15 QoS settings. I've disabled QoS for now as I am running on the primary. If you require further testing/logs (assuming you can't reproduce), I'll be more than happy to provide. Note I use Cake on the QoS side.
 

In the script, swap paths, put your path higher.

OK, thank you. But after every update I have to change the order :(
 
OK, thank you. But after every update I have to change the order :(
Yea sorry I’m working on it still, I have been talking to @lbtboy to iron out a solid solution. I was under the understanding the other files don’t exist but they do but are blank so I am going to come up with a way to look for scribe first and then look for factory syslog secondary.
 
Running Beta 13, and noticed that the QoS settings in the conf file wasn't being applied on Failover/Failback.

Guess should enable debug logs and pass it over, or is this something easily reproduced?

Primary: 400 up/down (prefer to disable QoS on this one if possible once running)
Secondary: 150/15 (must have QoS on this one)

Conf file snippet

Code:
WAN0_QOS_IBW=409600
WAN1_QOS_IBW=153600
WAN0_QOS_OBW=409600
WAN1_QOS_OBW=15360
WAN0_QOS_OVERHEAD=44
WAN1_QOS_OVERHEAD=18
WAN0_QOS_ATM=0
WAN1_QOS_ATM=0

I was running on secondary and QoS settings were showing in the GUI and being enforced from my Bufferbloat tests. When I switched to Primary, all was smooth but noticed I was being capped by the 150/15 QoS settings. I've disabled QoS for now as I am running on the primary. If you require further testing/logs (assuming you can't reproduce), I'll be more than happy to provide. Note I use Cake on the QoS side.
If QoS is disabled then it stops applying any settings, did you have QoS enabled during a Failover and new settings weren’t applied?
 
If QoS is disabled then it stops applying any settings, did you have QoS enabled during a Failover and new settings weren’t applied?

During failover it was enabled.

I checked the QoS GUI page and Speedtest and was getting the 150/15 cap instead of the 300/300.

I then disabled it, and reported the issue - as I am on the 300/300 (which ideally, i would like to switch off when using), and have QoS only kick-in for my secondary (150/15).

Thanks again for this awesomeness!
 
During failover it was enabled.

I checked the QoS GUI page and Speedtest and was getting the 150/15 cap instead of the 300/300.

I then disabled it, and reported the issue - as I am on the 300/300 (which ideally, i would like to switch off when using), and have QoS only kick-in for my secondary (150/15).

Thanks again for this awesomeness!
Did the actual values change in the QoS Menu during your failover? That is functionality that should happen, as far as changing QoS Enabled vs Disabled between interfaces is something I'd have to look into for a future release.
 
as far as changing QoS Enabled vs Disabled between interfaces is something I'd have to look into for a future release

Another vote for looking at possibility to disable / re-enable QoS on Failover please.
My secondary is a USB 4G stick which is very variable in performance anyway and it makes no sense to have QoS turned on, but it is definitely useful on my day-to-day primary connection. At the moment I just set the QoS numbers on the secondary at stupidly high numbers in the hope it then doesn’t do anything, but turning it off when I’m failed over would be neater if it’s achievable?
 
Another vote for looking at possibility to disable / re-enable QoS on Failover please.
My secondary is a USB 4G stick which is very variable in performance anyway and it makes no sense to have QoS turned on, but it is definitely useful on my day-to-day primary connection. At the moment I just set the QoS numbers on the secondary at stupidly high numbers in the hope it then doesn’t do anything, but turning it off when I’m failed over would be neater if it’s achievable?
I have some ideas so I'll look into it for future release.
 
Nope it didn't. It remained on 150/15.
I'm taking a quick look at that section before I publish (hopefully) my last update for v1.5.6 before going full release.
 
v1.5.6-beta14 Release: ***Disclaimer: This is a beta release and has been untested***

Manually upgrade to this beta by running the following command" ***Allow for cronjob to relaunch the script***
Clean installation:
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta14.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh install

Upgrade from previous installation:
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta14.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh restart

To revert back to Production Release:
Code:
/jffs/scripts/wan-failover.sh update

Beta Readme

***WARNING*** There are some major changes from v1.5.6-beta9 so if you experience issues please collect debug logs and forward to me via DM!

***WARNING*** If you are using an RT-AX88U, read release notes!


***HIGHLIGHT*** Script will now send emails in Failover Mode if the Primary or Secondary WAN fails or is disabled.

***HIGHLIGHT*** Script will now create an alias as "wan-failover", once script is updated and restarted. Consoles can now use the new alias instead of the full script path "/jffs/scripts/wan-failover.sh". Consoles open while the script is updated may need to be restarted or the following command executed.

Code:
source /jffs/configs/profile.add

Release Notes:
v1.5.6-beta14b
Enhancements:
- General optimization
- Added a confirmation prompt to Restart Mode.
- Load Balance Monitor now triggers Service Restart function during failover events.
- Target IPs for both interfaces can now be the same the Target IP.
- Added Recursive Ping Check feature. If packet loss is not 0% during a check, the Target IP Addresses will be checked again based on the number of iterations specified by this setting before determing a failure or packet loss. RECURSIVEPINGCHECK (Value is in # of iterations). Default: 1
- Moved WAN0_QOS_OVERHEAD, WAN1_QOS_OVERHEAD, WAN0_QOS_ATM, WAN1_QOS_ATM, BOOTDELAYTIMER, PACKETLOSSLOGGING and WANDISABLEDSLEEPTIMER to Optional Configuration and no longer are required to be set during Config or Installation. They will be given Default values that can be modified in the Configuration file.
- Created new Optional Configured Option to specify the ping packet size. PACKETSIZE specifes the packet size in Bytes, Default: 56 Bytes.
- Load Balance Mode will now dynamically update resolv.conf (DNS) for Disconnected WAN Interfaces.
- Created Alias for script as wan-failover to shorten length of commands used in console.
- Enhanced WAN Disabled Logging, will relog every 5 minutes the condition causing the script to be in the Disabled State.
- Added additional logging throughout script.
- Added cleanup function for when script exits to perform cleanup tasks.
- Service Restarts now include restarting enabled OpenVPN Server Instances.
- Target IP Rules will now compensate for the RT-AX88U however this can create conflicts if the Target IPs are the same or are used for other services/scripts.
- Switch WAN Mode will now prompt for confirmation before switching.
- Script will now reset VPNMON-R2 if it is installed and running during Failover
- Enhanced Ping Monitoring to improve failure/packet loss detection time as well as failure and restoration logging notifications.
- An email notification will now be sent if the Primary or Secondary WAN fails or is disabled while in Failover Mode.
- If IPv6 6in4 Service is being used, wan6 service will be restarted during failover events.
- Updated Monitor Mode to dynamically search multiple locations for System Log Path such as if Scribe or Entware syslog-ng package is installed.
- If QoS Settings are set to 0 for a WAN Interface, this will apply Automatic Settings for QoS when that WAN Interface becomes the Primary WAN.

Fixes:
- Fixed visual bugs when running Restart Mode.
- YazFi trigger during service restart will no longer run process in the background to prevent issues with script execution of YazFi.
- IP Rules should no longer create conflict with other scripts such as VPNMON unless using the RT-AX88U.
- Resolved issues that prevented 4G USB Devices from properly working in Failover Mode.
- Resolve issue where script would loop from WAN Status to Load Balance Monitor when an interface was disabled.
- Fixed Cron Job deletion during Uninstallation.
- Corrected issue with Failure Detected log not logging if a device was unplugged or powered off from the Router while in Failover Mode.
- Modified Restart Mode logic to better detect PIDs of running instances of the script.
- Fixed issue where if the USB Device is unplugged and plugged back in, script will now leave Disabled State to go back to WAN Status.
- Email function will check if DDNS is enabled before attempting to use saved DDNS Hostname
- Fixed issue in DNS Switch in Load Balance Mode where WAN1 was using the Status of WAN0.
- Fixed issue where Switch WAN Mode would fail due to missing Status parameters acquired in Run or Manual Mode.
- Fixed issue where WAN Interface would not come out of Cold Standby during WAN Status Check.
- If an amtm email alert fails to send, an email attempt will be made via AIProtection Alerts if properly configured.
- Fixed issue in Load Balance Mode when a Disconnected WAN Interface would cause WAN Failover to error and crash when creating OpenVPN rules when OpenVPN Split Tunneling is Disabled.
- Fixed issue where QoS settings would not apply during WAN Switch
- Fixed issue where if WAN1 was connected but failing ping, the script would loop back and forth from WAN Status to WAN Disabled.
 
Last edited:

Similar threads

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