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!

v1.5.6-beta5 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***
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta5.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: IPv6 6in4 Mode issues may occur from new service restart logic during failover, please test and provide debug logging data if you experience issues***

Release Notes:
v1.5.6-beta5
- 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.
- If IPv6 6in4 is being used, the script will perform a service restart.
- Corrected issue with Failure Detected log not logging if a device was unplugged or powered off from the Router while in Failover Mode.
 
Last edited:
Testing V1.5.6-beta5 Dual WAN Script in a Dual WAN FailBack mode: (errors in BOLD)

Test01:
- ISP01 goes down, ISP02 takes over in FailOver mode & YazFi is available in less than 1 minute
- ISP01 comes back up, ISP02 continues to be the main WAN, FailBack does NOT work, & YazFi is available in 1 minute and 30 seconds
- Run the "switchwan" argument with the script, and the FailBack works (did NOT work in beta4), & YazFi is available in 35 seconds

Test02:
- ISP01 goes down, ISP02 takes over in FailOver mode & YazFi is NOT available until the YazFi checks almost 7 minutes later
- ISP01 comes back up, ISP02 continues to be the main WAN, FailBack does NOT work, & YazFi is available in 1 minute and 35 seconds
- Run the "switchwan" argument with the script, and the FailBack works (did NOT work in beta4), & YazFi is available in 35 seconds
 
Testing V1.5.6-beta5 Dual WAN Script in a Dual WAN FailBack mode: (errors in BOLD)

Test01:
- ISP01 goes down, ISP02 takes over in FailOver mode & YazFi is available in less than 1 minute
- ISP01 comes back up, ISP02 continues to be the main WAN, FailBack does NOT work, & YazFi is available in 1 minute and 30 seconds
- Run the "switchwan" argument with the script, and the FailBack works (did NOT work in beta4), & YazFi is available in 35 seconds

Test02:
- ISP01 goes down, ISP02 takes over in FailOver mode & YazFi is NOT available until the YazFi checks almost 7 minutes later
- ISP01 comes back up, ISP02 continues to be the main WAN, FailBack does NOT work, & YazFi is available in 1 minute and 35 seconds
- Run the "switchwan" argument with the script, and the FailBack works (did NOT work in beta4), & YazFi is available in 35 seconds

Did you collect debug logs?
 
Did you collect debug logs?

I did, just ran Test03 with Debug Logs (Test01 had Debug Logs, and Test02 had Notice Logs)

Test03 was the same as Test01, with YazFi available every time, so I would count that as a success.

I'll see what I can get you as I have a lot of redacting to do, unless you can specify anything in particular in the logs I can find for you that might help in finding out why Failback is not working automatically as it did before.
 
I did, just ran Test03 with Debug Logs (Test01 had Debug Logs, and Test02 had Notice Logs)

Test03 was the same as Test01, with YazFi available every time, so I would count that as a success.

I'll see what I can get you as I have a lot of redacting to do, unless you can specify anything in particular in the logs I can find for you that might help in finding out why Failback is not working automatically as it did before.
I need to know if it is sitting in WAN0 Failback Monitor Loop, going to WAN Disabled, or going to WAN Status but failing for some reason. There's a lot of factors in what the script will do based on what happened for the failure. For example, being unplugged or powered off modem will delete the IP Rule / Route so the Failback Monitor will never detect the connection back online and in this case the script should go to WAN Disabled until it sees a connection and has an IP.
 
REDACTED Test03 DEBUG Log: (Part 1 of 2)

