What's new

[beta] Dual WAN helper script (discontinued)

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

Can you ping dns.msftncsi.com?
C:\Users\Andrew_jr>ping dns.msftncsi.com

Обмен пакетами с dns.msftncsi.com [131.107.255.255] с 32 байтами данных:
Превышен интервал ожидания для запроса.
Превышен интервал ожидания для запроса.
Превышен интервал ожидания для запроса.
Превышен интервал ожидания для запроса.

Статистика Ping для 131.107.255.255:
Пакетов: отправлено = 4, получено = 0, потеряно = 4
(100% потерь)

100% lost

UPD. http://www.msftncsi.com/ncsi.txt opens ok
 
Last edited:
C:\Users\Andrew_jr>ping dns.msftncsi.com

Обмен пакетами с dns.msftncsi.com [131.107.255.255] с 32 байтами данных:
Превышен интервал ожидания для запроса.
Превышен интервал ожидания для запроса.
Превышен интервал ожидания для запроса.
Превышен интервал ожидания для запроса.

Статистика Ping для 131.107.255.255:
Пакетов: отправлено = 4, получено = 0, потеряно = 4
(100% потерь)

100% lost
Just as I thought. Bad news.

BTW, which WAN is your primary, you can set it in dual WAN settings.

I can only look at the nvram settings, and if
nvram get link_wan is 1 and nvram get wan_primary is 0 then this is the primary WAN
and nvram get link_wan1 is 1 and nvram get wan_primary is 1 then this is secondary WAN.

This works 100% and immediately.
The IP is also derived from nvram:
nvram get wan0_ipaddr for primary WAN and
nvram get wan1_ipaddr for secondary WAN.
I have checks built in that make sure the IP is set at the time I report the WAN type.
 
Just as I thought. Bad news.
But before everything worked perfectly. Even today ))

BTW, which WAN is your primary, you can set it in dual WAN settings.
WAN is my primary and LAN Port 1 is secondary. I didn't change this setting for months.

This works 100% and immediately.
And it perfectly worked many weeks including today when i tested beta 2 and even beta 3.

I can only look at the nvram settings, and if
So all the problems come when dns.msftncsi.com becomes unpingable? Do you think it happened 1-2 hours ago and now i am facing these problems? Is it pingable for you?
For me it is unpingable even via my iphone working over LTE.
 
So all the problems come when dns.msftncsi.com becomes unpingable? Do you think it happened 1-2 hours ago and now i am facing these problems? Is it pingable for you?
For me it is unpingable even via my iphone working over LTE.
I have no idea if this has anything to do with it, I only happened to find out because I looked into why Asus is so slow and unreliable.
I cannot ping that domain from here nor from one of my external servers.
 
I cannot ping that domain from here nor from one of my external servers.
So it's not the problem. Or now your script says secondary wan when it's primary with you too?

I think the problem is that script reads this wrong data from some file that was not cleared before. And new data is not written to that file.
 
If you want to see a colorful interpretation of the WAN type flying by, use this here, it visually shows what type is in use.
Save it in some file and run it in the SSH terminal:
Code:
#!/bin/sh

detect_wan_type(){
ired='\033[0;31m'
igreen='\033[0;92m'
nc='\033[00m'
if [ "$(nvram get link_wan)" == 1 ] && [ "$(nvram get wan_primary)" == 0 ];then

   # WAN is up
   WAN_TYPE="Primary-WAN  "
   WAN_IP=$(nvram get wan0_ipaddr)
   color=$igreen

elif [ "$(nvram get link_wan1)" == 1 ] && [ "$(nvram get wan_primary)" == 1 ];then

   # WAN1 is up
   WAN_TYPE="Secondary-WAN"
   WAN_IP=$(nvram get wan1_ipaddr)
   color=$ired

else

   WAN_TYPE="UNDEFINED    "

fi

echo -e "$color$WAN_TYPE$nc link_wan $(nvram get link_wan) wan_primary $color$(nvram get wan_primary)$nc link_wan1 $(nvram get link_wan1) WAN_IP $color$WAN_IP$nc"
sleep 2
detect_wan_type
}
detect_wan_type
If the IP is 0.0.0.0 then it has not been acquired, in the dual-wan-helper I wait in that case.
 
