配置lvs nat模式下real server服务器端lvsrs脚本

由于lvs nat模式下,只有入站方向的流量通过lvs服务器,出站流量直接由Real server服务器响应,因此Real Server服务器必须作相应的配置才能响应客户数据包,即修改Real server作负载均衡时回包的源地址要改成VIP,另外要修改Real server的arp响应策略,关闭arp响应功能。bash

#!/bin/bash服务器

#description:start real server负载均衡

VIP=192.168.12.200ide

./etc/rc.d/init.d/functionsserver

case "$1" inip

   start)it

   echo " Start LVS of Real Server "io

   /sbin/ifconfig lo:0 $VIP broadcast $VIP netmask 255.255.255.255 upast

   echo "1" > /proc/sys/net/ipv4/conf/lo/arp_ignorefunction

   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

   ;;

   stop)

   /sbin/ifconfig lo:0 down

   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 "Usage:$0 {start|stop}"

   exit 1

 esac


经过service lvsrs {start|stop}开启或关闭lvsrs

相关文章
相关标签/搜索