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!

These are my WAN1 settings:
Unbenannt.png
 
It's in State 2 according to logs which is Connected and Dual WAN Mode will show this as "Hot-Standby" as opposed to "Cold-Standby" when it is the Secondary WAN and not Primary, that is correct. The problem is the inability to ping 1.1.1.1 out of WAN1.
I don't see it log creating the Routing Table default route for Table 200 or IP Rule for Target IP 1.1.1.1 for WAN1, it checks WAN1 for a null / 0.0.0.0 IP and then immediately goes to pinging it. Run these commands and verify that those prereqs are in place.

Code:
ip route show default table 200
ip rule list
 
Here is the output:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# ip route show default table 200
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule list
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
 
Here is the output:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# ip route show default table 200
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule list
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
That's while WAN Failover script is running? It logged saying it created the IP Rule for 8.8.8.8 but I don't see it in there, it logged it successfully created it and didn't have an error. The script will delete the rules when it is terminated/killed.
 
Sorry, no. I run these commands after I uninstalled the script.

Now, I re-installed the latest beta and run these commands again, here is the output: ( I chose 9.9.9.9 as the ping target now for WAN1)

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# ip route show default table 200
default via 192.168.8.1 dev eth7
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule list
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
admin@RT-AC86U-9AD0:/tmp/home/root#

admin@RT-AC86U-9AD0:/tmp/home/root# ip route show default table 200
default via 192.168.8.1 dev eth7
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule list
0:      from all lookup local
100:    from all to 8.8.8.8 iif lo oif ppp0 lookup wan0
100:    from all to 9.9.9.9 iif lo oif eth7 lookup wan1
32766:  from all lookup main
32767:  from all lookup default
admin@RT-AC86U-9AD0:/tmp/home/root#
 
Last edited:
Sorry, no. I run these commands after I uninstalled the script.

Now, I re-installed the latest beta and run these commands again, here is the output:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# ip route show default table 200
default via 192.168.8.1 dev eth7
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule list
0:      from all lookup local
32766:  from all lookup main
32767:  from all lookup default
admin@RT-AC86U-9AD0:/tmp/home/root#

admin@RT-AC86U-9AD0:/tmp/home/root# ip route show default table 200
default via 192.168.8.1 dev eth7
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule list
0:      from all lookup local
100:    from all to 8.8.8.8 iif lo oif ppp0 lookup wan0
100:    from all to 9.9.9.9 iif lo oif eth7 lookup wan1
32766:  from all lookup main
32767:  from all lookup default
admin@RT-AC86U-9AD0:/tmp/home/root#
Ok try this, add this IP Rule manually and see if you can ping out of WAN1.
Code:
ip rule add from all iif lo to 9.9.9.9 lookup wan1 priority 100

Ping using this command:
Code:
ping -I eth7 9.9.9.9

Delete test rule:
Code:
ip rule del from all iif lo to 9.9.9.9 lookup wan1 priority 100
 
Here is the output while the script was running:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule add from all iif lo to 9.9.9.9 lookup wan1 priority 100
admin@RT-AC86U-9AD0:/tmp/home/root# ping -I eth7 9.9.9.9
PING 9.9.9.9 (9.9.9.9): 56 data bytes
64 bytes from 9.9.9.9: seq=2 ttl=60 time=38.196 ms
64 bytes from 9.9.9.9: seq=3 ttl=60 time=48.198 ms
64 bytes from 9.9.9.9: seq=4 ttl=60 time=48.153 ms
64 bytes from 9.9.9.9: seq=5 ttl=60 time=58.189 ms
64 bytes from 9.9.9.9: seq=6 ttl=60 time=58.180 ms
64 bytes from 9.9.9.9: seq=7 ttl=60 time=48.174 ms
64 bytes from 9.9.9.9: seq=8 ttl=60 time=45.188 ms
64 bytes from 9.9.9.9: seq=9 ttl=60 time=38.179 ms
64 bytes from 9.9.9.9: seq=10 ttl=60 time=48.202 ms
64 bytes from 9.9.9.9: seq=11 ttl=60 time=57.926 ms
^C
--- 9.9.9.9 ping statistics ---
12 packets transmitted, 10 packets received, 16% packet loss
round-trip min/avg/max = 38.179/48.858/58.189 ms

admin@RT-AC86U-9AD0:/tmp/home/root# ip rule del from all iif lo to 9.9.9.9 lookup wan1 priority 100
 
