What's new

WANFailover Dual WAN Failover ***v2 Release***

  • 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!

Ok, no worries I have an idea of what is going on.

EDIT:
I did discover that I'm currently require ddns_hostname_x in nvram to not be null but I intended to accept null if DDNS was disabled so that could be it. Also I found a bug in it grabbing OVPN Server Instances within this function which keep in mind this is new and part of this beta cycle so I appreciate you guys helping me get these worked out.

DM me the output of these commands please.
Code:
nvram get model
nvram get productid
nvram get build_name
nvram get 3rd-party
nvram get buildno
nvram get lan_hostname
nvram get jffs2_scripts
ip -V | awk -F "-" '{print $2}'
nvram get misc_http_x
nvram get fw_enable_x
nvram get ipv6_fw_enable
nvram get led_disable
nvram get log_level
nvram get ddns_enable_x
nvram get ddns_hostname_x
nvram get vpn_serverx_start
 
Last edited:
Ok, no worries I have an idea of what is going on. Standby for guidance.
I'll be here. I don't have notifications but I'll regularly refresh. Also I'm still waiting for another SIM, so the modem is not currently plugged in. But the dual WAN feature is still on. Does it still install the script just fine? . Worst case I can plug it in and set the ping to my modem WebGUI IP which should be reachable

Edit : When i did install the script and it hangs. I tried plugging the modem as a secondary with a valid sim installed. Doesn't change anything. I can't use my sim to the modem again because I need to temporarily use my phone sim and put it in there
 
I'll be here. I don't have notifications but I'll regularly refresh. Also I'm still waiting for another SIM, so the modem is not currently plugged in. But the dual WAN feature is still on. Does it still install the script just fine? . Worst case I can plug it in and set the ping to my modem WebGUI IP which should be reachable

Edit : When i did install the script and it hangs. I tried plugging the modem as a secondary with a valid sim installed. Doesn't change anything. I can't use my sim to the modem again because I need to temporarily use my phone sim and put it in there
I just edited my last post.
 
Ok, no worries I have an idea of what is going on.

EDIT:
I did discover that I'm currently require ddns_hostname_x in nvram to not be null but I intended to accept null if DDNS was disabled so that could be it. Also I found a bug in it grabbing OVPN Server Instances within this function which keep in mind this is new and part of this beta cycle so I appreciate you guys helping me get these worked out.

DM me the output of these commands please.
Code:
nvram get model
nvram get productid
nvram get build_name
nvram get 3rd-party
nvram get buildno
nvram get lan_hostname
nvram get jffs2_scripts
ip -V | awk -F "-" '{print $2}'
nvram get misc_http_x
nvram get fw_enable_x
nvram get ipv6_fw_enable
nvram get led_disable
nvram get log_level
nvram get ddns_enable_x
nvram get ddns_hostname_x
nvram get vpn_serverx_start
Sent !! Thank you!
 
v2.0.0-beta5 has been published with the following changes, you can run the update command to update to the latest beta version if you have Dev Mode enabled.

Changes from v2.0.0-beta4:
- General Optimization
- Optimization to Email Function to help prevent duplicate emails and display ISP in email notification with proper format.
- Optimization to Update Functon
- Fixes to Get System Parameters Function that were causing lock ups and CPU spikes if DDNS Hostnames or OpenVPN Servers were not in use.
- Additional debug logging added for Get System Parameters and Get WAN Functions.
- Expansion to WAN Restart Functions for all WAN States.
- Checksums will now calculate using SHA256 if possible and fallback to using MD5 if not available.
- Modifications to Status Console formulas that check if Failover is Running or is Unresponsive.
 
Upgrade V2.0.0-beta4 to V2.0.0-beta5. Error at end of script I received from upgrade, otherwise appears to be running normally:


Code:
/jffs/scripts/wan-failover.sh update
***Dev Mode is Enabled***
wan-failover is out of date - Current Version: v2.0.0-beta4 Available Version: v2.0.0-beta5
Do you want to update to the latest beta version? v2.0.0-beta5 ***Enter Y for Yes or N for No***
> Y
wan-failover: Update - wan-failover has been updated to version: v2.0.0-beta5
wan-failover: Restart - Restarting wan-failover ***This can take up to approximately 1 minute***
wan-failover: Restart - Killing wan-failover Process ID: 20664
wan-failover: Restart - Killed wan-failover Process ID: 20664
wan-failover: Restart - Killing wan-failover Process ID: 20665
wan-failover: Restart - Killed wan-failover Process ID: 20665
wan-failover: Restart - Killing wan-failover Process ID: 27697
wan-failover: Restart - Killed wan-failover Process ID: 27697
wan-failover: Restart - Killing wan-failover Process ID: 27698
wan-failover: Restart - Killed wan-failover Process ID: 27698
wan-failover: Restart - Waiting for wan-failover to restart from Cron Job
wan-failover: Restart - Successfully Restarted wan-failover Process ID(s): 28309 28314
/jffs/scripts/wan-failover.sh: line 5808: DNS: parameter not set
 
