标签:lvs
#!/bin/bash # description: Config realserver lo and apply noarp SNS_VIP=( 192.168.100.210 192.168.100.220 ) case "$1" in start) for ((i=0;i<`echo ${#SNS_VIP[*]}`;i++)) do interface="lo:`echo ${SNS_VIP[$i]}|awk -F . ‘{print $4}‘`" /sbin/ifconfig $interface ${SNS_VIP[$i]} broadcast ${SNS_VIP[$i]} netmask 255.255.255.255 /sbin/route add -host ${SNS_VIP[$i]} dev $interface done #ifconfig lo:0 $SNS_VIP netmask 255.255.255.255 broadcast $SNS_VIP #/sbin/route add -host $SNS_VIP dev lo:0 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 "RealServer Start OK" ;; stop) for ((i=0;i<`echo ${#SNS_VIP[*]}`;i++)) do interface="lo:`echo ${SNS_VIP[$i]}|awk -F . ‘{print $4}‘`" /sbin/ifconfig $interface down /sbin/route del ${SNS_VIP[$i]} >/dev/null 2>&1 done echo "0" >/proc/sys/net/ipv4/conf/lo/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/lo/arp_announce echo "0" >/proc/sys/net/ipv4/conf/all/arp_ignore echo "0" >/proc/sys/net/ipv4/conf/all/arp_announce echo "RealServer Stoped" ;; *) echo "Usage: $0 {start|stop}" exit 1 esac exit 0
本文出自 “枫林晚” 博客,请务必保留此出处http://fengwan.blog.51cto.com/508652/1539022
标签:lvs
原文地址:http://fengwan.blog.51cto.com/508652/1539022