The TP-Link TL-R470T+ Load Balance Broadband Router performs mostly as desired and advertised. This is one of the very few load balancing routers under $150, coming in at about $55. As you might expect at that price point, it’s not perfect. One major limiting factor for my application is the limit of 16 (16?!) load balance policy rules. The only major flaw I’ve encountered in my use of this hardware is it’s “Online Detection” service.
The Problem: Online Detection
Determining if each WAN connection is online is an important feature of the router. Without this there would be no reliability. My connections are not the most reliable, hence the need for this router and two ISPs. I was often getting false positives and false negatives in online detection. Both false negatives and false positives are fairly disastrous for my network. I noticed that keeping the servers set to “manual” I would only receive false negatives (connection DOWN.) When I manually updated the settings for Online Detection, I could force the router to correctly refresh the status as long as the server addresses changed. I started using Google’s Public DNS hosts for ping and name resolution (in Online Detection settings) as I couldn’t trust the “Auto” setting. This was partially due to one WAN connection being a private subnet (double NAT).
The Solution: Automatically Update the Settings Every 5 Minutes
It’s crazy I know, but it’s been working for many months now. Requests for help from tech support and community forums received no serious answers. I crafted a couple Bash shell scripts on a local Linux (Ubuntu) machine to run every 5 minutes, automating the change in settings for Online Detection’s servers. This way a WAN connection is incorrectly marked online or offline for no longer than 5 minutes. The single disadvantage I’ve experienced from this method is normal access of the admin web page. The router only allows access to the admin pages from one IP at a time. This means you have to load and make changes between those automated accesses every 5 minutes. The interval can be changed at your discretion of course.
The script below is one part of this solution, it authenticates with the router’s web interface. The following scripts use the cookie generated by this script to access the Online Detection page. I kept the scripts separate for functionality.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
#!/bin/bash ADMIN_USER="YOUR_USERNAME" ADMIN_PASS="YOUR_PASSWORD" ROUTER_IP="YOUR_ROUTER_IP" initial=$(wget --timeout=7 -qO- --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies "http://$ROUTER_IP/") if [ -z "$initial" ] then echo "Connection error..." return 99 fi case "$initial" in *"LOGIN_NORMAL"* ) login=0; echo "Not logged in...";; *"option=timeout"* ) login=1; echo "Login timeout...";; * ) login=1; echo "Already logged in...";return 0;; esac if [[ $login -eq 1 ]] then initial=$(wget --timeout=7 -qO- --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies "http://$ROUTER_IP/../logon/logon.htm?option=timeout") fi echo "Attempting login..." cookie=$(cat cookies.txt | grep -o "COOKIE.*") cookie=${cookie:7} hash="$(echo -n "$ADMIN_USER:$ADMIN_PASS:$cookie" | md5sum | cut -f1 -d ' ')" hash="encoded=$ADMIN_USER%3A$hash&nonce=$cookie&URL=..%2Flogon%2FloginJump.htm" second=$(wget --timeout=7 -qO- --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies --post-data="$hash" "http://$ROUTER_IP/logon/loginJump.htm") case "$second" in *"has logged on from %sessionIp%!"* ) login=3;echo "Admin session in progress from another IP...";; *"LOGIN_NORMAL"* ) login=0;echo "Error: incorrect login?";return 9;; * ) login=4; echo "All is good?";return 0;; esac if [[ $login -eq 3 ]] then echo "Confirming login..." third=$(wget --timeout=7 -qO- --load-cookies cookies.txt --save-cookies cookies.txt --keep-session-cookies "http://$ROUTER_IP/logon/loginConfirm.htm?") return 0 fi |
This is part 1 of 3… See the next post here.
Are you going to publish further scripts? I am very interested in them as I am having the same problems with false negatives as you are.
Hi there. Obviously I let this fall by the wayside. Now that I see there’s interest, I will post more scripts very soon!
Modified the script a little bit, yet not able to login
cookie=$(cat cookies.txt | grep -o “COOKIE.*” | cut -f2)
hash=”$(echo -n “$ADMIN_USER:$ADMIN_PASS:$cookie” | md5sum | cut -f1 -d ‘ ‘ | tr ‘a-z’ ‘A-Z’)”
hash=”encoded=$ADMIN_USER%3A$hash&nonce=$cookie&URL=..%2Flogon%2FloginJump.htm”