1、LVS的跨网络DR实现
IP 服务 192.168.0.7 Internet 192.168.0.17、172.16.0.17 Router 172.16.0.27、172.16.0.100 LVS 172.16.0.37、172.16.0.100 RS1 172.16.0.47、172.16.0.100 RS2
# Internet
[ root@internet ~ ] # vim / etc/ sysconfig/ network- scripts/ ifcfg- eth0
DEVICE= eth0
NAME= eth0
BOOTPROTO= static
IPADDR= 192.168 . 0.7
PREFIX= 24
GATEWAY= 192.168 . 0.17
ONBOOT= yes
# Router
[ root@router ~ ] # vim / etc/ sysctl. conf
net. ipv4. ip_forward= 1
[ root@router ~ ] # sysctl - p
[ root@router network- scripts] #vim ifcfg- eth0
DEVICE= eth0
NAME= eth0
BOOTPROTO= static
IPADDR= 172.16 . 0.17
PREFIX= 24
ONBOOT= yes
[ root@router network- scripts] #vim ifcfg- eth1
DEVICE= eth1
NAME= eth1
BOOTPROTO= static
IPADDR= 192.168 . 0.17
PREFIX= 24
ONBOOT= yes
# LVS
[ root@lvs ~ ] # vim / etc/ sysconfig/ network- scripts/ ifcfg- ens32
DEVICE= eth0
NAME= eth0
BOOTPROTO= static
IPADDR= 172.16 . 0.27
PREFIX= 24
GATEWAY= 172.16 . 0.17
ONBOOT= yes
# RS1
[ root@lvs ~ ] # vim / etc/ sysconfig/ network- scripts/ ifcfg- ens32
DEVICE= eth0
NAME= eth0
BOOTPROTO= static
IPADDR= 172.16 . 0.37
PREFIX= 24
GATEWAY= 172.16 . 0.17
ONBOOT= yes
[ root@rs1 ~ ] #yum - y install httpd
[ root@rs1 ~ ] #systemctl enable -- now httpd
[ root@rs1 ~ ] #hostname - I > / var/ www/ html/ index. html
# RS2
[ root@lvs ~ ] # vim / etc/ sysconfig/ network- scripts/ ifcfg- ens32
DEVICE= eth0
NAME= eth0
BOOTPROTO= static
IPADDR= 172.16 . 0.47
PREFIX= 24
GATEWAY= 172.16 . 0.17
ONBOOT= yes
[ root@rs2 ~ ] #yum - y install httpd
[ root@rs2 ~ ] #systemctl enable -- now httpd
[ root@rs2 ~ ] #hostname - I > / var/ www/ html/ index. html
# LVS
[ root@lvs ~ ] # ip a add 172.16 . 0.100 / 32 dev lo
[ root@lvs ~ ] # yum - y install ipvsadm
[ root@lvs ~ ] # ipvsadm - A - t 172.16 . 0.100 : 80 - s rr
[ root@lvs ~ ] # ipvsadm - a - t 172.16 . 0.100 : 80 - r 172.16 . 0.37 : 80 - g
[ root@lvs ~ ] # ipvsadm - a - t 172.16 . 0.100 : 80 - r 172.16 . 0.47 : 80 - g
# RS1
[ root@rs1 ~ ] # echo 1 > / proc/ sys/ net/ ipv4/ conf/ all/ arp_ignore
[ root@rs1 ~ ] # echo 2 > / proc/ sys/ net/ ipv4/ conf/ all/ arp_announce
[ root@rs1 ~ ] # echo 2 > / proc/ sys/ net/ ipv4/ conf/ lo/ arp_announce
[ root@rs1 ~ ] # echo 1 > / proc/ sys/ net/ ipv4/ conf/ lo/ arp_ignore
[ root@rs1 ~ ] # ip a add 172.16 . 0.100 / 32 dev lo
# RS2
[ root@rs2 ~ ] # echo 1 > / proc/ sys/ net/ ipv4/ conf/ all/ arp_ignore
[ root@rs2 ~ ] # echo 2 > / proc/ sys/ net/ ipv4/ conf/ all/ arp_announce
[ root@rs2 ~ ] # echo 1 > / proc/ sys/ net/ ipv4/ conf/ lo/ arp_ignore
[ root@rs2 ~ ] # echo 2 > / proc/ sys/ net/ ipv4/ conf/ lo/ arp_announce
[ root@rs2 ~ ] # ip a add 172.16 . 0.100 / 32 dev lo
#测试访问
[ root@internet ~ ] # curl http:
172.16 . 0.47
[ root@internet ~ ] # curl http:
172.16 . 0.37