TT双拨脚本

 

#!/bin/sh
GET_PPP_GATEWAY() {
        iface
=$1
        echo 
"iface="$iface
        PPP_IP
=$(ifconfig $iface|grep "inet addr"|awk -":" '{print $2}'|awk -" " '{print $1}')
        PPP_GATEWAY
=$PPP_IP
}

GET_PPP_GATEWAY2() {
        iface
=$1
        echo 
"iface="$iface
        PPP_IP2
=$(ifconfig $iface|grep "inet addr"|awk -":" '{print $2}'|awk -" " '{print $1}')
        PPP_GATEWAY2
=$PPP_IP2
}

FAST_REBOOT() {
#ISP要求重拨前必须先断开并且要间隔60秒才能拨号,如果无要求可以在下面2句前加上#
        #service wan stop
        #sleep 3
#快速重启命令,只是重新初始化Tomato DualWAN环境,硬件无需重启

        kill -SIGHUP 1
}


#开始检测WAN1, WAN2
WAN1_IF=$(nvram get wan_iface)
WAN2_IF
=$(nvram get wan2_iface)
GET_PPP_GATEWAY 
$WAN1_IF
GET_PPP_GATEWAY2 
$WAN2_IF
#初始化拨号次数
PPPDailNum=0
#循环,直到双拨成功
while [ "$PPP_IP" == "" ] || [ "$PPP_IP2" == "" ]
       
do
#拨号次数最多为10次
              if [ $PPPDailNum -ne  10 ]; then
                     FAST_REBOOT
                     let PPPDailNum
=PPPDailNum+1
#拨号后停顿,建议15秒以上
                     sleep 15
#不知道为什么需要重新获取一次才能够正常运行?
GET_PPP_GATEWAY() {
        iface
=$1
        echo 
"iface="$iface
        PPP_IP
=$(ifconfig $iface|grep "inet addr"|awk -":" '{print $2}'|awk -" " '{print $1}')
        PPP_GATEWAY
=$PPP_IP
}

GET_PPP_GATEWAY2() {
        iface
=$1
        echo 
"iface="$iface
        PPP_IP2
=$(ifconfig $iface|grep "inet addr"|awk -":" '{print $2}'|awk -" " '{print $1}')
        PPP_GATEWAY2
=$PPP_IP2
}
                     WAN1_IF
=$(nvram get wan_iface)
                     WAN2_IF
=$(nvram get wan2_iface)
                     GET_PPP_GATEWAY 
$WAN1_IF
                     GET_PPP_GATEWAY2 
$WAN2_IF
                     
#在SSH终端里面执行可以去掉注释看见IP获取情况
                     #echo $PPP_IP
                     #echo $PPP_IP2

              else
                    PPP_IP
="stop Dail"
                    PPP_IP2
="stop Dail"
             fi
done

 

转载于:https://www.cnblogs.com/leeairw/archive/2011/04/05/2006130.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值