Ranger802004
Very Senior Member
WAN Failover is designed to replace the factory ASUS WAN Failover functionality, this script will monitor the WAN Interfaces using a Target IP Address and pinging these targets to determine when a failure occurs. When a failure is detected in Failover Mode, the script will switch to the Secondary WAN interface automatically and then monitor for failback conditions. When the Primary WAN interface connection is restored based on the Target IP Address, the script will perform the failback condition and switch back to Primary WAN. When a failure is detected in Load Balancing Mode, the script will remove the down WAN interface from Load Balancing and restore it when it is active again.
Requirements:
- ASUS Merlin Firmware v386.9 or higher
- JFFS custom scripts and configs Enabled
- Dual WAN Enabled
- ASUS Factory Failover Disabled (Network Monitoring Options, Allow Failback Option under WAN > Dual WAN)
Installation:
Updating:
Use Menu Option 6 or Run the Following Command
Uninstallation:
Use Menu Option 4 or Run the Following Command
Link to Script:
https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover.sh
Readme:
https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover-readme.txt
Release Notes:
v2.0.6 Release Notes:
Enhancements:
- Added 388.4 to Support List
- General Optimization
- WireGuard clients will restart during failover to recreate the default routes in each WireGuard Route Table.
Fixes:
- Corrected issue where having no OpenVPN Server Instances configured caused WAN Failover to hang.
v2.0.5 Release Notes:
Fixes:
- Corrected minor issue when retrieving WAN NVRAM Parameters
- Corrected issue if WAN Failover would be stuck in a continuous loop if a router didn't have WAN USB capability.
- Corrected issue that causes WAN Failover to exit in Load Balance mode during failover events.
- Corrected issue where DDNS Hostname being blank would cause the script to hang in a loop while collecting System Settings.
- Corrected issue during install where the existing monitor target value was a domain and being used as the WAN0 Target IP default value.
v2.0.4 Release Notes:
Enhancements:
- Added 3rd DNS Server from Automatic Settings to be factored into WAN Failover events.
- The checkiprules function will now be checked at the beginning of WAN Status checks to ensure NAT rules are created if necessary prior to performing packet loss checks.
- Added 386.10 and 386.11 to supported firmware list
- Removed 386.5 and 386.7 from supported firmware list.
Fixes:
- Corrected issue during uninstall when logic was reversed for retaining configuration file or to delete.
v2.0.3 Release Notes:
Fixes:
- Corrected syntax bug in Debug Logging function.
v2.0.2 Release Notes:
Fixes:
- Fixed minor issue with install mode getting stuck on WANDOGTARGET variable.
v2.0.1 Release Notes:
Enhancements:
- Added Process Priority (Real Time, High, Normal, Low, Lowest) for WAN Failover. Configuration Option: Process Priority
- General Optimization.
- CHECKNVRAM is Enabled by Default for the RT-AC86U and GT-AC2900 models on new installations.
- Status Console now shows more descriptions for each WAN interface status.
- Status Console will now passively check for updates every 4 hours while running.
- Status Console will now show WAN Failover status as "Initializing" for start up of the script.
- Added new option to block IPv6 in Failover Mode from traversing Secondary WAN. Configuration Option: Failover Block IPv6
Fixes:
- Corrected issues preventing Failback in v2.0.0.
- Corrected issues with acquiring WAN Interface MAC Addresses.
- Corrected issues with Email Notifications not properly disabling.
- Restart WAN functions will now start interface if already stopped instead of executing restart command.
v2.0.0 Release Notes:
Installation:
- Uninstallation will prompt if configuration file should be deleted or retained.
- During uninstallation, the script will now delete the script file. This change was necessary for AMTM integration
- Installation will automatically create default configuration that can be modified in the Config Menu.
- Installation will alert and log if Router is not properly configured for WAN Failover to being operation.
Enhancements:
- Added 388.2 to supported Firmware list
- Added 386.9 to supported Firmware list
- switchwan argument can now be ran in an unattended mode to passively allow failover that doesn't require User Verification to failover.
- Added new Configuration Option: SCHEDULECRONJON. Enabled by default, this will control whether the Cron Job is scheduled or not for WAN Failover to run.
This is configurable in the Config Menu under Option 23: Configure Cron Job
- Added Load Balance Mode Settings to GUI Config Menu for WAN0 FWMark, WAN0 Mask, WAN1 FWMark, and WAN1 Mask.
- Changed CHECKNVRAM Default to Disabled for performance optimization. This feature should only be enabled on routers with issues accessing nvram.
Existing installations of WAN Failover will need this setting manually changed under Configuration Menu Option 12.
- Added initiate command argument to only create Routing Table Rules, IP Rules, and IPTables Rules.
- Load Balance Monitor will now check IP Rules by default of every 15 minutes to make sure all rules are properly configured. This will help resolve issues where the router adds improperly configured IPTables MANGLE rules.
- Visual Enhancements with prompts.
- Optimization of script including reducing the number of NVRAM calls during script execution.
- New Enhanced Status Console
- Access from Menu or Command Argument "status"
- Built in Refresh Interval Added
- Additional information included (Failover Status, Primary WAN, Gateway MAC Address, Ping Time, etc).
- Added new configuration items PINGTIMEMIN (Ping Time will show green in Console), PINGTIMEMAX (Ping Time will show red in console), STATUSCHECK (Default interval between Status Console refreshes).
- System Log Events will now show as "wan-failover" instead of "wan-failover.sh"
- System Log Events for Failover Mode WAN Switches will dynamically be listed under "Failover" or "Failback" instead of "WAN Switch"
- System Log Events will now log if Ping Time Maximum is reached for WAN0 or WAN1.
- System Log Events will now log if an NVRAM Check Failure occured with CHECKNVRAM Enabled.
- Email Notifications will now display if QoS ATM is enabled.
- Configuration Menu will now allow configuration of all QoS Settings.
- Configuration Mode will now go straight to Configuration Menu when using command argument "config".
- Restart Services will now restart all processes consecutively without waiting for them to complete to reduce failover/failback time.
- Improvements to Update Mode for version checks
- Update Mode will now check checksum to ensure integrity of WAN Failover.
Fixes:
- Removed VPNMON-R2 integration. VPNMON-R2 is now capable of detecting failover events and resetting itself without WAN Failover.
- Resolved issue where some Failback emails were not being generated
- Resolved issue where WAN Failover was logging that QoS settings were being applied and restarting services if the non-Primary WAN failed during monitoring
- Various fixes to improve reliability and integrity of script.
- Monitor and Capture Mode will no longer show messages from tail command stating the file path has changed.
- Fixed Restart Mode not killing all PIDs.
- Added a check if WAN was changed by router firmware before making it to Failover function so it doesn't attempt to switch back Primary WAN to a down WAN interface.
- Fixed an issue where Installation would not create the WAN0_QOS_OBW configuration setting.
Deprecated:
- Removed Email Configuration Mode, use Configuration Menu to change Email Notification Settings.
New Status Console Example:
Note: To change the refresh interval, go to the Configuration Menu and modify the Status Check Setting
Requirements:
- ASUS Merlin Firmware v386.9 or higher
- JFFS custom scripts and configs Enabled
- Dual WAN Enabled
- ASUS Factory Failover Disabled (Network Monitoring Options, Allow Failback Option under WAN > Dual WAN)
Installation:
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jffs/scripts/wan-failover.sh install
Updating:
Use Menu Option 6 or Run the Following Command
Code:
/jffs/scripts/wan-failover.sh update
Uninstallation:
Use Menu Option 4 or Run the Following Command
Code:
/jffs/scripts/wan-failover.sh uninstall
Link to Script:
https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover.sh
Readme:
https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover-readme.txt
Release Notes:
v2.0.6 Release Notes:
Enhancements:
- Added 388.4 to Support List
- General Optimization
- WireGuard clients will restart during failover to recreate the default routes in each WireGuard Route Table.
Fixes:
- Corrected issue where having no OpenVPN Server Instances configured caused WAN Failover to hang.
v2.0.5 Release Notes:
Fixes:
- Corrected minor issue when retrieving WAN NVRAM Parameters
- Corrected issue if WAN Failover would be stuck in a continuous loop if a router didn't have WAN USB capability.
- Corrected issue that causes WAN Failover to exit in Load Balance mode during failover events.
- Corrected issue where DDNS Hostname being blank would cause the script to hang in a loop while collecting System Settings.
- Corrected issue during install where the existing monitor target value was a domain and being used as the WAN0 Target IP default value.
v2.0.4 Release Notes:
Enhancements:
- Added 3rd DNS Server from Automatic Settings to be factored into WAN Failover events.
- The checkiprules function will now be checked at the beginning of WAN Status checks to ensure NAT rules are created if necessary prior to performing packet loss checks.
- Added 386.10 and 386.11 to supported firmware list
- Removed 386.5 and 386.7 from supported firmware list.
Fixes:
- Corrected issue during uninstall when logic was reversed for retaining configuration file or to delete.
v2.0.3 Release Notes:
Fixes:
- Corrected syntax bug in Debug Logging function.
v2.0.2 Release Notes:
Fixes:
- Fixed minor issue with install mode getting stuck on WANDOGTARGET variable.
v2.0.1 Release Notes:
Enhancements:
- Added Process Priority (Real Time, High, Normal, Low, Lowest) for WAN Failover. Configuration Option: Process Priority
- General Optimization.
- CHECKNVRAM is Enabled by Default for the RT-AC86U and GT-AC2900 models on new installations.
- Status Console now shows more descriptions for each WAN interface status.
- Status Console will now passively check for updates every 4 hours while running.
- Status Console will now show WAN Failover status as "Initializing" for start up of the script.
- Added new option to block IPv6 in Failover Mode from traversing Secondary WAN. Configuration Option: Failover Block IPv6
Fixes:
- Corrected issues preventing Failback in v2.0.0.
- Corrected issues with acquiring WAN Interface MAC Addresses.
- Corrected issues with Email Notifications not properly disabling.
- Restart WAN functions will now start interface if already stopped instead of executing restart command.
v2.0.0 Release Notes:
Installation:
- Uninstallation will prompt if configuration file should be deleted or retained.
- During uninstallation, the script will now delete the script file. This change was necessary for AMTM integration
- Installation will automatically create default configuration that can be modified in the Config Menu.
- Installation will alert and log if Router is not properly configured for WAN Failover to being operation.
Enhancements:
- Added 388.2 to supported Firmware list
- Added 386.9 to supported Firmware list
- switchwan argument can now be ran in an unattended mode to passively allow failover that doesn't require User Verification to failover.
- Added new Configuration Option: SCHEDULECRONJON. Enabled by default, this will control whether the Cron Job is scheduled or not for WAN Failover to run.
This is configurable in the Config Menu under Option 23: Configure Cron Job
- Added Load Balance Mode Settings to GUI Config Menu for WAN0 FWMark, WAN0 Mask, WAN1 FWMark, and WAN1 Mask.
- Changed CHECKNVRAM Default to Disabled for performance optimization. This feature should only be enabled on routers with issues accessing nvram.
Existing installations of WAN Failover will need this setting manually changed under Configuration Menu Option 12.
- Added initiate command argument to only create Routing Table Rules, IP Rules, and IPTables Rules.
- Load Balance Monitor will now check IP Rules by default of every 15 minutes to make sure all rules are properly configured. This will help resolve issues where the router adds improperly configured IPTables MANGLE rules.
- Visual Enhancements with prompts.
- Optimization of script including reducing the number of NVRAM calls during script execution.
- New Enhanced Status Console
- Access from Menu or Command Argument "status"
- Built in Refresh Interval Added
- Additional information included (Failover Status, Primary WAN, Gateway MAC Address, Ping Time, etc).
- Added new configuration items PINGTIMEMIN (Ping Time will show green in Console), PINGTIMEMAX (Ping Time will show red in console), STATUSCHECK (Default interval between Status Console refreshes).
- System Log Events will now show as "wan-failover" instead of "wan-failover.sh"
- System Log Events for Failover Mode WAN Switches will dynamically be listed under "Failover" or "Failback" instead of "WAN Switch"
- System Log Events will now log if Ping Time Maximum is reached for WAN0 or WAN1.
- System Log Events will now log if an NVRAM Check Failure occured with CHECKNVRAM Enabled.
- Email Notifications will now display if QoS ATM is enabled.
- Configuration Menu will now allow configuration of all QoS Settings.
- Configuration Mode will now go straight to Configuration Menu when using command argument "config".
- Restart Services will now restart all processes consecutively without waiting for them to complete to reduce failover/failback time.
- Improvements to Update Mode for version checks
- Update Mode will now check checksum to ensure integrity of WAN Failover.
Fixes:
- Removed VPNMON-R2 integration. VPNMON-R2 is now capable of detecting failover events and resetting itself without WAN Failover.
- Resolved issue where some Failback emails were not being generated
- Resolved issue where WAN Failover was logging that QoS settings were being applied and restarting services if the non-Primary WAN failed during monitoring
- Various fixes to improve reliability and integrity of script.
- Monitor and Capture Mode will no longer show messages from tail command stating the file path has changed.
- Fixed Restart Mode not killing all PIDs.
- Added a check if WAN was changed by router firmware before making it to Failover function so it doesn't attempt to switch back Primary WAN to a down WAN interface.
- Fixed an issue where Installation would not create the WAN0_QOS_OBW configuration setting.
Deprecated:
- Removed Email Configuration Mode, use Configuration Menu to change Email Notification Settings.
New Status Console Example:
Note: To change the refresh interval, go to the Configuration Menu and modify the Status Check Setting
Last edited: