LVS的跨网络DR实现

实验环境
CentOS8 *4
Router
地址:eth1外网:192.168.0.200/24
eth2内网:172.16.0.200/24
LVS:Lo VIP:172.16.0.100/32
eth1:10.0.0.200
RS1: Lo VIP:172.16.0.100/32
eth1:RIP1:10.0.0.7/24
GW:10.0.0.200
RS1: Lo VIP:172.16.0.100/32
eth1:RIP1:10.0.0.17/24
GW:10.0.0.200
测试机: 192.168.0.6/24
GW:192.168.0.200

实验
设置router可通过ipv4报文

[root@Router ~]# echo 'net.ipv4.ip_forward=1' >> /etc/sysctl.conf
[root@Router ~]# sysctl -p
net.ipv4.ip_forward = 1

设置route ip地址

[root@Router ~]# ip add add 192.168.0.200/24 dev eth1
[root@Router ~]# ip add add 172.16.0.200/24 dev eth2
[root@Router ~]# ip add add 10.0.0.200/24 dev eth2

设置internet,与LVS,RS1,RS2地址

internet
  ip add add 192.168.0.6/24 dev eth1
LVS
  ip add add 10.0.0.8/24 dev eth1
  ip add add 172.16.0.100/32 dev lo
  ip route add default via 10.0.0.200
RS1
  ip add add 172.16.0.100/32 dev lo
  ip add add 10.0.0.7/24 dev eth1
  ip route add default via 10.0.0.200
RS2
  ip add add 172.16.0.100/32 dev lo
  ip add add 10.0.0.7/24 dev eth1
  ip route add default via 10.0.0.200
internet client
[root@internet ~]# ip route add default via 192.168.0.200
[root@internet ~]# ping 10.0.0.8
PING 10.0.0.8 (10.0.0.8) 56(84) bytes of data.
64 bytes from 10.0.0.8: icmp_seq=1 ttl=63 time=1.87 ms
64 bytes from 10.0.0.8: icmp_seq=2 ttl=63 time=0.691 ms
64 bytes from 10.0.0.8: icmp_seq=3 ttl=63 time=0.732 ms
64 bytes from 10.0.0.8: icmp_seq=4 ttl=63 time=0.799 ms
^C
--- 10.0.0.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 86ms
rtt min/avg/max/mdev = 0.691/1.023/1.870/0.490 ms

LVS配置

[root@LVS ~]# ipvsadm -A -t 172.16.0.100:80 -s wrr
[root@LVS ~]# ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.7 -g -w 1
[root@LVS ~]# ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.17 -g -w 1

RS配置

echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce

测试

[root@internet ~]# curl 172.16.0.100
10.0.0.17
[root@internet ~]# curl 172.16.0.100
10.0.0.7

你可能感兴趣的:(LVS的跨网络DR实现)