Code:
Jul 28 10:35:03 kernel: eth0 (Int switch port: 3) (Logical Port: 3) (phyId: c) Link UP at 1000 mbps full duplex
Jul 28 10:36:08 dnsmasq[13034]: read /REDACTED/hosts - 6 addresses
Jul 28 10:36:08 dnsmasq[13034]: using nameserver REDACTED#53 for domain REDACTED
Jul 28 10:36:08 dnsmasq[13034]: using nameserver REDACTED#53 for domain REDACTED
Jul 28 10:36:08 dnsmasq[13034]: using nameserver REDACTED#53
Jul 28 10:36:08 dnsmasq[13034]: using nameserver REDACTED#53
Jul 28 10:36:08 dnsmasq[13034]: using only locally-known addresses for domain REDACTED
Jul 28 10:36:08 YazFi: Firewall restarted - sleeping 10s before running YazFi
Jul 28 10:36:08 FlexQoS: /jffs/addons/flexqos/flexqos.sh (pid=17482) called in unattended mode with 1 args: -start
Jul 28 10:36:08 inadyn[17600]: In-a-dyn version 2.9.1 -- Dynamic DNS update client.
Jul 28 10:36:08 ovpn-server1[17631]: OpenVPN 2.5.7 arm-buildroot-linux-gnueabi [SSL (OpenSSL)] [LZO] [LZ4] [EPOLL] [MH/PKTINFO] [AEAD] built on Jul 24 2022
Jul 28 10:36:08 ovpn-server1[17631]: library versions: OpenSSL 1.1.1q  5 Jul 2022, LZO 2.08
Jul 28 10:36:08 ovpn-server1[17639]: NOTE: the current --script-security setting may allow this configuration to call user-defined scripts
Jul 28 10:36:08 ovpn-server1[17639]: PLUGIN AUTH-PAM: initialization succeeded (fg)
Jul 28 10:36:08 ovpn-server1[17639]: PLUGIN_INIT: POST /usr/lib/openvpn-plugin-auth-pam.so '[/usr/lib/openvpn-plugin-auth-pam.so] [openvpn]' intercepted=PLUGIN_AUTH_USER_PASS_VERIFY
Jul 28 10:36:08 ovpn-server1[17639]: Diffie-Hellman initialized with 2048 bit key
Jul 28 10:36:08 ovpn-server1[17639]: TUN/TAP device tun21 opened
Jul 28 10:36:08 ovpn-server1[17639]: TUN/TAP TX queue length set to 1000
Jul 28 10:36:08 ovpn-server1[17639]: /usr/sbin/ip link set dev tun21 up mtu 1500
Jul 28 10:36:08 vpnserver1[17643]: PLUGIN AUTH-PAM: BACKGROUND: initialization succeeded
Jul 28 10:36:08 ovpn-server1[17639]: /usr/sbin/ip link set dev tun21 up
Jul 28 10:36:08 ovpn-server1[17639]: /usr/sbin/ip addr add dev tun21 REDACTED/24
Jul 28 10:36:08 ovpn-server1[17639]: ovpn-up 1 server tun21 1500 1621 REDACTED 255.255.255.0 init
Jul 28 10:36:08 FlexQoS: iptables rules already present
Jul 28 10:36:08 ovpn-server1[17639]: Socket Buffers: R=[524288->524288] S=[524288->524288]
Jul 28 10:36:08 ovpn-server1[17639]: UDPv4 link local (bound): [AF_INET][undef]:62526
Jul 28 10:36:08 ovpn-server1[17639]: UDPv4 link remote: [AF_UNSPEC]
Jul 28 10:36:08 ovpn-server1[17639]: MULTI: multi_init called, r=256 v=256
Jul 28 10:36:08 ovpn-server1[17639]: IFCONFIG POOL IPv4: base=REDACTED size=253
Jul 28 10:36:08 ovpn-server1[17639]: Initialization Sequence Completed
Jul 28 10:36:09 FlexQoS: No TC modifications necessary
Jul 28 10:36:18 YazFi: YazFi v4.4.2 starting up
Jul 28 10:36:19 YazFi: wl0.1 (SSID: REDACTED) - sending all interface internet traffic over WAN interface
Jul 28 10:36:21 YazFi: wl0.2 (SSID: REDACTED) - sending all interface internet traffic over WAN interface
Jul 28 10:36:22 wan-failover.sh: WAN Failover Disabled - wan0 and wan1 are enabled and connected
Jul 28 10:36:22 wan-failover.sh: WAN Failover Disabled - Returning to check WAN Status
 
Last edited:
REDACTED Test03 DEBUG Log: (Part 2 of 2)

