OPENWRT自动检测断线脚本

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秒后再次检测,如果还不通,就重启路由器。

https://kzpu.com/archives/4023.html

posted @ 2020-08-29 07:33  笠航  阅读(3837)  评论(0编辑  收藏  举报