OpenWRT偶尔会自动死机或断线,手动检测重店比较麻烦,下面就用一个脚本来自动判断路由器是否连网。

#!/bin/sh
# 自动检查线路是否正常,不正常就重启 Openwrt 重新拨号

PING=`ping -c 5 202.96.128.86|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 202.96.128.86|grep -v grep|grep '64 bytes' |wc -l`

if [ ${PING2} -ne 0 ];then
	exit 0
else
	reboot
fi

通过ping电信的dns服务器,来判断网络是否连通。如果不通,就重启网络。10秒后再次检测,如果还不通,就重启路由器。

发表回复

您的电子邮箱地址不会被公开。 必填项已用*标注