中国移动宽带 + OpenWRT x86-64 软路由,发现有一定机率断线。
不知道是 ISP 的问题,还是 OpenWRT 的问题。
遂用脚本来检测,每分钟运行一次。
如果 ping 不通 1.2.4.8;就重启网络服务进行拨号,
10秒钟后还是不通,就尝试重启OpenWRT。
脚本如下:
#!/bin/sh
# 自动检查线路是否正常,不正常就重启 Openwrt 重新拨号
# 脚本时间:2018-05-03
PING=`ping -c 5 1.2.4.8|grep -v grep|grep '64 bytes' |wc -l`
if [ ${PING} -ne 0 ];then
exit 0
else
/etc/init.d/network restart
fi
sleep 10
PING2=`ping -c 5 1.2.4.8|grep -v grep|grep '64 bytes' |wc -l`
if [ ${PING2} -ne 0 ];then
exit 0
else
reboot