Here is the output while the script was running:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# ip rule add from all iif lo to 9.9.9.9 lookup wan1 priority 100
admin@RT-AC86U-9AD0:/tmp/home/root# ping -I eth7 9.9.9.9
PING 9.9.9.9 (9.9.9.9): 56 data bytes
64 bytes from 9.9.9.9: seq=2 ttl=60 time=38.196 ms
64 bytes from 9.9.9.9: seq=3 ttl=60 time=48.198 ms
64 bytes from 9.9.9.9: seq=4 ttl=60 time=48.153 ms
64 bytes from 9.9.9.9: seq=5 ttl=60 time=58.189 ms
64 bytes from 9.9.9.9: seq=6 ttl=60 time=58.180 ms
64 bytes from 9.9.9.9: seq=7 ttl=60 time=48.174 ms
64 bytes from 9.9.9.9: seq=8 ttl=60 time=45.188 ms
64 bytes from 9.9.9.9: seq=9 ttl=60 time=38.179 ms
64 bytes from 9.9.9.9: seq=10 ttl=60 time=48.202 ms
64 bytes from 9.9.9.9: seq=11 ttl=60 time=57.926 ms
^C
--- 9.9.9.9 ping statistics ---
12 packets transmitted, 10 packets received, 16% packet loss
round-trip min/avg/max = 38.179/48.858/58.189 ms

admin@RT-AC86U-9AD0:/tmp/home/root# ip rule del from all iif lo to 9.9.9.9 lookup wan1 priority 100
Does it still ping after deleting the test rule?
 
That's strange, what is your PACKETSIZE, PINGCOUNT, and PINGTIMEOUT set to? If it isn't set PACKETSIZE to default of 56 and PINGCOUNT maybe 10?

EDIT: Actually, since you changed WAN1 Target IP from 1.1.1.1 to 9.9.9.9 is it starting to work properly?
 
I don't know my PACKETSIZE.
During script install, I chose PINGCOUNT=3, PINGTIMEOUT=1
 
I don't know my PACKETSIZE.
During script install, I chose PINGCOUNT=3, PINGTIMEOUT=1
Read my edit to that comment and that means it's default 56.
 
It's not working, regardless of which target IP adress I chose.
I did not change any defaults.

Another, maybe useful information. When I manually switch to WAN1, my router does not get a public WAN IP. I think the LTE USB stick is getting a public WAN IP and my router a local 192.168.x.x IP. Does this help maybe?
 
It's not working, regardless of which target IP adress I chose.

Another, maybe useful information. When I manually switch to WAN1, my router does not get a public WAN IP. I think the LTE USB stick is getting a public WAN IP and my router a local 192.168.x.x IP. Does this help maybe?
The Double NAT shouldn't be an issue but the MTU you need to make sure you have it specified for that WAN Interface.
1660402399664.png
 
I think the MTU is not the problem.

Another approach, I just switched my primary WAN to USB and secondary WAN to WAN.

Unbenannt.png


And tried to install the latest beta:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# /usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta14.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jff
s/scripts/wan-failover.sh install
wan-failover.sh - Install Mode
Press any key to continue to install...Administration > System > Enable JFFS custom scripts and configs is enabled...
Creating /jffs/configs/wan-failover.conf...
/jffs/configs/wan-failover.conf created.
Setting Custom Variables...
***WAN Target IP Addresses will be routed via WAN Gateway dev WAN Interface***
Configure WAN0 Target IP Address - Will be routed via 0.0.0.0 dev eth7: 8.8.8.8
Configure WAN1 Target IP Address - Will be routed via 88.116.190.96 dev ppp1: 9.9.9.9
Configure Ping Count - This is how many consecutive times a ping will fail before a WAN connection is considered disconnected: 3
Configure Ping Timeout - Value is in seconds: 1
Configure WAN0 QoS Download Bandwidth - Value is in Mbps: 30
Configure WAN1 QoS Download Bandwidth - Value is in Mbps: 30
Configure WAN0 QoS Upload Bandwidth - Value is in Mbps: 20
Configure WAN1 QoS Upload Bandwidth - Value is in Mbps: 20
Adding Custom Settings to /jffs/configs/wan-failover.conf...
Custom Variables added to /jffs/configs/wan-failover.conf.
Creating Wan-Event script...
Wan-Event script already exists...
Adding wan-failover.sh to Wan-Event...
wan-failover.sh added to Wan-Event.
Creating /jffs/configs/profile.add...
/jffs/configs/profile.add already exists...
wan-failover.sh - Install: Creating Alias for /jffs/scripts/wan-failover.sh as wan-failover...
wan-failover.sh - Install: Created Alias for /jffs/scripts/wan-failover.sh as wan-failover...
admin@RT-AC86U-9AD0:/tmp/home/root# wan-failover.sh: Cron - Creating Cron Job
wan-failover.sh: Cron - Created Cron Job

I noticed 0.0.0.0 for WAN0.
Why is that?
 
I think the MTU is not the problem.

Another approach, I just switched my primary WAN to USB and secondary WAN to WAN.

View attachment 43508