Upgrade V2.0.0-beta4 to V2.0.0-beta5. Error at end of script I received from upgrade, otherwise appears to be running normally:


Code:
/jffs/scripts/wan-failover.sh update
***Dev Mode is Enabled***
wan-failover is out of date - Current Version: v2.0.0-beta4 Available Version: v2.0.0-beta5
Do you want to update to the latest beta version? v2.0.0-beta5 ***Enter Y for Yes or N for No***
> Y
wan-failover: Update - wan-failover has been updated to version: v2.0.0-beta5
wan-failover: Restart - Restarting wan-failover ***This can take up to approximately 1 minute***
wan-failover: Restart - Killing wan-failover Process ID: 20664
wan-failover: Restart - Killed wan-failover Process ID: 20664
wan-failover: Restart - Killing wan-failover Process ID: 20665
wan-failover: Restart - Killed wan-failover Process ID: 20665
wan-failover: Restart - Killing wan-failover Process ID: 27697
wan-failover: Restart - Killed wan-failover Process ID: 27697
wan-failover: Restart - Killing wan-failover Process ID: 27698
wan-failover: Restart - Killed wan-failover Process ID: 27698
wan-failover: Restart - Waiting for wan-failover to restart from Cron Job
wan-failover: Restart - Successfully Restarted wan-failover Process ID(s): 28309 28314
/jffs/scripts/wan-failover.sh: line 5808: DNS: parameter not set
Published a minor fix for this, update again.
 
Published a minor fix for this, update again.

Code:
/jffs/scripts/wan-failover.sh update
wan-failover is up to date - Version: v2.0.0-beta5
***Checksum Failed***
Current Checksum: 1f1774c62efbbdf23f7269bcffcd08c6ba04fcab75a011c9dd1aa464c28c42f9  Val                           id Checksum: 5056812515b10958f8bcc1ecb6436ad91091ab5b310ccd76ec854217fd2c642d
wan-failover is up to date. Do you want to reinstall wan-failover Version: v2.0.0-beta5                           ? ***Enter Y for Yes or N for No***
> Y
wan-failover: Update - wan-failover has reinstalled version: v2.0.0-beta5
wan-failover: Restart - Restarting wan-failover ***This can take up to approximately 1                            minute***
wan-failover: Restart - Killing wan-failover Process ID: 4526
kill: can't kill pid 4526: No such process
wan-failover: Restart - Killing wan-failover Process ID: 28309
wan-failover: Restart - Killed wan-failover Process ID: 28309
wan-failover: Restart - Killing wan-failover Process ID: 28314
wan-failover: Restart - Killed wan-failover Process ID: 28314
wan-failover: Restart - Waiting for wan-failover to restart from Cron Job
wan-failover: Restart - Successfully Restarted wan-failover Process ID(s): 4888 4889
Successfully Restarted wan-failover Process ID(s): 4888,4889
/jffs/scripts/wan-failover.sh: line 5940: syntax error: unterminated quoted string
 
Code:
/jffs/scripts/wan-failover.sh update
wan-failover is up to date - Version: v2.0.0-beta5
***Checksum Failed***
Current Checksum: 1f1774c62efbbdf23f7269bcffcd08c6ba04fcab75a011c9dd1aa464c28c42f9  Val                           id Checksum: 5056812515b10958f8bcc1ecb6436ad91091ab5b310ccd76ec854217fd2c642d
wan-failover is up to date. Do you want to reinstall wan-failover Version: v2.0.0-beta5                           ? ***Enter Y for Yes or N for No***
> Y
wan-failover: Update - wan-failover has reinstalled version: v2.0.0-beta5
wan-failover: Restart - Restarting wan-failover ***This can take up to approximately 1                            minute***
wan-failover: Restart - Killing wan-failover Process ID: 4526
kill: can't kill pid 4526: No such process
wan-failover: Restart - Killing wan-failover Process ID: 28309
wan-failover: Restart - Killed wan-failover Process ID: 28309
wan-failover: Restart - Killing wan-failover Process ID: 28314
wan-failover: Restart - Killed wan-failover Process ID: 28314
wan-failover: Restart - Waiting for wan-failover to restart from Cron Job
wan-failover: Restart - Successfully Restarted wan-failover Process ID(s): 4888 4889
Successfully Restarted wan-failover Process ID(s): 4888,4889
/jffs/scripts/wan-failover.sh: line 5940: syntax error: unterminated quoted string
I’m not sure where your router sees the unterminated string, I can’t find it or replicate the error.
 
