Home routing relay Others distant a tp-link to the Internet, but the distance is too far, often disconnected, the disconnection is not aware of the abnormal, so write a test script to determine whether to drop the line
Mainly ping Superior routing
Through the ping 114dns did not touch the shell script, the logic is not how to do well directly up a while cycle plus multiple if
It's a bad writing.
echo ' Hello world ' while test "1" = "1" do# do something# first time ping Superior 192.168.1.1if ping -w 1 -c 1 192.168.1.1then #若通则ping 114 if ping -w 1 -c 1 114.114.114.114 then echo ' 01 network ok ' else #再ping 115 confirm if -w 1 -c 1 ping 114.114.115.115 then echo ' 02 network ok ' #上级通, 114,115 non-pass, restart network else /etc/init.d/network restart #重启网络, wait echo ' F1: network fail ' fi fi# first Ping Upper 192 not pass, second time pingelse if ping -w 1 -c 1 192.168.1.1 then #第二次ping上级通了 if ping -w 1 -c 1 114.114.114.114 then #ping 114 also pass the echo ' 04 network ok ' else #ping 114 Non-pass ping 115 confirmation if ping -w 1 -c 1 114.114.115.115 then #115可达 echo ' 05 network ok ' #114, 115 is not through, restart network else /etc/init.d/ network restart #重启网络, wait echo ' F3: network&nbsP Fail ' fi fi# The second ping superior still does not pass, direct ping 114 try else if ping -w 1 -c 1 114.114.114.114 then #114可达, network normal echo ' 03 network Ok ' else #确实不通, only restart /etc/init.d/network restart #重启网络, wait echo ' F2: network fail ' fi fifisleep 100done
OpenWrt routing in relay mode to detect restart scripts