有时候断线自动重拨需要一定时间
保存下面文件为 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
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
本文介绍了一种通过shell脚本实现的DSL连接状态检查及自动重拨的方法。该脚本能够定时检查网络连接状态,并在网络连接不稳定或断开时自动进行重拨,确保网络连接的稳定性和连续性。
150

被折叠的 条评论
为什么被折叠?



