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!

Are these the correct settings in Dual-WAN?:
Unbenannt.png
 
I lied, I didn’t get an infinite number of mail, but 14. Then everything stopped. After 20 minutes, I inserted a 4g modem into my wan1 Chinese router and received 1 more mail about recovery;)
Yea @Stephen Harrington and I have been trying to work on that, the router has a delay on recognizing the modem has been unplugged.
 
V1.5.6-Beta12 Firmware - Failover/Failback Mode:

Test#01:
1. ISP01 (Primary WAN - Connected), ISP02 (Secondary WAN - Hot-Standby)
2. Power off ISP01
3. Failover to ISP02 - Failover SUCCESS, YazFi SUCCESS, AMTM email SUCCESS
4. ISP01 (Primary WAN) - Down/No ISP | ISP02 (Secondary WAN - Connected)


Test#02:
1. Power Up ISP01
2. Failback to ISP01 (Primary WAN - Connected), ISP02 (Secondary WAN - Hot Standby)
3. Failback SUCCESS, YazFi SUCCESS, AMTM email SUCCESS


FailOver Mode work great for me @Ranger802004 , thanks!
 
Thank you for reply.
Please, how can I put the script into debugging mode?
Because I see only logs from the booting time.
I mention I have syslogng for logging with logging file in opt var log messages

Thank you!
Enable Debug logging on the Syslog page and that should allow all of the debug logging to start generating
 
I am very glad that it works for you and that in fact you get too much. But I state the fact that neither more nor less works for me.
It took me a minute but I see why yours is not working, you're in Load Balance Mode and the loop is ending instead of properly running the failover cycles which includes the email. Your configuration is being reset properly in WAN Status though, I'm going to DM you.
 
Tell me please. Surely someone here knows how to do this. If it is possible to implement without enabling the load balancing mode.
Given: ax88 with main line ,backup line and Dual WAN Failover Script

To ALWAYS have access to a device connected to WAN1 (its ip is 10.100.0.1), it is enough to enter this command or run Dual WAN Failover Script.
iptables -t nat -A POSTROUTING -o eth2 ! -s 10.100.0.0/24 -j MASQUERADE

Without this command or without a running script, access to the device starts working only when wan0 is turned off and wan1 is active.

But, a 4g modem is inserted into this device, which of course has its own subnet, its ip is 100.100.10.1. So it does not work so that I can go into the settings of this modem. Or rather, in the same way, when wan1 is active, then everything is OK, but in such a way that wan0 is active, and wan1 is in reserve, it is impossible to enter the modem interface.
Changing the previous command (replacing 0 with 10) does not help, nothing works. Tell me pliz, is it possible to make it so that you can go to a 4g modem inserted into a device that is in a standby state.

If it's not possible to do this without enabling load balancing mode, is it possible to make it so that 100% of the traffic in balancing mode goes through wan0 except what is precisely directed in wan1?

I apologize for the offtopic.
 
Last edited:
Tell me please. Surely someone here knows how to do this. If it is possible to implement without enabling the load balancing mode.
Given: ax88 with main line ,backup line and Dual WAN Failover Script

To ALWAYS have access to a device connected to WAN1 (its ip is 10.100.0.1), it is enough to enter this command or run Dual WAN Failover Script.
iptables -t nat -A POSTROUTING -o eth2 ! -s 10.100.0.0/24 -j MASQUERADE

Without this command or without a running script, access to the device starts working only when wan0 is turned off and wan1 is active.

But, a 4g modem is inserted into this device, which of course has its own subnet, its ip is 100.100.10.1. So it does not work so that I can go into the settings of this modem. Or rather, in the same way, when wan1 is active, then everything is OK, but in such a way that wan0 is active, and wan1 is in reserve, it is impossible to enter the modem interface.
Changing the previous command (replacing 0 with 10) does not help, nothing works. Tell me pliz, is it possible to make it so that you can go to a 4g modem inserted into a device that is in a standby state.

If it's not possible to do this without enabling load balancing mode, is it possible to make it so that 100% of the traffic in balancing mode goes through wan0 except what is precisely directed in wan1?

I apologize for the offtopic.
I would recommend adding that rule to your nat-start startup script to retain it.
 
I would recommend adding that rule to your nat-start startup script to retain it.
The problem is not that. I have already added. The problem is that I can't get access to the 4g modem itself (which is inserted into a small Chinese router) :( because I don't know linux well.
 

Attachments

  • 123.jpg
    123.jpg
    47.5 KB · Views: 37
The problem is not that. I have already added. The problem is that I can't get access to the 4g modem itself (which is inserted into a small Chinese router) :( because I don't know linux well.
The router in between may be causing you issues accessing it then, you'd have to set up NAT, firewall, routing through that router to make it work for the local IP of the 4G USB Modem.
 
