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!

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’ve started moving towards that direction already.
 
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.


With pleasure if there were other options than paypal (does not work in my country)
What do they allow?
 
What do they allow?
If you are talking about donations, then: Crypto works always and for everyone;)

If you are talking about the GUI, then this script could conveniently view the settings, status.

in Domain-based VPN Routing Script, I would like to change settings through the web interface (add and remove domains, set which vpn interface to use)
 
Screenshot_2022-08-17-18-27-28-91_40deb401b9ffe8e1df2f1cc5ba480b12.jpg

What means 1 in the log? Is it really 1 or is it a typo, Just everywhere as a percentage.

Aug 17 16:20:19 RT-AX88U-30C8 wan-failover.sh: Packet Loss Detected - WAN1 Packet Loss: 1
 
If you are talking about donations, then: Crypto works always and for everyone;)

If you are talking about the GUI, then this script could conveniently view the settings, status.

in Domain-based VPN Routing Script, I would like to change settings through the web interface (add and remove domains, set which vpn interface to use)
I need to get back into Crypto...I had some up until last year but yes that's what I was referring to because I know things are restrictive where you are so was curious. As far as UI I'm going to be working on an SSH UI for WAN Failover first so it can get integrated with amtm and then consider something like that for Domain-based VPN Routing.
 
View attachment 43610

What means 1 in the log? Is it really 1 or is it a typo, Just everywhere as a percentage.

Aug 17 16:20:19 RT-AX88U-30C8 wan-failover.sh: Packet Loss Detected - WAN1 Packet Loss: 1
Not sure how that happened but my guess is this. The output of the pings are written to a temporary file in memory under /tmp and the function is set to wait on the ping commands to finish before reading the output but somehow the write may have not been finished when it was being read.
 
Error during update:
 

Attachments

  • Screenshot_20220818-053130_JuiceSSH.jpg
    Screenshot_20220818-053130_JuiceSSH.jpg
    71 KB · Views: 58
Error during uninstall:

Code:
ASUSWRT-Merlin RT-AC86U 386.7_2 Sun Jul 24 21:39:14 UTC 2022
admin@RT-AC86U-9AD0:/tmp/home/root# /jffs/scripts/wan-failover.sh uninstall
wan-failover.sh - Uninstall Mode
Press any key to continue to uninstall...wan-failover.sh: Cron - Removing Cron Job
wan-failover.sh: Cron - Removed Cron Job
wan-failover.sh - Uninstall: Deleting /jffs/configs/wan-failover.conf...
wan-failover.sh - Uninstall: /jffs/configs/wan-failover.conf deleted.
wan-failover.sh - Uninstall: Removing Cron Job from Wan-Event...
wan-failover.sh - Uninstall: Removed Cron Job from Wan-Event.
wan-failover.sh - Uninstall: Removing Alias for /jffs/scripts/wan-failover.sh as wan-failover...
wan-failover.sh - Uninstall: Removed Alias for /jffs/scripts/wan-failover.sh as wan-failover...
/jffs/scripts/wan-failover.sh: line 2: WAN0TARGET: parameter not set
admin@RT-AC86U-9AD0:/tmp/home/root#

And during install, I noticed this.
I guess this is just a cosmetic error/typo/thingy:
Code:
Aug 18 15:38:02 wan-failover.sh: Debug - WAN0TARGET: 8.8.8.8
Aug 18 15:38:15 wan-failover.sh: Debug - WAN1 Target: 8.8.4.4
 
Error during uninstall:

Code:
ASUSWRT-Merlin RT-AC86U 386.7_2 Sun Jul 24 21:39:14 UTC 2022
admin@RT-AC86U-9AD0:/tmp/home/root# /jffs/scripts/wan-failover.sh uninstall
wan-failover.sh - Uninstall Mode
Press any key to continue to uninstall...wan-failover.sh: Cron - Removing Cron Job
wan-failover.sh: Cron - Removed Cron Job
wan-failover.sh - Uninstall: Deleting /jffs/configs/wan-failover.conf...
wan-failover.sh - Uninstall: /jffs/configs/wan-failover.conf deleted.
wan-failover.sh - Uninstall: Removing Cron Job from Wan-Event...
wan-failover.sh - Uninstall: Removed Cron Job from Wan-Event.
wan-failover.sh - Uninstall: Removing Alias for /jffs/scripts/wan-failover.sh as wan-failover...
wan-failover.sh - Uninstall: Removed Alias for /jffs/scripts/wan-failover.sh as wan-failover...
/jffs/scripts/wan-failover.sh: line 2: WAN0TARGET: parameter not set
admin@RT-AC86U-9AD0:/tmp/home/root#

And during install, I noticed this.
I guess this is just a cosmetic error/typo/thingy:
Code:
Aug 18 15:38:02 wan-failover.sh: Debug - WAN0TARGET: 8.8.8.8
Aug 18 15:38:15 wan-failover.sh: Debug - WAN1 Target: 8.8.4.4
I’ll review these items for v1.5.7 beta
 
