Linux之lvs负载均衡【TUN模式】

######隧道TUN模式######

#在server1上
1.ipvsadm -C ##清除之前的规则

2.modprobe ipip ##添加隧道使用的模块

ip addr del 172.25.0.100/24 dev eth0
ip addr add 172.25.0.100/24 dev tunl0
ip link set up tunl0 ##删除原来网卡上的vip,添加到tunl0上,并激活

ipvsadm -A -t 172.25.0.100:80 -s rr
ipvsadm -a -t 172.25.0.100:80 -r 172.25.0.2:80 -i
ipvsadm -a -t 172.25.0.100:80 -r 172.25.0.3:80 -i ##添加隧道规则

#在server2和server3(rs)上
modprobe ipip ##添加tunl模块

ip addr del 172.25.0.100/32 dev eth0

ip addr add 172.25.0.100/32 dev tunl0 ##添加vip到tunl上

ip link set up tunl0 ##激活tunl0

sysctl -a | grep rp_filter ##查看反向过滤规则
sysctl -w net.ipv4.conf.default.rp_filter = 0
sysctl -w net.ipv4.conf.default.rp_filter=0
sysctl -w net.ipv4.conf.lo.rp_filter=0
sysctl -w net.ipv4.conf.eth0.rp_filter=0
sysctl -w net.ipv4.conf.tunl0.rp_filter=0 ##关闭反向过滤(如果开启,会对流入的数据包的反向路径进行校验,如果不符合要求,就 丢弃,设置为0则不进行校验)

sysctl -p ##使生效

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值