github twitter email rss
dualwan一线多拨
Jul 6, 2014
1 minute read

1.telnet 至路由器并运行命令显示vlan配置

# nvram show | grep vlan

显示结果如下

vlan0ports=2 1 0 5*
vlan1ports=4 5
vlan2ports=3 5

2.运行以下命令,将lan2与lan1加入同一个vlan

nvram set vlan0ports=1 0 5*
nvram set vlan2ports=3 2 5*

3.用网线桥接wan与lan1(lan2), isp的接入线插入lan2(lan1) 4.以下脚本用来在路由初始化时自动双(多)拨

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

#30秒后开始检测WAN1, WAN2
sleep 30
WAN1_IF=$(nvram get wan_iface)
WAN2_IF=$(nvram get wan2_iface)
WAN1_IP=$(ifconfig $WAN1_IF |grep -c "inet addr:10.3")
WAN2_IP=$(ifconfig $WAN2_IF |grep -c "inet addr:10.3")
if [ "$WAN1_IF" == "" ] || [ "$WAN2_IF" == "" ]; then
        echo "2WAN fail"
        kill -SIGHUP 1
else
        GET_PPP_GATEWAY $WAN1_IF
        if [ "$PPP_IP" == "" ]; then
                kill -SIGHUP 1
                exit
        fi
        
        GET_PPP_GATEWAY $WAN2_IF
        if [ "$PPP_IP" == "" ]; then
                kill -SIGHUP 1
                exit
        fi        
        echo "2WAN ok 1"
fi

if [ "$WAN1_IP" == "0" ] && [ "$WAN2_IP" == "0" ]; then
        echo "2WAN ok 2"
else
        echo "2WAN fail"
        kill -SIGHUP 1
fi

Back to posts


comments powered by Disqus