最新消息:

试着做个双adsl负载均衡

技术相关 admin 1743浏览

公司搬家后需要在两路adsl同时拨号增加所谓的带宽,我选择了Openbsd系统.目前系统运行稳定,负载如下:

uptime

6:11AM? up 3 days, 12:04,?1 users, load averages: 0.11, 0.10, 0.12

参考:http://bbs.chinaunix.net/viewthread.php?tid=746001&extra=page%3D1%26filter%3Ddigest
?
使用OpenBSD 3.9 双ADSL 架设 负载均衡 NAT服务器 配置文件大致相同.参考pf-faq中Address Pools and Load Balancing 章节.计划过些天试着做2路网通adsl,1路电信的adsl的负载均衡.(要设置默认路由)
监控脚本有些不同,如下:
?

!/bin/sh

sleep 10
flag=0
while :
do
if_add0=”ifconfig tun0 | grep netmask | awk '{printf $2}'
if_add1=”ifconfig tun1 | grep netmask | awk '{printf $2}'

if? [ $flag != 2 ]
then
if [[ ! -z “$if_add0” && “$if_add0″ != ” && ! -z “$if_add1” && “$if_add1″ != ”? ]]
then
/sbin/pfctl -d
/sbin/pfctl -F all -e? -f /etc/pf1.conf ;
echo date ” –>? chang to? /etc/pf1.conf –>” tun0:$if_add0? tun1:$if_add1
flag=2
sleep 30
fi
fi
? if [[ ! -z “$if_add0” && “$if_add0″ != ” &&? -z “$if_add1” && “$if_add1″ = ”? ]]
then
/sbin/pfctl -d
/sbin/pfctl -F all -e? -f /etc/pf.conf ;
echo date ” –>? chang to? /etc/pf.conf –>” tun0:$if_add0? tun1:$if_add1
sleep 30
fi
? if [[? -z “$if_add0” && “$if_add0″ = ” && ! -z “$if_add1” && “$if_add1″! = ”? ]]
then
/sbin/pfctl -d
/sbin/pfctl -F all -e? -f /etc/pf2.conf ;
echo date ” –>? chang to? /etc/pf2.conf –>” tun0:$if_add0? tun1:$if_add1
sleep 30
fi

if [[? -z “$if_add1” && “$if_add1″ = ”? ]]
then
PID=ps -x | grep 'unit 1' | grep ppp1 | awk '{print $1}'
kill $PID
ifconfig tun1 down
ifconfig tun1 up
/usr/sbin/ppp -unit 1 -auto ppp1
echo ‘dial ppp1’
sleep? 5
flag=0
fi

if [[? -z “$if_add0” && “$if_add0″ = ”? ]]
then
PID=ps -x | grep 'unit 0' | grep ppp0 | awk '{print $1}'
kill $PID
ifconfig tun0 down
ifconfig tun0 up
/usr/sbin/ppp -unit 0 -auto ppp0
echo ‘dial ppp0’
sleep? 5
flag=0
fi
? sleep 30

done

转载请注明:Kermit的网站 » 试着做个双adsl负载均衡