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!

WAN0TARGET="$(nvram get wan0_dns | awk '{print $1}')"
WAN1TARGET="$(nvram get wan1_gateway)"
My wife is using internet.. When I can ill do a sh +x, and kill my primary line see if I can see something.
 
WAN0TARGET="$(nvram get wan0_dns | awk '{print $1}')"
WAN1TARGET="$(nvram get wan1_gateway)"
Send your script over and let me take a look, somewhere it is trying to grep but doesn’t have a parameter set like -e? Perhaps the script status check at the top?
 
Send your script over and let me take a look, somewhere it is trying to grep but doesn’t have a parameter set like -e? Perhaps the script status check at the top?
If you run diff, youll see nothings really been changed.
 

Attachments

  • wan.txt
    12.3 KB · Views: 100
If you run diff, youll see nothings really been changed.
I’m not home atm, run diff and send me the output please.
 
I’m not home atm, run diff and send me the output please.
admin@RT-AX86U-D7D0:/jffs/scripts# diff original wan2
--- original
+++ wan2
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh

# Author: Ranger802004
# Version 1.1
@@ -32,7 +32,7 @@
DNSRESOLVFILE="/tmp/resolv.conf"

#Ping Target for failure detections, must be routed over targeted interface
-WAN0TARGET="$(nvram get wan0_dns1_x)"
+WAN0TARGET="$(nvram get wan0_dns | awk '{print $1}')"
WAN1TARGET="$(nvram get wan1_gateway)"

#Ping count before WAN is considered down, requires 100% Packet Loss.
@@ -45,11 +45,11 @@

#QoS Manual Settings Variables
#QoS Inbound Bandwidth - Values are in Kbps
-WAN0_QOS_IBW=972800
-WAN1_QOS_IBW=97280
+WAN0_QOS_IBW=2972800
+WAN1_QOS_IBW=2297280
#QoS Outbound Bandwidth - Values are in Kbps
-WAN0_QOS_OBW=972800
-WAN1_QOS_OBW=5120
+WAN0_QOS_OBW=22972800
+WAN1_QOS_OBW=225120
#QoS WAN Packet Overhead - Values are in Bytes
WAN0_QOS_OVERHEAD=42
WAN1_QOS_OVERHEAD=18
@@ -311,7 +311,7 @@
# Trigger WAN Event
wanevent ()
{
-/jffs/scripts/wan-event
+#/jffs/scripts/wan-event
wanstatus
}
scriptstatus
 
admin@RT-AX86U-D7D0:/jffs/scripts# diff original wan2
--- original
+++ wan2
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/sh

# Author: Ranger802004
# Version 1.1
@@ -32,7 +32,7 @@
DNSRESOLVFILE="/tmp/resolv.conf"

#Ping Target for failure detections, must be routed over targeted interface
-WAN0TARGET="$(nvram get wan0_dns1_x)"
+WAN0TARGET="$(nvram get wan0_dns | awk '{print $1}')"
WAN1TARGET="$(nvram get wan1_gateway)"

#Ping count before WAN is considered down, requires 100% Packet Loss.
@@ -45,11 +45,11 @@

#QoS Manual Settings Variables
#QoS Inbound Bandwidth - Values are in Kbps
-WAN0_QOS_IBW=972800
-WAN1_QOS_IBW=97280
+WAN0_QOS_IBW=2972800
+WAN1_QOS_IBW=2297280
#QoS Outbound Bandwidth - Values are in Kbps
-WAN0_QOS_OBW=972800
-WAN1_QOS_OBW=5120
+WAN0_QOS_OBW=22972800
+WAN1_QOS_OBW=225120
#QoS WAN Packet Overhead - Values are in Bytes
WAN0_QOS_OVERHEAD=42
WAN1_QOS_OVERHEAD=18
@@ -311,7 +311,7 @@
# Trigger WAN Event
wanevent ()
{
-/jffs/scripts/wan-event
+#/jffs/scripts/wan-event
wanstatus
}
scriptstatus
Did you change something with the ping count or timeout? Go ahead and run this command and send me the output.

nvram show | grep -e “wan”
 
Last edited:
You need wan1_dns populated, most likely.
Shouldn’t unless he is targeting it for his ping target. The switch wan will check that variable and then go to dns1_x and dns2_x variables. Unless both of those are blank as well should be fine.
 