The router in between may be causing you issues accessing it then, you'd have to set up NAT, firewall, routing through that router to make it work for the local IP of the 4G USB Modem.
No, the problem is not there. When the backup line (wan1) is active, I can access the modem. You also wrote in the script that my router inserted into wan1 became available, I thought you knew what command you could prescribe so that he could connect the modem subnet via wan1. But I read the forums, it seems like this is only possible in balancing mode.
 
Enable Debug logging on the Syslog page and that should allow all of the debug logging to start generating
Thanks. I had this setting already set.
I had to change the system location in wan-failover.sh script to: SYSTEMLOG=" opt var log messages".
The notification is not happening every time. Maybe is something related to USB 4G stick (modem on secondary wan, hot-standby): wan1 has 70% packet loss.
We are talking about RT-AX88U. No other issue found.

Thank you!
Code:
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - wan0 Packet Loss: 0%%
Aug 10 13:57:08 src@B88X wan-failover.sh: WAN Status - wan0 has 0% packet loss
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - wan0 Status: CONNECTED
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Function: setwanstatus
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Setting parameters for wan1
Aug 10 13:57:08 src@B88X wan-failover.sh: WAN Status - wan1 enabled
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 State
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for null IP or Gateway
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for Default Route in 200
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for IP Rule to 9.9.9.9
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Recursive Ping Check: 1
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for packet loss via 9.9.9.9 - Attempt: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 Packet Loss: 70%%
Aug 10 13:57:18 src@B88X wan-failover.sh: WAN Status - wan1 has 70% packet loss
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 Status: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: setwanstatus
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: switchdns
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for DNS Switch
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Manual DNS Settings for wan0
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN1 Status for DNS Switch
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: checkiprules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for Check IP Rules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan0 NAT Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for Check IP Rules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 UPNP Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 NAT Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN0STATUS: CONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN1STATUS: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: WAN Status - Verifying WAN0
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: sendemail
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Checking if /tmp/wan-failover-mail exists
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Subject Name
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting From Name
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Email Header
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Hostname
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - DDNS Hostname: breaz.asuscomm.com
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Parameters based on Dual WAN Mode: fo
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN0 Status: CONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN1 Status: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Connecting to ipinfo.io for Active ISP
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN IP Address: 192.x.x.x
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - IPv6 IP Address:
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN Gateway IP Address: 192.x.x.1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN Interface: ppp0
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Checking if AdGuardHome is running
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Checking for Automatic or Manual DNS Settings. WAN DNS Enable: 1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Automatic DNS Servers: 192.x.x.1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - QoS Enabled: 0
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Selecting AMTM or AIProtection for Email Notification
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - AMTM Email Configuration Detected
Aug 10 13:57:20 src@B88X wan-failover.sh: Email Notification - Email Notification via amtm Sent
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - Function: wan0failovermonitor
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:20 src@B88X wan-failover.sh: WAN0 Failover Monitor - Monitoring wan0 via 4.2.2.2 for Failure
Aug 10 13:57:20 src@B88X wan-failover.sh: WAN0 Failover Monitor - Monitoring wan1 via 9.9.9.9 for Failure
 
No, the problem is not there. When the backup line (wan1) is active, I can access the modem. You also wrote in the script that my router inserted into wan1 became available, I thought you knew what command you could prescribe so that he could connect the modem subnet via wan1. But I read the forums, it seems like this is only possible in balancing mode.
Try adding this IP Rule and see if it helps.

ip rule add from all to 10.100.10.1 lookup 200
 
Thanks. I had this setting already set.
I had to change the system location in wan-failover.sh script to: SYSTEMLOG=" opt var log messages".
The notification is not happening every time. Maybe is something related to USB 4G stick (modem on secondary wan, hot-standby): wan1 has 70% packet loss.
We are talking about RT-AX88U. No other issue found.