I’m not sure where your router sees the unterminated string, I can’t find it or replicate the error.
Shell check doesnt like something in restartwan0 ()
Code:
Line 3850:
restartwan0 ()
^-- SC1009 (info): The mentioned syntax error was in this function.
 
Line 3851:
{
^-- SC1073 (error): Couldn't parse this brace group. Fix to allow more checks.
 
Line 3912:
[ ! -z "${wan0state+x}" ]  &>/dev/null unset wan0state
                                       ^-- SC1056 (error): Expected a '}'. If you have one, try a ; or \n in front of it.
                                       ^-- SC1072 (error): Missing '}'. Fix any mentioned problems and try again.
                                       ^-- SC1140 (error): Unexpected parameters after condition. Missing &&/||, or bad expression?

$


Also
Code:
Line 2966:
      if [ ! -z "${WAN0DUALWANDEV+x}" ]] &>/dev/null;then
         ^-- SC1034 (error): Test expression was opened with single [ but closed with double ]]. Make sure they match.

Line 3120:
      if [ ! -z "${WAN1DUALWANDEV+x}" ]] &>/dev/null;then
         ^-- SC1034 (error): Test expression was opened with single [ but closed with double ]]. Make sure they match.
 
Last edited:
Shell check doesnt like something in restartwan0 ()

Also
Code:
Line 2966:
      if [ ! -z "${WAN0DUALWANDEV+x}" ]] &>/dev/null;then
         ^-- SC1034 (error): Test expression was opened with single [ but closed with double ]]. Make sure they match.

Line 3120:
      if [ ! -z "${WAN1DUALWANDEV+x}" ]] &>/dev/null;then
         ^-- SC1034 (error): Test expression was opened with single [ but closed with double ]]. Make sure they match.
Lol thank you, I’ll clean that up, those are new additions in this beta.
Edit: I found the problem in that function, missing && between commands at the end.
 
Last edited:
Lol thank you, I’ll clean that up, those are new additions in this beta.
Edit: I found the problem in that function, missing && between commands at the end.
Minor revision to v2.0.0-beta5 has been published to address these issues. Thanks @Maverickcdn for the finds!
 
Its looking good!
One comment (from my edge case ;-): If the cron job is disabled, when installing/updating, wan-failover waits quite a while for a non-existant cron job to start. Maybe check the variable and skip the wait?

I thought initate was hanging. It turns out I had set my ping times long - I switch based on speedtest. As a result, initiate uses pretty long values for -w and -W. It does complete (after a while).
Not sure you need to do anything - just an FYI.

Speaking of initiate - I have cron jobs disabled. Do you recommend I call wan-failover initiate from services-start? Do I just need to call it once?
I typically call wan-failover from a shell script when I detect my WAN0 getting too slow. wan-failover switchan
Switches to WAN1 perfectly.
I then call it later from a cron job at 2AM - which will switch it back to WAN0.
 
BTW, here is a short snippet that might be useful built into wan-failover.
Once in a while my DSL modem goes into Cold Standby.
Before I call wan-failover, I check to see if it is Connected (Hot Standby). If not, I reset the wan interface.
This usually fixes it.
In my case, it's just WAN1 so it's hard coded to WAN1. Easy enough to do for WAN0 as well.

Code:
                if [[ "$(nvram get wan1_state_t)" != "2" ]] >/dev/null;then
                        logger -t switchwan "WAN1 not connected, attempt restart"
                        service "restart_wan_if 1"
                        sleep 30
                fi
 
BTW, here is a short snippet that might be useful built into wan-failover.
Once in a while my DSL modem goes into Cold Standby.
Before I call wan-failover, I check to see if it is Connected (Hot Standby). If not, I reset the wan interface.
This usually fixes it.
In my case, it's just WAN1 so it's hard coded to WAN1. Easy enough to do for WAN0 as well.

Code:
                if [[ "$(nvram get wan1_state_t)" != "2" ]] >/dev/null;then
                        logger -t switchwan "WAN1 not connected, attempt restart"
                        service "restart_wan_if 1"
                        sleep 30
                fi
I haven't used this script fully yet since I'm still waiting for my SIM card to come in the mail.

But, shouldn't the script force the second WAN to always be active (hot standby)? Since it automatically does the ping periodically for both WAN interfaces?
 
I haven't used this script fully yet since I'm still waiting for my SIM card to come in the mail.

But, shouldn't the script force the second WAN to always be active (hot standby)? Since it automatically does the ping periodically for both WAN interfaces?
It does, it checks state at start up.
 
Ahh, I see that now (restartwan). I didn't read through the entire wan-failover script!!!
 
Double check you guys are currently up to date if you are running v2.0.0-beta5, I had a commit that somehow didn’t apply and I corrected this early this morning.
 

Similar threads

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