`

FreeBSD下ADSL上网断线自动重拨

阅读更多

有时候断线自动重拨需要一定时间
保存下面文件为 checkadsl.sh
再添加到crontab里,每分钟检查一次。

#!/bin/sh

HOME=/
PATH=/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin
export HOME PATH

time=6
ok=`expr $time / 2`
myip=`ifconfig tun0 | grep "inet" | awk '{print $4}'`

if [ -n "$myip" ]; then

        count=`ping -c $time -s 8 $myip | grep "icmp_seq" | wc -l 2> /dev/null`

        if [ "$count" -lt "$ok" ]; then
                echo "DSL is not connected."
                /etc/rc.d/ppp restart
        fi
fi
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics