lvs dr tunl真实机脚本
#!/bin/bash
#create lvs dr or tunl realservr scripts.
#chenjian 2011-09-23
VIP_LIST="192.168.116.20 192.168.116.21"
USAGE="Usage: $0 {start|stop|status} {dr|tunl}"
NAME=tunl
NUM=0
if [ -z $1 ]
then
echo $USAGE
exit 2
fi
ACTION=`echo $1|tr A-Z a-z`
if ! [ $1 == status ]
then
if [ -z $2 ]
then
echo $USAGE
exit 2
fi
fi
TYPE=`echo $2|tr A-Z a-z`
case "$1" in
start)
if [ $TYPE == dr ]
then
if /sbin/ifconfig |grep lo: > /dev/null
then
/sbin/ifdown lo
/sbin/ifup lo
fi
for vip in `echo $VIP_LIST`;do
/sbin/ifconfig lo:$NUM $vip netmask 255.255.255.255 broadcast $vip
/sbin/route add -host $vip dev lo:$NUM
NUM=`echo $[$NUM+1]`
done
echo "1" >/proc/sys/net/ipv4/conf/lo/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/lo/arp_announce
echo "1" >/proc/sys/net/ipv4/conf/all/arp_ignore
echo "2" >/proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p >/dev/null 2>&1
echo "$TYPE RealServer Start [ OK ]"
elif [ $TYPE == tunl ]
then
for vip in `echo $VIP_LIST`;do
if [ $NAME == tunl ]
then
NAME=tunl0
/sbin/ifconfig "$NAME" $vip netmask 255.255.255.255
/sbin/route add -host $vip dev $NAME
else
/sbin/ifconfig "$NAME":"$NUM" $vip netmask 255.255.255.255
/sbin/route add -host $vip dev $NAME
fi
NUM=`echo $[$NUM+1]`
done
echo 1 > /proc/sys/net/ipv4/conf/tunl0/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/tunl0/arp_announce
echo 0 > /proc/sys/net/ipv4/conf/tunl0/arp_filter
echo 1 > /proc/sys/net/ipv4/conf/tunl0/forwarding
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
sysctl -p >/dev/null 2>&1
echo "$TYPE RealServer Start [ OK ]"
else
echo $USAGE
exit 2
fi
;;
stop)
if [ $TYPE == dr ]
then
for vip in `echo $VIP_LIST`;do
/sbin/ifconfig lo:$NUM down
/sbin/route del $vip
&nb
- 发表评论
-
- 最新评论 更多>>