{% if ansible_prolog -%} {% from 'templates/ansible/prolog.j2' import prolog with context %} {{ prolog() }} {% endif -%} # # Configuration file for ferm(1). # @def $PORTS = ({{ firewall_public | join(' ') }}); # Services running worldwide table filter { chain INPUT { policy DROP; # connection tracking mod state state INVALID DROP; mod state state (ESTABLISHED RELATED) ACCEPT; # allow local packet interface lo ACCEPT; # respond to ping proto icmp icmp-type echo-request ACCEPT; # standard ports we allow from the outside proto (udp tcp) dport $PORTS ACCEPT; {% if firewall_private is defined %} # Private networks configuration {% for fwconf in firewall_private %} interface {{ fwconf.interface }}{% if fwconf.networks is defined %} saddr ({{ fwconf.networks | join(' ') }}){% endif %} { proto (udp tcp) dport ({{ fwconf.ports | join(' ') }}) ACCEPT; } {% endfor %} {% endif %} } chain OUTPUT { policy ACCEPT; # connection tracking #mod state state INVALID DROP; mod state state (ESTABLISHED RELATED) ACCEPT; {% if firewall_private is defined %} {% for fwconf in firewall_private %} {% if fwconf.users is defined %} # Private networks configuration mod owner uid-owner ({{ fwconf.users | join(' ') }}) outerface {{ fwconf.interface }} ACCEPT; outerface {{ fwconf.interface }} DROP; {% endif %} {% endfor %} {% endif %} } chain FORWARD { policy DROP; # connection tracking mod state state INVALID DROP; mod state state (ESTABLISHED RELATED) ACCEPT; } } domain ip6 table filter { chain INPUT { policy DROP; # connection tracking mod state state INVALID DROP; mod state state (ESTABLISHED RELATED) ACCEPT; # allow local packet interface lo ACCEPT; # allow ICMP (for neighbor solicitation, like ARP for IPv4) proto ipv6-icmp ACCEPT; # standard ports we allow from the outside proto (udp tcp) dport $PORTS ACCEPT; } chain OUTPUT { policy ACCEPT; # connection tracking #mod state state INVALID DROP; mod state state (ESTABLISHED RELATED) ACCEPT; } chain FORWARD { policy DROP; # connection tracking mod state state INVALID DROP; mod state state (ESTABLISHED RELATED) ACCEPT; } }