六、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
vim