LVS的NAT模式

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

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
前期规则设置<br><br>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<br><br>192.168.80.120 RS1192.168.80.110 RS2<em id="__mceDel" style="font-size: 13px; font-family: "PingFang SC", "Helvetica Neue", Helvetica, Arial, sans-serif"><em id="__mceDel"><em id="__mceDel"> </em></em></em>

  

posted @   yuanbangchen  阅读(36)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 单元测试从入门到精通
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示