LVS的NAT模式

原理查看 https://www.cnblogs.com/Yuanbangchen/p/16533261.html

  

前期规则设置

CIP:192.168.10.50 LVS:192.168.10.100(VIP 对外)  192.168.80.100(DIP 对内) server2(RS): 192.168.80.110 gateway: 192.168.80.100 server3(RS): 192.168.80.120 gateway: 192.168.80.100 1.LVS服务器设置 a:director服务器上开启路由转发功能: vim /etc/sysctl.conf net.ipv4.ip_forward = 1 sysctl -p b:director设置 nat 防火墙: iptables -t nat -A POSTROUTING -s 192.168.0.0/24 -j MASQUERADE#测试中没用设置 c:director设置: ipvsadm IPVSADM -A -t 192.168.10.100:80 -s wrr IPVSADM -a -t 192.168.10.100:80 -r 192.168.80.110:80 -m -w 1 IPVSADM -a -t 192.168.10.100:80 -r 192.168.80.120:80 -m -w 1 2.web服务器设置:安装httpd echo 192.168.80.110 RS1 > /var/www/html/index.html echo 192.168.80.120 RS2 > /var/www/html/index.html systemctl start httpd 3.客户端访问 while true ; do curl http://192.168.10.100 ;sleep 1; done

192.168.80.120 RS1
192.168.80.110 RS2
 

  

posted @ 2022-08-02 14:32  yuanbangchen  阅读(22)  评论(0编辑  收藏  举报