More cosmetic stuff to consider @Ranger802004 when you get around to noodling on the next beta ...
I think this one could well be related to the last bug you squashed for me prior to releasing 1.5.6 maybe?

I did a quick Reboot of my Secondary WAN device, a 4G LTE USB Stick, using it's own GUI, so no Failover/Fallback, just "loss' of backup capability for a minute or so.
All handled properly by wan-failover / vpnmon-r2, but the emails are slightly incorrect as below, it's taking the Active IP and Gateway addresses from the Secondary but gets everything else right.

Let me know if you want logs?

Code:
Received on WAN1 Reboot ...

***WAN Failover Notification***
----------------------------------------------------------------------------------------
Hostname: 16henrystreet.dyndns.org
Event Time: Aug 19 06:33:56
WAN0 Status: CONNECTED
WAN1 Status: DISCONNECTED
Active ISP: Superloop
WAN IPv4 Address: 192.168.2.100 <<= Should be 203.132.93.25
WAN Gateway IP Address: 192.168.2.1 <<= Should be 203.132.93.1
WAN Interface: eth0
DNS: Managed by AdGuardHome
QoS Status: Enabled
QoS Mode: Manual Settings
QoS Download Bandwidth: 100Mbps
QoS Upload Bandwidth: 35Mbps
QoS WAN Packet Overhead: 0
----------------------------------------------------------------------------------------


Received on WAN1 Re-Connect ...

***WAN Failover Notification***
----------------------------------------------------------------------------------------
Hostname: 16henrystreet.dyndns.org
Event Time: Aug 19 06:35:23
WAN0 Status: CONNECTED
WAN1 Status: CONNECTED
Active ISP: Superloop
WAN IPv4 Address: 192.168.2.100 <<= Should be 203.132.93.25
WAN Gateway IP Address: 192.168.2.1 <<= Should be 203.132.93.1
WAN Interface: eth0
DNS: Managed by AdGuardHome
QoS Status: Enabled
QoS Mode: Manual Settings
QoS Download Bandwidth: 100Mbps
QoS Upload Bandwidth: 35Mbps
QoS WAN Packet Overhead: 0
----------------------------------------------------------------------------------------

Also, the reason I was rebooting the USB stick was that this morning when I was checking I couldn't get to it's web interface on 192.168.2.1, even though I could ping it.
Had to connect separately to it on its own Wifi in order to login and reboot it.

Was definitely working yesterday via the Asus router and suddenly stopped for some reason - maybe not related at all to wan-failover.
I assume the reboot of USB stick makes your script re-impose the routes? Don't know if there is something else going on ... will monitor for a repeat.
 
More cosmetic stuff to consider @Ranger802004 when you get around to noodling on the next beta ...
I think this one could well be related to the last bug you squashed for me prior to releasing 1.5.6 maybe?

I did a quick Reboot of my Secondary WAN device, a 4G LTE USB Stick, using it's own GUI, so no Failover/Fallback, just "loss' of backup capability for a minute or so.
All handled properly by wan-failover / vpnmon-r2, but the emails are slightly incorrect as below, it's taking the Active IP and Gateway addresses from the Secondary but gets everything else right.

Let me know if you want logs?

Code:
Received on WAN1 Reboot ...

***WAN Failover Notification***
----------------------------------------------------------------------------------------
Hostname: 16henrystreet.dyndns.org
Event Time: Aug 19 06:33:56
WAN0 Status: CONNECTED
WAN1 Status: DISCONNECTED
Active ISP: Superloop
WAN IPv4 Address: 192.168.2.100 <<= Should be 203.132.93.25
WAN Gateway IP Address: 192.168.2.1 <<= Should be 203.132.93.1
WAN Interface: eth0
DNS: Managed by AdGuardHome
QoS Status: Enabled
QoS Mode: Manual Settings
QoS Download Bandwidth: 100Mbps
QoS Upload Bandwidth: 35Mbps
QoS WAN Packet Overhead: 0
----------------------------------------------------------------------------------------


Received on WAN1 Re-Connect ...

***WAN Failover Notification***
----------------------------------------------------------------------------------------
Hostname: 16henrystreet.dyndns.org
Event Time: Aug 19 06:35:23
WAN0 Status: CONNECTED
WAN1 Status: CONNECTED
Active ISP: Superloop
WAN IPv4 Address: 192.168.2.100 <<= Should be 203.132.93.25
WAN Gateway IP Address: 192.168.2.1 <<= Should be 203.132.93.1
WAN Interface: eth0
DNS: Managed by AdGuardHome
QoS Status: Enabled
QoS Mode: Manual Settings
QoS Download Bandwidth: 100Mbps
QoS Upload Bandwidth: 35Mbps
QoS WAN Packet Overhead: 0
----------------------------------------------------------------------------------------

