恩山无线论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
查看: 3343|回复: 4

(转载)TOMATO 3 wan脚本 合并的实现方法

[复制链接]
发表于 2010-8-23 20:05 | 显示全部楼层 |阅读模式
本帖最后由 uu236 于 2010-8-23 20:23 编辑

原帖应该是zd出品。
以下是3WAN的脚本,曾经放出过,但一般新手并不懂怎么用的。

#!/bin/ash
# load-balance Script VER 0.5 by rightzd 20081124

LOGGER=logger
LOCK_FILE=/var/policyroute-set.lock

NETLIST=/var/policyroute-netlist
if [ ! -f $WAN1_NETLIST ]; then
    $LOGGER "$NETLIST does not exist!"
    exit 2
fi

$LOGGER "Start PolicyRouting ..."
WAN1_GATEWAY=$(nvram get wan_gateway)
WAN2_GATEWAY=$(nvram get wan_gateway)
WAN3_GATEWAY=$(nvram get wan_gateway)
WAN1_IFACE=ppp0
WAN2_IFACE=ppp1
WAN3_IFACE=ppp2
LAN_IFACE=$(nvram get lan_ifname)
LAN_IP=$(nvram get lan_ipaddr)
LAN_NET=${LAN_IP%.*}.0/24
WAN1_WAN_IP=$(ifconfig $WAN1_IFACE|grep "inet addr"|awk -F ":" '{print $2}'|awk -F " " '{print $1}')
WAN2_WAN_IP=$(ifconfig $WAN2_IFACE|grep "inet addr"|awk -F ":" '{print $2}'|awk -F " " '{print $1}')
WAN3_WAN_IP=$(ifconfig $WAN3_IFACE|grep "inet addr"|awk -F ":" '{print $2}'|awk -F " " '{print $1}')
LAN_IP=$(ifconfig $LAN_IFACE|grep "inet addr"|awk -F ":" '{print $2}'|awk -F " " '{print $1}')

if [ "$WAN1_IFACE" = "$WAN2_IFACE" ]; then
  $LOGGER "Start PolicyRouting fail, WAN1_IFACE = WAN2_IFACE"
  exit
fi

if [ "$WAN1_IFACE" = "$WAN3_IFACE" ]; then
  $LOGGER "Start PolicyRouting fail, WAN1_IFACE = WAN3_IFACE"
  exit
fi

if [ "$WAN2_IFACE" = "$WAN3_IFACE" ]; then
  $LOGGER "Start PolicyRouting fail, WAN2_IFACE = WAN3_IFACE"
  exit
fi

if [ "$WAN1_IFACE" = "" ]; then
  $LOGGER "Start PolicyRouting fail, WAN1_IFACE is NULL"
  exit
fi

if [ "$WAN2_IFACE" = "" ]; then
  $LOGGER "Start PolicyRouting fail, WAN2_IFACE is NULL"
  exit
fi

if [ "$WAN3_IFACE" = "" ]; then
  $LOGGER "Start PolicyRouting fail, WAN3_IFACE is NULL"
  exit
fi

if [ -f $LOCK_FILE ]; then
  $LOGGER "Start PolicyRouting exit, other process starting."
  exit
fi

echo "SETTING" > $LOCK_FILE

$LOGGER "WAN1_IFACE: $WAN1_IFACE, WAN1_WAN_IP: $WAN1_WAN_IP, WAN1_GATEWAY: $WAN1_GATEWAY"
$LOGGER "WAN2_IFACE: $WAN2_IFACE, WAN2_WAN_IP: $WAN2_WAN_IP, WAN2_GATEWAY: $WAN2_GATEWAY"
$LOGGER "WAN3_IFACE: $WAN3_IFACE, WAN3_WAN_IP: $WAN3_WAN_IP, WAN3_GATEWAY: $WAN3_GATEWAY"
$LOGGER "LAN_IP: $LAN_IP LAN_NET: $LAN_NET"

$LOGGER "disable rp_filter "
echo 0 >/proc/sys/net/ipv4/conf/all/rp_filter

$LOGGER "set default router via $WAN1_IFACE, $WAN2_IFACE, $WAN3_IFACE"
ip route del default
ip route del default
ip route del default
ip route add default nexthop via $WAN1_GATEWAY dev $WAN1_IFACE weight 1 nexthop via $WAN2_GATEWAY dev $WAN2_IFACE weight 1 nexthop via $WAN3_GATEWAY dev $WAN3_IFACE weight 1


转载原地址:http://www.high3.cn/viewall.asp?webid=472
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-24 16:06 | 显示全部楼层
怎么操作这是问题啊!
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-27 22:00 | 显示全部楼层
方法????                 能3难道不能4??              为什么是3!!!!!
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-29 04:04 | 显示全部楼层
等楼下的教程好了。。。
我的恩山、我的无线 The best wifi forum is right here.
发表于 2010-8-29 09:43 | 显示全部楼层
没有LINUX的基础最好不要搞~这个不能反应在WEB页面的
我的恩山、我的无线 The best wifi forum is right here.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )|网站地图

GMT+8, 2020-9-27 01:52

Powered by Discuz! X3.4

Copyright © 2001-2020, Tencent Cloud.

快速回复 返回顶部 返回列表