Code:
Jul 28 10:36:22 wan-failover.sh: Debug - ***WAN Disabled Loop Ended***
Jul 28 10:36:22 wan-failover.sh: Debug - Function: debuglog
Jul 28 10:36:22 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:22 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:22 wan-failover.sh: Debug - Dual WAN Mode: fo
Jul 28 10:36:22 wan-failover.sh: Debug - Dual WAN Interfaces: wan lan
Jul 28 10:36:22 wan-failover.sh: Debug - ASUS Factory Watchdog: 0
Jul 28 10:36:22 wan-failover.sh: Debug - Firewall Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - LEDs Disabled: 0
Jul 28 10:36:22 wan-failover.sh: Debug - QoS Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - DDNS Hostname: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - LAN Hostname: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN IPv6 Service: disabled
Jul 28 10:36:22 wan-failover.sh: Debug - WAN IPv6 Address:
Jul 28 10:36:22 wan-failover.sh: Debug - Default Route: default via REDACTED dev eth4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Routing Table Default Route:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Target IP Rule:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 IP Address: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Real IP Address:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Real IP Address State: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Gateway IP: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Gateway Interface: eth0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Interface: eth0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Automatic ISP DNS Enabled: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Automatic ISP DNS Servers: REDACTED REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Manual DNS Server 1: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Manual DNS Server 2: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 State: 2
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Primary Status: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 USB Modem Status: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Target IP Address: 8.8.8.8
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Routing Table: 100
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 IP Rule Priority: 100
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Mark: 0x80000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Mask: 0xf0000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 From WAN Priority: 200
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 To WAN Priority: 400
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Routing Table Default Route:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Target IP Rule:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 IP Address: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Real IP Address: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Real IP Address State: 2
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Gateway IP: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Gateway Interface: eth4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Interface: eth4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Automatic ISP DNS Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Automatic ISP DNS Servers: REDACTED REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Manual DNS Server 1:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Manual DNS Server 2:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 State: 2
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Primary Status: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 USB Modem Status: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Target IP Address: 8.8.4.4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Routing Table: 200
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 IP Rule Priority: 100
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Mark: 0x90000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Mask: 0xf0000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 From WAN Priority: 200
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 To WAN Priority: 400
Jul 28 10:36:22 wan-failover.sh: Debug - Function: wanstatus
Jul 28 10:36:22 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:22 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:22 wan-failover.sh: Debug - System Uptime: 318462 Seconds
Jul 28 10:36:22 wan-failover.sh: Debug - Boot Delay Timer: 60 Seconds
Jul 28 10:36:22 wan-failover.sh: WAN Status - wan0 enabled
Jul 28 10:36:23 wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via REDACTED dev eth0
Jul 28 10:36:23 wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via REDACTED dev eth0
Jul 28 10:36:23 wan-failover.sh: WAN Status - Adding IP Rule for 8.8.8.8 to monitor wan0
Jul 28 10:36:23 wan-failover.sh: WAN Status - Added IP Rule for 8.8.8.8 to monitor wan0
Jul 28 10:36:23 wan-failover.sh: Debug - Recursive Ping Check: 1
Jul 28 10:36:23 wan-failover.sh: Debug - Checking wan0 for packet loss via 8.8.8.8 - Attempt: 1
Jul 28 10:36:25 YazFi: Forcing YazFi Guest WiFi clients to reauthenticate
Jul 28 10:36:25 REDACTED
Jul 28 10:36:29 wan-failover.sh: Debug - wan0 Packet Loss: 100%%
Jul 28 10:36:29 wan-failover.sh: WAN Status - wan0 has 100% packet loss ***Verify 8.8.8.8 is a valid server for ICMP Echo Requests***
Jul 28 10:36:29 wan-failover.sh: Debug - wan0 Status: DISCONNECTED
Jul 28 10:36:29 wan-failover.sh: Debug - Function: setwanstatus
Jul 28 10:36:29 wan-failover.sh: WAN Status - wan1 enabled
Jul 28 10:36:29 wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via REDACTED dev eth4
Jul 28 10:36:29 wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via REDACTED dev eth4
Jul 28 10:36:29 wan-failover.sh: WAN Status - Adding IP Rule for 8.8.4.4 to monitor wan1
Jul 28 10:36:29 wan-failover.sh: WAN Status - Added IP Rule for 8.8.4.4 to monitor wan1
Jul 28 10:36:29 wan-failover.sh: Debug - Recursive Ping Check: 1
Jul 28 10:36:29 wan-failover.sh: Debug - Checking wan1 for packet loss via 8.8.4.4 - Attempt: 1
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 Packet Loss: 0%%
Jul 28 10:36:33 wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 Status: CONNECTED
Jul 28 10:36:33 wan-failover.sh: Debug - Function: setwanstatus
Jul 28 10:36:33 wan-failover.sh: Debug - Function: checkiprules
Jul 28 10:36:33 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:33 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 UPNP Enabled: 1
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 NAT Enabled: 1
Jul 28 10:36:33 wan-failover.sh: Debug - WAN0STATUS: DISCONNECTED
Jul 28 10:36:33 wan-failover.sh: Debug - WAN1STATUS: CONNECTED
Jul 28 10:36:33 wan-failover.sh: Debug - Function: wan0failbackmonitor
Jul 28 10:36:33 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:33 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:33 wan-failover.sh: WAN0 Failback Monitor - Verifying WAN1
Jul 28 10:36:33 wan-failover.sh: WAN0 Failback Monitor - Monitoring wan1 via 8.8.4.4 for Failure
Jul 28 10:36:33 wan-failover.sh: WAN0 Failback Monitor - Monitoring wan0 via 8.8.8.8 for Restoration
Jul 28 10:36:35 REDACTED
Jul 28 10:36:40 YazFi: YazFi v4.4.2 completed successfully
Jul 28 10:36:40 REDACTED
 