Thank you!
Code:
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - wan0 Packet Loss: 0%%
Aug 10 13:57:08 src@B88X wan-failover.sh: WAN Status - wan0 has 0% packet loss
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - wan0 Status: CONNECTED
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Function: setwanstatus
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Setting parameters for wan1
Aug 10 13:57:08 src@B88X wan-failover.sh: WAN Status - wan1 enabled
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 State
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for null IP or Gateway
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for Default Route in 200
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for IP Rule to 9.9.9.9
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Recursive Ping Check: 1
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for packet loss via 9.9.9.9 - Attempt: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 Packet Loss: 70%%
Aug 10 13:57:18 src@B88X wan-failover.sh: WAN Status - wan1 has 70% packet loss
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 Status: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: setwanstatus
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: switchdns
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for DNS Switch
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Manual DNS Settings for wan0
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN1 Status for DNS Switch
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: checkiprules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for Check IP Rules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan0 NAT Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for Check IP Rules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 UPNP Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 NAT Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN0STATUS: CONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN1STATUS: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: WAN Status - Verifying WAN0
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: sendemail
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Checking if /tmp/wan-failover-mail exists
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Subject Name
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting From Name
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Email Header
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Hostname
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - DDNS Hostname: breaz.asuscomm.com
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Parameters based on Dual WAN Mode: fo
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN0 Status: CONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN1 Status: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Connecting to ipinfo.io for Active ISP
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN IP Address: 192.x.x.x
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - IPv6 IP Address:
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN Gateway IP Address: 192.x.x.1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN Interface: ppp0
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Checking if AdGuardHome is running
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Checking for Automatic or Manual DNS Settings. WAN DNS Enable: 1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Automatic DNS Servers: 192.x.x.1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - QoS Enabled: 0
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Selecting AMTM or AIProtection for Email Notification
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - AMTM Email Configuration Detected
Aug 10 13:57:20 src@B88X wan-failover.sh: Email Notification - Email Notification via amtm Sent
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - Function: wan0failovermonitor
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:20 src@B88X wan-failover.sh: WAN0 Failover Monitor - Monitoring wan0 via 4.2.2.2 for Failure
Aug 10 13:57:20 src@B88X wan-failover.sh: WAN0 Failover Monitor - Monitoring wan1 via 9.9.9.9 for Failure
I'll change the logic where packet loss greater than 0% and less than 100% is flagging the device as "DISCONNECTED"
 
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.
 
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.
Everything is perfect and switching and notifications and lifting the 6in4 tunnel.
 
Thanks. I had this setting already set.
I had to change the system location in wan-failover.sh script to: SYSTEMLOG=" opt var log messages".
The notification is not happening every time. Maybe is something related to USB 4G stick (modem on secondary wan, hot-standby): wan1 has 70% packet loss.
We are talking about RT-AX88U. No other issue found.

Thank you!
Code:
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - wan0 Packet Loss: 0%%
Aug 10 13:57:08 src@B88X wan-failover.sh: WAN Status - wan0 has 0% packet loss
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - wan0 Status: CONNECTED
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Function: setwanstatus
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Setting parameters for wan1
Aug 10 13:57:08 src@B88X wan-failover.sh: WAN Status - wan1 enabled
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 State
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for null IP or Gateway
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for Default Route in 200
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for IP Rule to 9.9.9.9
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Recursive Ping Check: 1
Aug 10 13:57:08 src@B88X wan-failover.sh: Debug - Checking wan1 for packet loss via 9.9.9.9 - Attempt: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 Packet Loss: 70%%
Aug 10 13:57:18 src@B88X wan-failover.sh: WAN Status - wan1 has 70% packet loss
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 Status: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: setwanstatus
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: switchdns
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for DNS Switch
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Manual DNS Settings for wan0
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN1 Status for DNS Switch
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: checkiprules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for Check IP Rules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan0 NAT Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Setting WAN0 Status for Check IP Rules
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 UPNP Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - wan1 NAT Enabled: 1
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN0STATUS: CONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN1STATUS: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: WAN Status - Verifying WAN0
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: sendemail
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Checking if /tmp/wan-failover-mail exists
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Subject Name
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting From Name
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Email Header
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Hostname
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - DDNS Hostname: breaz.asuscomm.com
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Selecting Parameters based on Dual WAN Mode: fo
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN0 Status: CONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - WAN1 Status: DISCONNECTED
Aug 10 13:57:18 src@B88X wan-failover.sh: Debug - Connecting to ipinfo.io for Active ISP
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN IP Address: 192.x.x.x
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - IPv6 IP Address:
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN Gateway IP Address: 192.x.x.1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - WAN Interface: ppp0
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Checking if AdGuardHome is running
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Checking for Automatic or Manual DNS Settings. WAN DNS Enable: 1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Automatic DNS Servers: 192.x.x.1
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - QoS Enabled: 0
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - Selecting AMTM or AIProtection for Email Notification
Aug 10 13:57:19 src@B88X wan-failover.sh: Debug - AMTM Email Configuration Detected
Aug 10 13:57:20 src@B88X wan-failover.sh: Email Notification - Email Notification via amtm Sent
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - Function: wan0failovermonitor
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - Function: nvramcheck
Aug 10 13:57:20 src@B88X wan-failover.sh: Debug - ***NVRAM Check Passed***
Aug 10 13:57:20 src@B88X wan-failover.sh: WAN0 Failover Monitor - Monitoring wan0 via 4.2.2.2 for Failure
Aug 10 13:57:20 src@B88X wan-failover.sh: WAN0 Failover Monitor - Monitoring wan1 via 9.9.9.9 for Failure
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.
 

Latest threads

Sign Up For SNBForums Daily Digest

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