实验环境:
Direcotr:
Server1(调度器):eth0:172.25.7.1/24 tunl0:172.25.7.100/24
Realserver:
Server2(服务器):eth0:172.25.7.2 tunl0:172.25.7.100/24
Server3(服务器):eth0:172.25.7.3 tunl0:172.25.7.100/24
Client:172.25.7.250
在server1中设置如下:
[root@server1 ~]# modprobe ipip
[root@server1 ~]#ip link set up tunl0
[root@server1 ~]#ip addr add 172.25.7.100/24 dev tunl0
添加rules: -i 表示tun方式
[root@server1 ~]# ipvsadm -A -t 172.25.7.100:80 -s rr
[root@server1 ~]# ipvsadm -a -t 172.25.7.100:80 -r 172.25.7.3:80 -i
[root@server1 ~]# ipvsadm -a -t 172.25.7.100:80 -r 172.25.7.2:80 -i
在server2中设置如下:
[root@server2 ~]#modprobe ipip
[root@server2 ~]#ip link set up tunl0
[root@server2 ~]#ip addr add 172.25.7.100/24 dev tunl0
[root@server2 ~]#/etc/init.d/arptables_jf start
[root@server2 ~]#sysctl -w net.ipv4.conf.tunl0.rp_filter=0
设置arp抑制如下:
##对input进行拒绝
[root@server2 ~]# arptables -A IN -d 172.25.7.100 -j DROP
##对output进行伪装
[root@server2 ~]# arptables -A OUT -s 172.25.7.100 -j mangle --mangle-ip-s 172.25.7.2
[root@server2 ~]# /etc/init.d/arptables_jf save
在server3中设置如下:
[root@server3 ~]#modprobe ipip
[root@server3 ~]#ip link set up tunl0
[root@server3 ~]#ip addr add 172.25.7.100/24 dev tunl0
[root@server3 ~]#/etc/init.d/arptables_jf start
[root@server3 ~]#sysctl -w net.ipv4.conf.tunl0.rp_filter=0
设置arp抑制如下:
##对input进行拒绝
[root@server3 ~]# arptables -A IN -d 172.25.7.100 -j DROP
##对output进行伪装
[root@server2 ~]# arptables -A OUT -s 172.25.7.100 -j mangle --mangle-ip-s 172.25.7.3
[root@server2 ~]# /etc/init.d/arptables_jf save
测试:在client访问vip