REDACTED Test03 DEBUG Log: (Part 2 of 2)

Code:
Jul 28 10:36:22 wan-failover.sh: Debug - ***WAN Disabled Loop Ended***
Jul 28 10:36:22 wan-failover.sh: Debug - Function: debuglog
Jul 28 10:36:22 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:22 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:22 wan-failover.sh: Debug - Dual WAN Mode: fo
Jul 28 10:36:22 wan-failover.sh: Debug - Dual WAN Interfaces: wan lan
Jul 28 10:36:22 wan-failover.sh: Debug - ASUS Factory Watchdog: 0
Jul 28 10:36:22 wan-failover.sh: Debug - Firewall Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - LEDs Disabled: 0
Jul 28 10:36:22 wan-failover.sh: Debug - QoS Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - DDNS Hostname: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - LAN Hostname: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN IPv6 Service: disabled
Jul 28 10:36:22 wan-failover.sh: Debug - WAN IPv6 Address:
Jul 28 10:36:22 wan-failover.sh: Debug - Default Route: default via REDACTED dev eth4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Routing Table Default Route:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Target IP Rule:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 IP Address: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Real IP Address:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Real IP Address State: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Gateway IP: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Gateway Interface: eth0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Interface: eth0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Automatic ISP DNS Enabled: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Automatic ISP DNS Servers: REDACTED REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Manual DNS Server 1: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Manual DNS Server 2: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 State: 2
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Primary Status: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 USB Modem Status: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Target IP Address: 8.8.8.8
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Routing Table: 100
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 IP Rule Priority: 100
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Mark: 0x80000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 Mask: 0xf0000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 From WAN Priority: 200
Jul 28 10:36:22 wan-failover.sh: Debug - WAN0 To WAN Priority: 400
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Routing Table Default Route:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Target IP Rule:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 IP Address: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Real IP Address: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Real IP Address State: 2
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Gateway IP: REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Gateway Interface: eth4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Interface: eth4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Automatic ISP DNS Enabled: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Automatic ISP DNS Servers: REDACTED REDACTED
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Manual DNS Server 1:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Manual DNS Server 2:
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 State: 2
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Primary Status: 1
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 USB Modem Status: 0
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Target IP Address: 8.8.4.4
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Routing Table: 200
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 IP Rule Priority: 100
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Mark: 0x90000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 Mask: 0xf0000000
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 From WAN Priority: 200
Jul 28 10:36:22 wan-failover.sh: Debug - WAN1 To WAN Priority: 400
Jul 28 10:36:22 wan-failover.sh: Debug - Function: wanstatus
Jul 28 10:36:22 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:22 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:22 wan-failover.sh: Debug - System Uptime: 318462 Seconds
Jul 28 10:36:22 wan-failover.sh: Debug - Boot Delay Timer: 60 Seconds
Jul 28 10:36:22 wan-failover.sh: WAN Status - wan0 enabled
Jul 28 10:36:23 wan-failover.sh: WAN Status - Adding default route for wan0 Routing Table via REDACTED dev eth0
Jul 28 10:36:23 wan-failover.sh: WAN Status - Added default route for wan0 Routing Table via REDACTED dev eth0
Jul 28 10:36:23 wan-failover.sh: WAN Status - Adding IP Rule for 8.8.8.8 to monitor wan0
Jul 28 10:36:23 wan-failover.sh: WAN Status - Added IP Rule for 8.8.8.8 to monitor wan0
Jul 28 10:36:23 wan-failover.sh: Debug - Recursive Ping Check: 1
Jul 28 10:36:23 wan-failover.sh: Debug - Checking wan0 for packet loss via 8.8.8.8 - Attempt: 1
Jul 28 10:36:25 YazFi: Forcing YazFi Guest WiFi clients to reauthenticate
Jul 28 10:36:25 REDACTED
Jul 28 10:36:29 wan-failover.sh: Debug - wan0 Packet Loss: 100%%
Jul 28 10:36:29 wan-failover.sh: WAN Status - wan0 has 100% packet loss ***Verify 8.8.8.8 is a valid server for ICMP Echo Requests***
Jul 28 10:36:29 wan-failover.sh: Debug - wan0 Status: DISCONNECTED
Jul 28 10:36:29 wan-failover.sh: Debug - Function: setwanstatus
Jul 28 10:36:29 wan-failover.sh: WAN Status - wan1 enabled
Jul 28 10:36:29 wan-failover.sh: WAN Status - Adding default route for wan1 Routing Table via REDACTED dev eth4
Jul 28 10:36:29 wan-failover.sh: WAN Status - Added default route for wan1 Routing Table via REDACTED dev eth4
Jul 28 10:36:29 wan-failover.sh: WAN Status - Adding IP Rule for 8.8.4.4 to monitor wan1
Jul 28 10:36:29 wan-failover.sh: WAN Status - Added IP Rule for 8.8.4.4 to monitor wan1
Jul 28 10:36:29 wan-failover.sh: Debug - Recursive Ping Check: 1
Jul 28 10:36:29 wan-failover.sh: Debug - Checking wan1 for packet loss via 8.8.4.4 - Attempt: 1
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 Packet Loss: 0%%
Jul 28 10:36:33 wan-failover.sh: WAN Status - wan1 has 0% packet loss
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 Status: CONNECTED
Jul 28 10:36:33 wan-failover.sh: Debug - Function: setwanstatus
Jul 28 10:36:33 wan-failover.sh: Debug - Function: checkiprules
Jul 28 10:36:33 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:33 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 UPNP Enabled: 1
Jul 28 10:36:33 wan-failover.sh: Debug - wan1 NAT Enabled: 1
Jul 28 10:36:33 wan-failover.sh: Debug - WAN0STATUS: DISCONNECTED
Jul 28 10:36:33 wan-failover.sh: Debug - WAN1STATUS: CONNECTED
Jul 28 10:36:33 wan-failover.sh: Debug - Function: wan0failbackmonitor
Jul 28 10:36:33 wan-failover.sh: Debug - Function: nvramcheck
Jul 28 10:36:33 wan-failover.sh: Debug - ***NVRAM Check Passed***
Jul 28 10:36:33 wan-failover.sh: WAN0 Failback Monitor - Verifying WAN1
Jul 28 10:36:33 wan-failover.sh: WAN0 Failback Monitor - Monitoring wan1 via 8.8.4.4 for Failure
Jul 28 10:36:33 wan-failover.sh: WAN0 Failback Monitor - Monitoring wan0 via 8.8.8.8 for Restoration
Jul 28 10:36:35 REDACTED
Jul 28 10:36:40 YazFi: YazFi v4.4.2 completed successfully
Jul 28 10:36:40 REDACTED
Hmmm looks like it went to Disabled state, then came back out of Disabled state and added the route and rule but never was able to ping out of eth0. But a switchwan and it was working you said? For some reason your router was unable to communicate out of WAN0 until it was primary WAN. Get it back into this state again and try and ping manually using the following command.
Code:
ping -I eth0 8.8.8.8
 
