iptables: Don't set empty defaults, check if var is defined

This commit is contained in:
Timo Makinen 2021-03-19 18:36:48 +00:00
parent 6acefc9178
commit a17cb88c1e
3 changed files with 8 additions and 7 deletions

View file

@ -1,6 +1,3 @@
---
firewall_in:
- {proto: tcp, port: 22}
firewall_raw: []

View file

@ -5,9 +5,11 @@
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p ipv6-icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
{% if firewall_raw6 is defined %}
{% for rule in firewall_raw6 %}
{{ rule }}
{% endfor %}
{% endif %}
{% for rule in firewall_in %}
{% if rule.from is defined %}
{% for from in rule.from | ipv6 %}

View file

@ -5,9 +5,11 @@
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
{% if firewall_raw is defined %}
{% for rule in firewall_raw %}
{{ rule }}
{% endfor %}
{% endif %}
{% for rule in firewall_in %}
{% if rule.from is defined %}
{% for from in rule.from | ipv4 %}