linux防火墙下允许keepalived组播

   最近在两台linux服务器里面安装keepalived,配置好后发现两台机器都是master状态,网上搜索发现是防火墙没有允许vrrp的组播,两台服务器分别是centos7和suse系统
上网找了很久才找到这两个系统下开放vrrp组播的方法,特此记之。


使用keepalived组播的话需要修改防火墙设置:

centos 6下面修改防火墙
vi /etc/sysconfig/iptables  增加这个
-A INPUT -p 112 -d 224.0.0.0/32 -j ACCEPT           #-p 112指定协议为112,也可-p vrrp即vrrp,keepalived组播地址是224.0.0.18

centos7下面改防火墙
firewall-cmd --direct --permanent --add-rule ipv4 filter INPUT 0 --in-interface enp4s0 --destination 224.0.0.18 --protocol vrrp -j ACCEPT
firewall-cmd --reload

suse下面修改防火墙
vi  /etc/sysconfig/SuSEfirewall2
将下面这行的注释去掉
FW_CUSTOMRULES="/etc/sysconfig/scripts/SuSEfirewall2-custom"     
并将下面这行注释掉
FW_CUSTOMRULES="" 

然后
vi /etc/sysconfig/scripts/SuSEfirewall2-custom

fw_custom_before_antispoofing() {
    # these rules will be loaded before any anti spoofing rules will be
    # loaded. Effectively the only filter lists already effective are
    # 1) allow any traffic via the loopback interface, 2) allow DHCP stuff,
    # 3) allow SAMBA stuff [2 and 3 only if FW_SERVICE_... are set to "yes"]
    # You can use this hook to prevent logging of uninteresting broadcast
    # packets or to allow certain packet through the anti-spoofing mechanism.

#example: allow incoming multicast packets for any routing protocol
#iptables -A INPUT  -j ACCEPT -d 224.0.0.0/24
#添加下面这行
iptables -A INPUT -p vrrp -j ACCEPT -d 224.0.0.18
   true
    }


修改防火墙后记得重启防火墙。
然后再看系统的ip地址,发现恢复正常,只有一台机器是master状态了。

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值