Hmmm looks like it went to Disabled state, then came back out of Disabled state and added the route and rule but never was able to ping out of eth0. But a switchwan and it was working you said? For some reason your router was unable to communicate out of WAN0 until it was primary WAN. Get it back into this state again and try and ping manually using the following command.
Code:
ping -I eth0 8.8.8.8

Before going my full Test route, I decided to just run

Code:
//jffs/scripts/wan-failover.sh switchwan

Which switched over to my ISP02, and then ran your test ping, and no response from eth0. Reran the "switchwan", and I was able to ping eth0 again.
 
So my Iface for ISP01 is eth0, and for ISP02 is eth4, and when ISP01 is Primary WAN(Connected), and ISP02 is Secondary WAN (Hot-Standby), you can ping 8.8.8.8 via eth0, but NOT eth4.

After using

Code:
//jffs/scripts/wan-failover.sh switchwan

ISP01 is Primary WAN(Hot-Standby), and ISP02 is Secondary WAN(Connected), you can ping 8.8.8.8 via eth4, but NOT eth0.
 
So my Iface for ISP01 is eth0, and for ISP02 is eth4, and when ISP01 is Primary WAN(Connected), and ISP02 is Secondary WAN (Hot-Standby), you can ping 8.8.8.8 via eth0, but NOT eth4.

