6、LVS DR模式配置
(1)客户端配置
eth0(ip):172.17.10.252
网关(GW):172.17.10.250
(2)防火墙配置
eth0:172.17.10.250
eth1:192.168.10.1
eth1:0 192.168.20.1
# vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
# sysctl -p
# iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 80 -j DNAT --to 192.168.10.10
# service iptables save
(3)调度服务器配置
# ipvsadm -A -t 192.168.10.10:80 -s wrr -p 300
# ipvsadm -a -t 192.168.10.10:80 -r 192.168.20.21:80 -g -w 2
# ipvsadm -a -t 192.168.10.10:80 -r 192.168.20.22:80 -g -w 3
(4)真是服务器(RS1)配置
eth0:192.168.20.21
VIP:192.168.10.10
配置真实服务器进行arp广播和回应
# vim /etc/sysctl.conf
net.ipv4.conf.lo.arp_ignore = 1
net.ipv4.conf.lo.arp_announce = 2
net.ipv4.conf.all.arp_ignore = 1
net.ipv4.conf.all.arp_announce = 2
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
# rpm -ivh arptables_jf*
# arptables -A IN -d 192.168.10.10 -j DROP
# ifconfig lo:0 192.168.10.10 netmask 255.255.255.0 broadcast 192.168.10.10
# route add -host 192.168.10.10 dev lo:0
原文地址:http://office580.blog.51cto.com/4708529/1633900