Shouldn’t unless he is targeting it for his ping target. The switch wan will check that variable and then go to dns1_x and dns2_x variables. Unless both of those are blank as well should be fine.
@Ranger802004 and @dave14305 , right now I just have dual wan set in the UI, with nothing setup for ping,dns,etc while trying the script. Besides that ranger as you can see, i didnt change much at all in the script. I can give you the output of nvram if you tell me exactly what your looking for. wan1_dns points to the secondary modem ip right now. As does nvram get wan1_gateway
 
@Ranger802004 and @dave14305 , right now I just have dual wan set in the UI, with nothing setup for ping,dns,etc while trying the script. Besides that ranger as you can see, i didnt change much at all in the script. I can give you the output of nvram if you tell me exactly what your looking for. wan1_dns points to the secondary modem ip right now. As does nvram get wan1_gateway
I’m just looking for if any of the variables used throughout the script are blank.
 
@Ranger802004 and @dave14305 , right now I just have dual wan set in the UI, with nothing setup for ping,dns,etc while trying the script. Besides that ranger as you can see, i didnt change much at all in the script. I can give you the output of nvram if you tell me exactly what your looking for.
Code:
nvram show 2>/dev/null | grep -E "^wan[01]?_dns|^wan[01]?_ifname"
I’m just trying to understand your grep problem.
 
Code:
nvram show 2>/dev/null | grep -E "^wan[01]?_dns|^wan[01]?_ifname"
I’m just trying to understand your grep problem.
I only saw it when it switch to wan1, but I cannot test failover for now.

admin@RT-AX86U-D7D0:/jffs/scripts# nvram show 2>/dev/null | grep -E "^wan[01]?_dns|^wan[01]?_ifname"
wan0_dns=1.1.1.1 8.8.8.8
wan0_dns1_x=1.1.1.1
wan0_dns2_x=
wan0_dnsenable_x=1
wan0_ifname=eth0
wan1_dns=192.168.10.1
wan1_dns1_x=1.1.1.1
wan1_dns2_x=
wan1_dnsenable_x=1
wan1_ifname=eth5
wan_dns=192.168.10.1
wan_dns1_x=1.1.1.1
wan_dns2_x=
wan_dnsenable_x=1
wan_ifname=eth5
wan_ifnames=eth0 eth5
 
Did you change something with the ping count or timeout? Go ahead and run this command and send me the output.

nvram show | grep -e “wan”
I sent the diff, i didnt touch any of that.

admin@RT-AX86U-D7D0:/jffs/scripts# nvram show | grep -e “wan”
size: 74666 bytes (56406 left)
admin@RT-AX86U-D7D0:/jffs/scripts#
 
I only saw it when it switch to wan1, but I cannot test failover for now.

admin@RT-AX86U-D7D0:/jffs/scripts# nvram show 2>/dev/null | grep -E "^wan[01]?_dns|^wan[01]?_ifname"
wan0_dns=1.1.1.1 8.8.8.8
wan0_dns1_x=1.1.1.1
wan0_dns2_x=
wan0_dnsenable_x=1
wan0_ifname=eth0
wan1_dns=192.168.10.1
wan1_dns1_x=1.1.1.1
wan1_dns2_x=
wan1_dnsenable_x=1
wan1_ifname=eth5
wan_dns=192.168.10.1
wan_dns1_x=1.1.1.1
wan_dns2_x=
wan_dnsenable_x=1
wan_ifname=eth5
wan_ifnames=eth0 eth5
I have a clue on the problem and can test and add some logic for it later, do this in the meantime and test, assign a second DNS server to your WAN1 interface and see if gets rid of the error.
 
I have a clue on the problem and can test and add some logic for it later, do this in the meantime and test, assign a second DNS server to your WAN1 interface and see if gets rid of the error.
sorry but I assume, this will work for now?

admin@RT-AX86U-D7D0:/jffs/scripts# nvram set wan1_dns2_x=8.8.8.8
admin@RT-AX86U-D7D0:/jffs/scripts# nvram set wan0_dns2_x=8.8.8.8
 
sorry but I assume, this will work for now?

admin@RT-AX86U-D7D0:/jffs/scripts# nvram set wan1_dns2_x=8.8.8.8
admin@RT-AX86U-D7D0:/jffs/scripts# nvram set wan0_dns2_x=8.8.8.8
Yea should work as a temp fix until I can update the script this weekend.
 
There seems to be a misplaced/misused & in the middle of the until condition in switchwan().
and.png


Is that what your seeing?
 

Latest threads

Support SNBForums w/ Amazon

If you'd like to support SNBForums, just use this link and buy anything on Amazon. Thanks!

Sign Up For SNBForums Daily Digest

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