only block traffic on external interfaces

master
Michael Wilson 3 years ago
parent fae1992c19
commit 60d991ff48
  1. 4
      linux/nftables/defaults/main.yml
  2. 6
      linux/nftables/templates/nftables.conf

@ -1,5 +1,5 @@
nftables_whitelisted_interfaces: nftables_external_interfaces:
- lo - ens3
nftables_tcp_in: nftables_tcp_in:
- 22 - 22
- 80 - 80

@ -31,9 +31,13 @@ table inet firewall {
# Allow traffic from established and related packets, drop invalid # Allow traffic from established and related packets, drop invalid
ct state vmap { established : accept, related : accept, invalid : drop } ct state vmap { established : accept, related : accept, invalid : drop }
{% for interface in nftables_whitelisted_interfaces %} {% if nftables_external_interfaces is defined %}
{% for interface in ansible_interfaces %}
{% if interface not in nftables_blacklisted_interfaces %}
iifname {{ interface }} accept iifname {{ interface }} accept
{% endif %}
{% endfor %} {% endfor %}
{% endif %}
# Jump to chain according to layer 3 protocol using a verdict map # Jump to chain according to layer 3 protocol using a verdict map
meta protocol vmap { ip : jump inbound_ipv4, ip6 : jump inbound_ipv6 } meta protocol vmap { ip : jump inbound_ipv4, ip6 : jump inbound_ipv6 }

Loading…
Cancel
Save