1、LVS的跨网络DR实现
网络配置
client 192.168.120.102
route 10.0.0.103/192.168.120.100/172.16.0.200
lvs 10.0.0.10
rs1 10.0.0.100
rs2 10.0.0.101
http服务配置
RS1
[root@zuoye1 ~]# echo `hostname -I` > /var/www/html/index.html
[root@zuoye1 ~]# systemctl start httpd
[root@zuoye1 ~]# curl 10.0.0.100
10.0.0.100
RS2
[root@zuoye2 ~]# echo `hostname -I` > /var/www/html/index.html
[root@zuoye2 ~]# systemctl start httpd
[root@zuoye2 ~]# curl 10.0.0.101
10.0.0.101
lvs 配置
RS1
[root@zuoye1 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[root@zuoye1 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[root@zuoye1 ~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
[root@zuoye1 ~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
[root@zuoye1 ~]# ifconfig lo:1 172.16.0.100/32
RS2
[root@zuoye2 ~]# echo 1 > /proc/sys/net/ipv4/conf/all/arp_ignore
[root@zuoye2 ~]# echo 2 > /proc/sys/net/ipv4/conf/all/arp_announce
[root@zuoye2 ~]# echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignore
[root@zuoye2 ~]# echo 2 > /proc/sys/net/ipv4/conf/lo/arp_announce
[root@zuoye2 ~]# ifconfig lo:1 172.16.0.100/32
LVS
[root@rac1 ~]# ifconfig lo:1 172.16.0.100/32
[root@rac1 ~]# yum install -y ipvsadm
[root@rac1 ~]# ipvsadm -A -t 172.16.0.100:80 -s wrr
[root@rac1 ~]# ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.100:80 -g -w 1
[root@rac1 ~]# ipvsadm -a -t 172.16.0.100:80 -r 10.0.0.101:80 -g -w 1
[root@rac1 ~]# ipvsadm -Ln
IP Virtual Server version 1.2.1 (size=4096)
Prot LocalAddress:Port Scheduler Flags
-> RemoteAddress:Port Forward Weight ActiveConn InActConn
TCP 172.16.0.100:80 wrr
-> 10.0.0.100:80 Route 1 0 0
-> 10.0.0.101:80 Route 1 0 0
测试
[root@zuoye3 ~]# curl 172.16.0.100
10.0.0.101
[root@zuoye3 ~]# curl 172.16.0.100
10.0.0.100
[root@zuoye3 ~]# curl 172.16.0.100
10.0.0.101
[root@zuoye3 ~]# curl 172.16.0.100
10.0.0.100
[root@zuoye3 ~]# curl 172.16.0.100
10.0.0.101
[root@zuoye3 ~]# curl 172.16.0.100
10.0.0.100