dubzland.shorewall

Dubzland: Shorewall

Gitlab 管道状态(自托管)

安装并配置 Shorewall 防火墙构建工具。

要求

需要 Ansible 版本 2.0 或更高。需要安装 netaddr python 包。

角色变量

可用变量如下所列,并带有默认值(更多信息请参见 defaults/main.yml):

dubzland_shorewall_conf

dubzland_shorewall_conf:
  startup_enabled: "是"
  verbosity: 1
  log_level: '"info"'
  log_martians: "是"
  log_verbosity: 2
  log_zone: Both
  logfile: /var/log/shorewall
  logformat: '"%s(%d) %s "'

/etc/shorewall/shorewall.conf 中设置的选项。选项名称可以使用大写或小写(将以大写写入文件)。有关更多信息,请参见 shorewall.conf 手册

dubzland_shorewall_params

dubzland_shorewall_params: []

要写入 /etc/shorewall/params 的键值对列表。有关使用参数的更多信息,请参见 params 手册

dubzland_shorewall_zones

dubzland_shorewall_zones:
  - name: fw
    type: 防火墙
  - name: net
    type: ipv4
  - name: lan
    type: ipv4

/etc/shorewall/zones 中声明的区域。有关更多信息,请参见 zones 手册

dubzland_shorewall_interfaces

dubzland_shorewall_interfaces:
  - name: eth0
    zone: net
    options:
      - tcpflags
      - nosmurfs
      - routefilter
      - "sourceroute=0"
  - name: eth1
    zone: lan
    options:
      - tcpflags
      - nosmurfs
      - routefilter

要在 /etc/shorewall/interfaces 中配置的接口列表。有关更多信息,请参见 interfaces 手册

dubzland_shorewall_hosts

dubzland_shorewall_hosts: []

指定防火墙机器可路由但不直接可访问的主机。

dubzland_shorewall_policies

dubzland_shorewall_policies:
  - source: "$FW"
    dest: all
    policy: 接受
  - source: net
    dest: all
    policy: 拒绝
  - source: all
    dest: all
    policy: 拒绝
    log_level: info

由 Shorewall 使用的策略,用于根据数据包的区域遍历确定默认行为。有关更多信息,请参见 policy 手册

dubzland_shorewall_snat

dubzland_shorewall_snat:
  - action: MASQUERADE
    dest: eth0

为 iptables 配置 SNAT/伪装。如果您想对出站流量执行网络地址转换(NAT),则需要此配置。有关更多信息,请参见 snat 手册

dubzland_shorewall_rules

dubzland_shorewall_rules:
  - section: NEW
    rulesets:
      - comment: PINGS
        rules:
          - action: Ping(接受)
            source: all
            dest: all
      - comment: 网页流量
        rules:
          - action: Web(接受)
            source: $FW,lan
            dest: net

此角色的核心部分。配置 Shorewall 使用的规则,以确定如何处理穿过其监控接口的数据包。有关更多信息,请参见 rules 手册

依赖项

无。

示例剧本

假设一台机器有两个网卡(eth0 在互联网,eth1 在 LAN):

- hosts: firewall
  become: yes
  roles:
    - role: dubzland-shorewall
      vars:
        dubzland_shorewall_zones:
          - name: fw
            type: 防火墙
          - name: net
            type: ipv4
          - name: lan
            type: ipv4
        dubzland_shorewall_interfaces:
          - name: eth0
            zone: net
            options:
              - tcpflags
              - nosmurfs
              - routefilter
              - "sourceroute=0"
          - name: eth1
            zone: lan
            options:
              - tcpflags
              - nosmurfs
              - routefilter
        dubzland_shorewall_policies:
          - source: "$FW"
            dest: all
            policy: 接受
          - source: net
            dest: all
            policy: 拒绝
          - source: all
            dest: all
            policy: 拒绝
            log_level: info
        dubzland_shorewall_snat:
          - action: MASQUERADE
            dest: eth0
        dubzland_shorewall_rules:
          - section: NEW
            rulesets:
              - comment: Ping
                rules:
                  - action: Ping(接受)
                    source: all
                    dest: all
              - comment: 网络浏览
                rules:
                  - action: Web(接受)
                    source: lan
                    dest: net
                  - action: 接受
                    source: lan
                    dest: net
                    proto: udp
                    dest_ports:
                      - 80
                      - 443

这将允许所有人 ping 防火墙机器,并允许 LAN 客户端 ping 互联网主机。所有 LAN 客户端也可以浏览网页。

许可证

MIT

作者

关于项目

Shorewall for Debian

安装
ansible-galaxy install dubzland.shorewall
许可证
mit
下载
74
拥有者
A lone greybeard