After using

Code:
//jffs/scripts/wan-failover.sh switchwan

ISP01 is Primary WAN(Hot-Standby), and ISP02 is Secondary WAN(Connected), you can ping 8.8.8.8 via eth4, but NOT eth0.
Send me this when it's not performing failback to WAN01 like it is suppose to please, I think I have an idea on what's going on. You can DM if necessary for privacy reasons.
Code:
ip rule list | grep -e "8.8.8.8"
ip route show default table 100
 
Send me this when it's not performing failback to WAN01 like it is suppose to please, I think I have an idea on what's going on. You can DM if necessary for privacy reasons.
Code:
ip rule list | grep -e "8.8.8.8"
ip route show default table 100
I run both of those commands and both are blank, or return no output
 
v1.5.6-beta6 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***
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta6.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: IPv6 6in4 Mode issues may occur from new service restart logic during failover, please test and provide debug logging data if you experience issues***

Release Notes:
v1.5.6-beta6
- 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.
- If IPv6 6in4 is being used, the script will perform a service restart.
- Corrected issue with Failure Detected log not logging if a device was unplugged or powered off from the Router while in Failover Mode.
 
v1.5.6-beta6 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***
Code:
/usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta6.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: IPv6 6in4 Mode issues may occur from new service restart logic during failover, please test and provide debug logging data if you experience issues***

Release Notes:
v1.5.6-beta6
- 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.
- If IPv6 6in4 is being used, the script will perform a service restart.
- Corrected issue with Failure Detected log not logging if a device was unplugged or powered off from the Router while in Failover Mode.
Hi,

Could you please make a list with requirement entware packages to be installed?

I changed my entware and I suppose that I do not have all the packages installed. I am stuck in Secondary WAN connected and Primary WAN Hot-Standby.
When I try manualy switch wan I get:
Code:
/wan-failover.sh switchwan
wan-failover.sh - Switch WAN Mode
"ip rule show" does not take any arguments.
"ip rule show" does not take any arguments.
wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
wan-failover.sh: WAN Switch - WAN IP Address: x.x.x.x
wan-failover.sh: WAN Switch - WAN Gateway IP: 10.0.0.1
wan-failover.sh: WAN Switch - Deleting default route via 192.168.7.1 dev eth8
wan-failover.sh: WAN Switch - Deleting default route via 192.168.7.1 dev eth8
RTNETLINK answers: No such process
Thank you,
amplatfus
 
Last edited:
Hi,

Could you please make a list with requirement entware packages to be installed?

I changed my entware and I suppose that I do not have all the packages installed. I am stuck in Secondary WAN connected and Primary WAN Hot-Standby.
When I try manualy switch wan I get:
Code:
/wan-failover.sh switchwan
wan-failover.sh - Switch WAN Mode
"ip rule show" does not take any arguments.
"ip rule show" does not take any arguments.
wan-failover.sh: WAN Switch - Switching wan0 to Primary WAN
wan-failover.sh: WAN Switch - WAN IP Address: x.x.x.x
wan-failover.sh: WAN Switch - WAN Gateway IP: 10.0.0.1
wan-failover.sh: WAN Switch - Deleting default route via 192.168.7.1 dev eth8
wan-failover.sh: WAN Switch - Deleting default route via 192.168.7.1 dev eth8
RTNETLINK answers: No such process
Thank you,
amplatfus

It shouldn’t require any Entware packages, do you have the ip-full package installed from Entware? It is older than the stock firmware and will give those errors. The script should be using system binaries over the Entware installed ones thought. What router and firmware are you on?
 
It shouldn’t require any Entware packages, do you have the ip-full package installed from Entware? It is older than the stock firmware and will give those errors. The script should be using system binaries over the Entware installed ones thought. What router and firmware are you on?
Thank you. RT-AX88U, Firmware Version:386.7_2
 
Yes. Should I uninstall it?
The script should use the system binaries over that one but that package is now older than what you get with the built in firmware so personally I would. That error you are getting is a known issue with older versions of ip binaries as well.
 
Last edited:

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