look:


yum -y install arptables_jf


vim dr.sh


#!/bin/sh

# chkconfig: 2345 90 10

# description: Preparing for Load Balancer and Real Server switching


VIP=124.160.156.149

LOCAL_IP=124.160.156.155

BROADCAST=124.160.156.255


#echo "1" > /proc/sys/net/ipv4/ip_forward


. /etc/rc.d/init.d/functions


case "$1" in

   stop)

       echo "Preparing for Load Balancer"

       echo "1" > /proc/sys/net/ipv4/ip_forward

       ifconfig lo:0 down

       /sbin/arptables -F

       ;;

   start)

       echo "Preparing for Real Server"

       echo "0" > /proc/sys/net/ipv4/ip_forward

       #/sbin/ip addr del ${VIP}/26 dev eth0

       ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $BROADCAST up

       /sbin/arptables -F

       /sbin/arptables -A IN -j DROP -d ${VIP}

       /sbin/arptables -A OUT -j mangle -o eth0 -s ${VIP} --mangle-ip-s ${LOCAL_IP}

       ;;

   *)

       echo "Usage: lvs {start|stop}"

       exit 1

esac