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!

I'll consider a custom config location for next version.
Thanks @Ranger802004 , and also just confirming Beta 14f working fine for me as per our discussions yesterday, with seemingly no regressions after my "usual" suite of tests.
As discussed previously, I still don't get a Failover email in some specific "short interruption" situations, but no different to Beta 14e.
I think this one may be cooked enough to go into Production?
 
Thanks @Ranger802004 , and also just confirming Beta 14f working fine for me as per our discussions yesterday, with seemingly no regressions after my "usual" suite of tests.
As discussed previously, I still don't get a Failover email in some specific "short interruption" situations, but no different to Beta 14e.
I think this one may be cooked enough to go into Production?
Send me some more logs on when the email doesn't happen and let me see if I can take a look at what's going on.
 
I'll consider a custom config location for next version.

Or you could keep your status check file separate from the logs (which some power users shift around), to simplify your life.
 
Dear Ranger, I manually triggered a WAN0 disconnect. The script successfully switched to WAN1, but did not fallback to WAN0 when it was re-connected.
Also, Skynet did not restart successfully. Do you see anything in this log?
The last log I see before you executed the manual switch was this? Did something crash because it looks like it stopped executing here and none of the cleanup functions ran that normally run on script termination / kill signals
  1. Aug 15 13:49:23 wan-failover.sh: Debug - Setting WAN0 Status for DNS Switch
 
If you scroll further down in the syslog, you will see more wan-failover script entries.
I don't think that something crashed.
At some time, I manually switched back to WAN0 with "wan-failover switchwan" command.
 
If you scroll further down in the syslog, you will see more wan-failover script entries.
I don't think that something crashed.
At some time, I manually switched back to WAN0 with "wan-failover switchwan" command.
The manual switch wan is the only logs I see after that.
 
Published another revision with a few enhancements/tweaks. Give it a test and report back please.
 
Or you could keep your status check file separate from the logs (which some power users shift around), to simplify your life.
What do you mean? I don't think I'm following you.
 
What do you mean? I don't think I'm following you.

Anything add-on specific that you want to track for the purpose of the add-on, keep it in a jffs/addons/wan-failover/ folder or perhaps the /jffs/configs/ folder like you do for the conf file.

I look at the logger as just that -- audit, trace, debug log, not to be parsed for any add-on operational purpose/lookup. So doesn't matter where/what a user does to the syslog on the box.

Hope that helps.
 
Anything add-on specific that you want to track for the purpose of the add-on, keep it in a jffs/addons/wan-failover/ folder or perhaps the /jffs/configs/ folder like you do for the conf file.

I look at the logger as just that -- audit, trace, debug log, not to be parsed for any add-on operational purpose/lookup. So doesn't matter where/what a user does to the syslog on the box.

Hope that helps.
My thought was to generate a setting like CUSTOMLOGPATH= in config file and leave it blank and if it is blank to skip over using it and proceed forward and if someone sets it, the monitor will use it.
 
My thought was to generate a setting like CUSTOMLOGPATH= in config file and leave it blank and if it is blank to skip over using it and proceed forward and if someone sets it, the monitor will use it.

Yes, that was what I had in mind, thanks!
 
v1.5.6 has been officially released! See Original Post for updating and viewing the readme!

v1.5.6
Installation:
- During installation, if QoS is Enabled and set using Manual Settings, WAN0 QoS Settings will apply the values set from the router.
- Fixed Cron Job deletion during Uninstallation.

Enhancements:
- General optimization
- Added a confirmation prompt to Restart Mode.
- During WAN Status checks, WAN Failover will test different IP Rules / Routes to ensure router can properly ping a Target IP with correct interface. Warning messages will log if a rule or route can cause potential conflicts with the IP using other services.
- 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.
- 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.
- 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.
- 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.
- Fixed issue where the Router firwmare would switch WAN instead of WAN Failover causing some settings to not be changed such as WAN IP, Gateway, DNS, and QoS Settings.
 
v1.5.6 has been officially released!

Great work @Ranger802004 and thank you for the massive effort to harness the rudimentary (and badly broken) Asus Dual-WAN "bones" into something which I now feel I can really rely on for my main Production router. Working very, very nicely for me as a cheap "insurance" backup WAN with a 4G USB stick and data plan.

Looking forward to seeing where you go with future versions (AMTM? GUI?), and hoping others may choose to send a little "encouragement" your way as well ...

>>>> Donation Link <<<<
 
Last edited:
Great work @Ranger802004 and thank you for the massive effort to harness the rudimentary (and badly broken) Asus Dual-WAN "bones" into something which I now feel I can really rely on for my main Production router. Working very, very nicely for me as a cheap "insurance" backup WAN with a 4G USB stick and data plan.

Looking forward to seeing where you go with future versions (AMTM? GUI?), and hoping others may choose to send a little "encouragement" your way as well ...

>>>> Donation Link <<<<
Thank you for this post! I have put a lot of time in this to make it work for everyone well and hope to continue that trend!
 
Dear Ranger, thank you for this script. I have another request, if this is possible:
If QoS is disabled or set to automatic not to ask for QoS settings during script install process.

It may confuse some users if they don't know what QoS is and which values to insert during install process. Thanks!
 
I completely agree.
I would also really like to see a GUI in this script and in the Domain-based VPN Routing Script, but it seems to me that this is a very time-consuming function.
others may choose to send a little "encouragement" your way as well

With pleasure if there were other options than paypal (does not work in my country)
 

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