LVS NAT模式配置

LVS Server

# 外网IP:10.10.10.1 内网IP:172.25.25.3
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
iptables -t nat -I POSTROUTING -s 172.25.25.0/24 -o eth0 -j SNAT --to-source 10.10.10.1
[root@localhost ~]# ipvsadm -A -t 10.10.10.1:80 -s rr -p 5
[root@localhost ~]# ipvsadm -a -t 10.10.10.1:80 -r 172.25.25.4:80 -m
[root@localhost ~]# ipvsadm -a -t 10.10.10.1:80 -r 172.25.25.5:80 -m
[root@localhost ~]# ipvsadm -S
[root@localhost ~]# ipvsadm -Ln
[root@localhost ~]# ipvsadm -Ln --stats

RealServer

# RIP(真实IP/内网IP):172.25.25.4
# RIP(真实IP/内网IP):172.25.25.5
[root@localhost ~]# route add default gw 172.25.25.3
posted @ 2021-04-28 19:26  wanghongwei-dev  阅读(55)  评论(0编辑  收藏  举报