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