;;
stop)
echo "Tunl port closing"
ifconfig tunl0 down
echo 1 > /proc/sys/net/ipv4/ip_forward
echo 0 > /proc/sys/net/ipv4/conf/all/arp_announce
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
-------------------------------
# service shutarp start
B.中转机:
1。安装 ipvs服务:
# yum clean all
# yum install -y ipvsadm
2。打开ip转发功能,关闭其他服务,设置中转
# vim /etc/init.d/lvsDR
---------------------------------
#!/bin/sh
VIP=192.168.0.19
RIP1=192.168.0.11
RIP2=192.168.0.12
GW=192.168.0.1
. /etc/rc.d/init.d/functions
case "$1" in
start)
echo " start LVS of DirectorServer"
/sbin/ifconfig tunl0 $VIP broadcast $VIP netmask 255.255.255.255 up
/sbin/route add -host $VIP dev tunl0
/sbin/ipvsadm -C
/sbin/ipvsadm -A -t $VIP:80 -s rr
/sbin/ipvsadm -a -t $VIP:80 -r $RIP1:80 -i
/sbin/ipvsadm -a -t $VIP:80 -r $RIP2:80 -i
/sbin/ipvsadm
;;
stop)
echo "close LVS Directorserver"
ifconfig tunl0 down
/sbin/ipvsadm -C
;;
*)
echo "Usage: $0 {start|stop}"
exit 1
esac
---------------------------------
# service lvsDR start (执行脚本)