Also, the reason I was rebooting the USB stick was that this morning when I was checking I couldn't get to it's web interface on 192.168.2.1, even though I could ping it.
Had to connect separately to it on its own Wifi in order to login and reboot it.

Was definitely working yesterday via the Asus router and suddenly stopped for some reason - maybe not related at all to wan-failover.
I assume the reboot of USB stick makes your script re-impose the routes? Don't know if there is something else going on ... will monitor for a repeat.
The router deletes the rules/routes when an interface is dropped and defaults things back to WAN1 so I just have to find what condition it is and force it back. Logs will help :)
 
So I'm in the middle of developing first beta for v1.5.7 and I'm trying to make sure I am thinking of all of the requests I received for enhancements (not fixes). So far I've incorporated these 2 for the next build but if you have any additional requests please post here and I will see what I can do to implement them into the script, thank you!

- WAN0 and WAN1 can be specified to have QoS Enabled or Disabled during Failovers.
- WAN0 and WAN1 Packet Size can be specified seperately in Configuration File.
- Custom Log Path can be specified for Monitor Mode using CUSTOMLOGPATH setting in Configuration Settings.
 
Last edited:
Also, the reason I was rebooting the USB stick was that this morning when I was checking I couldn't get to it's web interface on 192.168.2.1, even though I could ping it.
Had to connect separately to it on its own Wifi in order to login and reboot it.

Was definitely working yesterday via the Asus router and suddenly stopped for some reason - maybe not related at all to wan-failover.
I assume the reboot of USB stick makes your script re-impose the routes? Don't know if there is something else going on ... will monitor for a repeat.

I had the same thing right now. I haven’t checked for a long time how my devices are connected to wan1 (ethernet, not usb) and they were also all unavailable for entering the web interface. Restarted from physically and everything earned. True, I set up something in the router (the same thing for all three), so for now let's write it off as a glitch.
 
but if you have any additional requests please post here and I will see what I can do to implement them into the script, thank you!
I think those 3 cover it for me off the top of my head … thanks @Ranger802004
 
v1.5.7-beta1b 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-beta.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-beta.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, verify DEVMODE in Configuration is set to 0 before running this command:
Code:
/jffs/scripts/wan-failover.sh update

Beta Readme

Release Notes:
v1.5.7-beta1b
Installation:
- Fixed during Uninstallation where Cleanup would error out due to not having configuration items loaded prior to deletion of configuration file.
- Fixed text formatting for debug logging during installation when selecting WAN IP Address Targets.
- If QoS is Disabled QoS Settings will Default to 0 instead of prompting for configuration.

Enhancements:
- Configuration Mode will instantly kill script and wait for it to be relaunched by Cron Job.
- WAN0 and WAN1 can be specified to have QoS Enabled or Disabled during Failovers.
- WAN0 and WAN1 Packet Size can be specified seperately in Configuration File.
- Custom Log Path can be specified for Monitor Mode using CUSTOMLOGPATH setting in Configuration Settings.
- Added Dev Mode to update to beta releases using Update Command
- Service Restarts triggered by USB Modem failure events when it is not the Primary WAN will only restart OpenVPN Server instances.
- Added Configuration Option CHECKNVRAM to Enable or Disable NVRAM Checks due to only certain routers needing this check such as the RT-AC86U.
- New Status UNPLUGGED for when a WAN interface connection is not physically present.

Fixes:
- Configuration Mode will no longer delete new or current IP rules/routes and will delete old ones before restarting script.
- Switch WAN function will now properly check Default IP Routes for deletion and creation.
- Load Balance Mode will now properly get default WAN Status before performing checks
- Emails not generating when some scenarios of Secondary WAN failure occur in Failover Mode.
 
Last edited:
File.
- Custom Log Path can be specified for Monitor Mode using CUSTOMLOGPATH setting in Configuration Settings.

Confirmed this is working, thanks @Ranger802004.

Also did a quick remote reboot of my 4G USB stick to simulate a WAN1 outage, that went OK. Noticed reduced amount of info on the notification emails? No more IP/Gateway/Interface? Deliberate I assume?
 
Confirmed this is working, thanks @Ranger802004.

Also did a quick remote reboot of my 4G USB stick to simulate a WAN1 outage, that went OK. Noticed reduced amount of info on the notification emails? No more IP/Gateway/Interface? Deliberate I assume?
No it should be there just grabbing it a different way to ensure accuracy, do you have logs you can send?
 
No it should be there just grabbing it a different way to ensure accuracy, do you have logs you can send?

Will do so when I can via DM as usual. :)
 
WAN0 and WAN1 can be specified to have QoS Enabled or Disabled during Failovers.

Thanks and slapped this beta in for testing, specifically for this feature.

Observation
- QoS is only disabled on Failover and not reconfig/restart of the script. My expectation is that on reconfig/restart the QoS settings/toggle should be enabled/disabled based on configuration file. Thus, for WAN0 I had to manually disable QoS. Trending in the right direction as usual @Ranger802004
 

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!

Members online

Top