【问题标题】:Migrating from iptables to firewalld settings with ansible in CentOS 7在 CentOS 7 中使用 ansible 从 iptables 迁移到 firewalld 设置
【发布时间】:2019-01-14 18:34:12
【问题描述】:

我正在我的网络服务器上设置一个新的 Redis 集群,目前我正在使用 iptables 设置添加一些链式规则,但现在我正在切换到通过 ansible 自动部署。

我的 iptables 是这样的:

1 iptables -N REDIS
2 iptables -A REDIS -s 10.0.1.11 -j ACCEPT  ## Master server
3 iptables -A REDIS -s 10.0.1.10 -j ACCEPT  ## Slave 01/03
4 iptables -A REDIS -j LOG --log-prefix "unauth-redis-access"
5 iptables -A REDIS -j REJECT --reject-with icmp-port-unreachable
6 iptables -I INPUT -p tcp --dport 6379 -j REDIS

这样,我必须手动将规则 #3 添加到每个从服务器(目前只有 3 个从服务器,但在某些时候会更多,因此,我计划自动部署它通过ansible)。

我设置的 ansible 配置如下所示:

- name: Redis service
  tags: ['redis']
  firewalld:
        service=redis
        zone=internal
        state=enabled
        permanent=yes

- name: Redis connections
  tags: ['redis']
  firewalld:
        source=10.0.1.0/24
        port=6379/tcp
        zone=internal
        state=enabled
        permanent=yes
  notify: restart redis

我使用我的网络服务器的子网作为源,还是应该列出每个网络服务器的 ip 作为源?

虽然当我部署 ansible 配置时,它根本不起作用。使用 iptables 效果很好,但由于上面提到的 dev-env 问题,我必须将其切换到 firewalld。

有什么想法吗?

【问题讨论】:

  • 您能否更具体地了解“它根本不起作用”。鉴于这可能需要重点关注,而且没有任何细节,它的原因可能有很多,很难知道从哪里开始提供帮助。
  • 哦,对不起。当我这样设置时,当我尝试将奴隶连接到主人时,它说无法连接/无法到达主机。所以基本上就像这些设置根本不起作用
  • 所以firewalld只是对iptables的一个包装,所以你仍然可以使用iptables来检查firewalld已经实现的规则,那么你能检查一下Ansible添加了哪些规则吗?如果您的 firewalld 是默认设置,我建议您的规则需要进入“公共”区域,而不是“内部”。 (除非您在充当路由器的多宿主计算机上,否则区域名称是违反直觉的)

标签: redis centos ansible firewall iptables


【解决方案1】:

尝试添加immediate=yes 或添加服务处理程序以重新加载firewalld。 使用带有permanent=yes 的firewalld 只会更改配置文件,它不会安装iptables-rules

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2015-12-18
    • 2023-04-04
    • 2015-08-20
    • 1970-01-01
    • 2014-09-05
    • 1970-01-01
    • 2020-05-22
    • 1970-01-01
    相关资源
    最近更新 更多