NAT模式
当客户端为桥接,两台后台真实服务器,需要一台负载均衡器,后台服务器添加转发,转发到lvs的同网段ip,lvs
服务器做本地路由转发,ipvsadm添加即可。
lvs:192.168.107.180
RS1:192.168.107.181
RS2:192.168.107.182
1.lvs服务器上做本地路由转发,vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
wq保存之后,sysctl –p。
配置ipvsadm:
ipvsadm –A –t 192.168.107.180:80 –s rr
ipvsadm –a –t 192.168.107.180:80 –r 192.168.107.181:80 –m
ipvsadm –a –t 192.168.107.180:80 –r 192.168.107.182:80 –m
2.在RS服务器上配置ip转发,ip route add default via 192.168.107.180即可
NAT模式就配好了
DR模式
三台机器要在同一网段,隐藏后台真实服务器。
lvs:192.168.107.180
RS1:192.168.107.181
RS2:192.168.107.182
lvs:ip addr add dev ens33 192.168.107.200/32
ipvsadm –A –t 192.168.107.200:80 –s rr
ipvsadm –a –t 192.168.107.200:80 –r 192.168.107.181:80 –g
ipvsadm –a –t 192.168.107.200:80 –r 192.168.107.182:80 –g
RS:ip addr add dev lo 192.168.107.200/32
echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce