首页 > 代码库 > LVS多VIP脚本
LVS多VIP脚本
#!/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
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。