全部博文(230)
分类: LINUX
2006-01-26 02:09:00
如果多链路负载均衡中的一个链路丢失,默认路由会造成错误
下面的方法可以根据当时情况重建默认路由,并判断多链路阀值,低于阀值自动重拨
#! /bin/bash
RE_ROUTE()
{
CMD="ip route replace default equalize "
for i in $ADSL_DEV
do
CMD="$CMD nexthop dev $i weight 1"
done
$CMD &>/dev/null
}
RE_ADSL()
{
# because there are 6 lines in my company
for PPP in 0 1 2 3 4 5
do
ifdown ppp$PPP
done
sleep 1
for PPP in 0 1 2 3 4 5
do
ifup ppp$PPP
done
# another rules by platinum
firewall
}
SET_QDNS()
{
ADSL_DEV_FIRST=`echo $ADSL_DEV|awk '{print $1}'`
/usr/local/ez-ipupdate-3.0.10-linux-i386/ez-ipupdate -S qdns -h 域名 -u USER:PASS -i $ADSL_DEV_FIRST &>/dev/null
}
ADSL_DEV=`ifconfig|awk '/ppp.*Link/{print $1}'`
if [ "`echo $ADSL_DEV|wc -w`" -lt "4" ]; then
echo "`date` $ADSL_DEV" >> /var/log/adsl.log
RE_ADSL
fi
RE_ROUTE
SET_QDNS