And tried to install the latest beta:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# /usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta14.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jff
s/scripts/wan-failover.sh install
wan-failover.sh - Install Mode
Press any key to continue to install...Administration > System > Enable JFFS custom scripts and configs is enabled...
Creating /jffs/configs/wan-failover.conf...
/jffs/configs/wan-failover.conf created.
Setting Custom Variables...
***WAN Target IP Addresses will be routed via WAN Gateway dev WAN Interface***
Configure WAN0 Target IP Address - Will be routed via 0.0.0.0 dev eth7: 8.8.8.8
Configure WAN1 Target IP Address - Will be routed via 88.116.190.96 dev ppp1: 9.9.9.9
Configure Ping Count - This is how many consecutive times a ping will fail before a WAN connection is considered disconnected: 3
Configure Ping Timeout - Value is in seconds: 1
Configure WAN0 QoS Download Bandwidth - Value is in Mbps: 30
Configure WAN1 QoS Download Bandwidth - Value is in Mbps: 30
Configure WAN0 QoS Upload Bandwidth - Value is in Mbps: 20
Configure WAN1 QoS Upload Bandwidth - Value is in Mbps: 20
Adding Custom Settings to /jffs/configs/wan-failover.conf...
Custom Variables added to /jffs/configs/wan-failover.conf.
Creating Wan-Event script...
Wan-Event script already exists...
Adding wan-failover.sh to Wan-Event...
wan-failover.sh added to Wan-Event.
Creating /jffs/configs/profile.add...
/jffs/configs/profile.add already exists...
wan-failover.sh - Install: Creating Alias for /jffs/scripts/wan-failover.sh as wan-failover...
wan-failover.sh - Install: Created Alias for /jffs/scripts/wan-failover.sh as wan-failover...
admin@RT-AC86U-9AD0:/tmp/home/root# wan-failover.sh: Cron - Creating Cron Job
wan-failover.sh: Cron - Created Cron Job

I noticed 0.0.0.0 for WAN0.
Why is that?
Looks like it is staying in Cold State. Try issuing it a restart command.
Code:
service "restart_wan_if 0"
 
I think the MTU is not the problem.

Another approach, I just switched my primary WAN to USB and secondary WAN to WAN.

View attachment 43508

And tried to install the latest beta:

Code:
admin@RT-AC86U-9AD0:/tmp/home/root# /usr/sbin/curl -s "https://raw.githubusercontent.com/Ranger802004/asusmerlin/main/wan-failover_v1.5.6-beta14.sh" -o "/jffs/scripts/wan-failover.sh" && chmod 755 /jffs/scripts/wan-failover.sh && sh /jff
s/scripts/wan-failover.sh install
wan-failover.sh - Install Mode
Press any key to continue to install...Administration > System > Enable JFFS custom scripts and configs is enabled...
Creating /jffs/configs/wan-failover.conf...
/jffs/configs/wan-failover.conf created.
Setting Custom Variables...
***WAN Target IP Addresses will be routed via WAN Gateway dev WAN Interface***
Configure WAN0 Target IP Address - Will be routed via 0.0.0.0 dev eth7: 8.8.8.8
Configure WAN1 Target IP Address - Will be routed via 88.116.190.96 dev ppp1: 9.9.9.9
Configure Ping Count - This is how many consecutive times a ping will fail before a WAN connection is considered disconnected: 3
Configure Ping Timeout - Value is in seconds: 1
Configure WAN0 QoS Download Bandwidth - Value is in Mbps: 30
Configure WAN1 QoS Download Bandwidth - Value is in Mbps: 30
Configure WAN0 QoS Upload Bandwidth - Value is in Mbps: 20
Configure WAN1 QoS Upload Bandwidth - Value is in Mbps: 20
Adding Custom Settings to /jffs/configs/wan-failover.conf...
Custom Variables added to /jffs/configs/wan-failover.conf.
Creating Wan-Event script...
Wan-Event script already exists...
Adding wan-failover.sh to Wan-Event...
wan-failover.sh added to Wan-Event.
Creating /jffs/configs/profile.add...
/jffs/configs/profile.add already exists...
wan-failover.sh - Install: Creating Alias for /jffs/scripts/wan-failover.sh as wan-failover...
wan-failover.sh - Install: Created Alias for /jffs/scripts/wan-failover.sh as wan-failover...
admin@RT-AC86U-9AD0:/tmp/home/root# wan-failover.sh: Cron - Creating Cron Job
wan-failover.sh: Cron - Created Cron Job

I noticed 0.0.0.0 for WAN0.
Why is that?
Maybe not for this particular issue but you will 100% have connection issues if you don't specify MTU for that interface.
 
Last edited:
OK, will do, but have a look at that:
As I said I switched to my LTE USB stick as my primary wan and my regular ISP to secondary. I tried to install the latest beta:


The script says, I'm not connected to WAN0, but I am.
Yea that is normal, the router's firmware boots with WAN1 as Primary and uses failback to switch over....same thing my script does except it can't determine if your WAN0 is properly working because the router can't ping out of your USB Modem. Try adjusting PINGTIMEOUT to 10 and test please.

EDIT: Make sure that MTU value is set properly before you do any further network testing.

  1. Aug 13 17:13:00 wan-failover.sh: Debug - Default Route: default via 88.116.190.96 dev ppp1
  2. Aug 13 17:13:00 wan-failover.sh: Debug - WAN1 Primary Status: 1
 
OK, here is the output:


And:


Thank you for your patience, but I give up now.
 
Last edited:

Similar 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!
Top