LVS的TUN模式-隧道模式
内核反向路径校验
server1:
ipvsadm -c 清除策略
modprobe ipip 添加ipip模块
ip addr del 172.25.29.100/24 dev eth0 在eth0网卡上删掉vip
ip addr add 172.25.29.100/24 dev tunl0 在隧道网卡上添加vip
ip link set up tunl0 激活(是unknow,只要不是down就可以)
ipvsadm -A -t 172.25.29.100:80 -s rr
ipvsadm -a -t 172.25.29.100:80 -r 172.25.29.2:80 -i -i 隧道模式
ipvsadm -a -t 172.25.29.100:80 -r 172.25.29.3:80 -i
server2和server3:
modprobe ipip 添加隧道模块
ip addr del 172.25.29.100/32 dev eth0
ip addr add 172.25.29.100/32 dev tunl0
ip link set up tunl0
sysctl -a |grep rp_filter 查看过滤表
sysctl -w net.ipv4.conf.all.rp_filter=0 将所有的过滤规则都关闭
sysctl -w net.ipv4.conf.default.rp_filter=0
sysctl -w net.ipv4.conf.eth0.rp_filter=0
sysctl -w net.ipv4.conf.tunl0.rp_filter=0
sysctl -p 使设置生效
真机测试:
curl 172.25.38.100