Last edited:
If the IP is 0.0.0.0 then it has not been acquired, in the dual-wan-helper I wait in that case.

[0;31mSecondary-WAN link_wan 1 wan_primary [0;31m1 link_wan1 1 WAN_IP [0;31m192.168.0.111

That is 100% wrong. I don't know where it gets this information. These numbers refer to secondary wan. And the router is running primary. Why does it happen?
 
[0;31mSecondary-WAN link_wan 1 wan_primary [0;31m1 link_wan1 1 WAN_IP [0;31m192.168.0.111

That is 100% wrong. I don't know where it gets this information. These numbers refer to secondary wan. And the router is running primary. Why does it happen?
Can you post that without the color code, or make a screenshot?
 
Smth strange is happening.
Secondary is changed to secondary and script sends email about it.
But the router is still on primary.
May be there is some mistake in the script?


/tmp$ /jffs/scripts/dual-wan-helper kill
Terminated
/tmp$ /jffs/scripts/dual-wan-helper

---------------------------------------------
Settings used for dual-wan-helper 1.0 beta 3

WANDOG_INTERVAL = 9 (real setting 9)
WANDOG_MAXFAIL = 2 (2)
WANDOG_FB_COUNT = 99 (99)

SLEEP_TIMEOUT = 9
PING_COUNT = 27
WAN_SUCCESSFUL = 71

SEND_MAIL = on

NTP Timeout = 36
NTP Sleep = 4
Ping Domain = 8.8.8.8
---------------------------------------------

Secondary-WAN reported
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 71, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 62, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 53, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 44, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 35, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 26, Progressive timeout 0
ping NOK, restarting WAN in 27
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 71, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 62, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 53, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 44, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 35, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 26, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 17, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 8, Progressive timeout 0

WAN type change on Fri, 11 Aug 2017 23:38:38 +0300
WAN type = Secondary-WAN, sending WAN change mail

dual-wan-helper.cfg found and verified, using it as source

% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0100 433 0 0 100 433 0 199 0:00:02 0:00:02 --:--:-- 203100 433 0 0 100 433 0 134 0:00:03 0:00:03 --:--:-- 136100 433 0 0 100 433 0 101 0:00:04 0:00:04 --:--:-- 102100 433 0 0 100 433 0 94 0:00:04 0:00:04 --:--:-- 95

ping OK, Secondary-WAN, 192.168.0.111, WAN test in 71, Progressive timeout 0
ping OK, Secondary-WAN, 192.168.0.111, WAN test in 62, Progressive timeout 0
 
Power cycled the router - it is still online saying it is on secondary wan although it is on primary.
I will try to switch back to beta 2 to see if it's code related bug.
 
Wow that is really strange. Switched back to beta 2 and now it says it is on secondary wan as well.
So i see 2 versions:
1. Either this unpingable dns corrupts everything - it means you should have the same problem like i do. Please test it.
2. Or your script made some changes to some files and now reads falce information from it.
 
This is what it should look like with colors:

wOM3lA5.png
 
Secondary-WAN link_wan 1 wan_primary 1 link_wan1 1 WAN_IP 192.168.0.111
This is correct as secondary WAN: wan_primary 1
Primary would be wan_primary 0
 
I unplugged primary wan - it switched to secondary and didn't send email. After 9*99 sec it switched back to PRIMARY and sent correct email about primary wan.
I dont understand what is going on.
 
This is my main router, the one that has a defective WAN port.
So here I use LAN port 4 as primary WAN.
It is reported as such correctly.
Primary WAN is LAN Port 4.

Cb0rIb8.png



And this is my test router, with the primary WAN being WAN port, also reported correctly.
Primary WAN is WAN.

Gh7vZ9r.png
 
Not sure if colors could help me lol.
If you reboot your router running beta3 - it says you are on primary or on secondary? I cannot understand what is happening to my router..
I have tested this on three routers, many times. Works without fail on all of them, even the router with the LTS fork.
 

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