diff --git a/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v4.j2 b/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v4.j2 index b9e1221..9345991 100644 --- a/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v4.j2 +++ b/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v4.j2 @@ -22,7 +22,10 @@ # Host specific rules {% for host in iptables_allowed_hosts %} -{% for addr in host.hostname | dns_a %} +{% if host['address'] | ipv4 %} +-A INPUT {% if host['protocol'] == 'tcp' %}-m state --state NEW {% endif %}-m {{ host['protocol'] }} -p {{ host['protocol'] }} -s {{ host['address'] | ipv4 }} --dport {{ host['port'] }} -j ACCEPT +{% endif %} +{% for addr in host['address'] | dns_a %} -A INPUT {% if host['protocol'] == 'tcp' %}-m state --state NEW {% endif %}-m {{ host['protocol'] }} -p {{ host['protocol'] }} -s {{ addr | ipv4 }} --dport {{ host['port'] }} -j ACCEPT {% endfor %} {% endfor %} diff --git a/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v6.j2 b/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v6.j2 index 7386ec4..3bd57ce 100644 --- a/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v6.j2 +++ b/playbooks/bootstrap/roles/iptables/templates/etc/iptables/rules.v6.j2 @@ -22,7 +22,10 @@ # Host specific rules {% for host in iptables_allowed_hosts %} -{% for addr in host.hostname | dns_aaaa %} +{% if host['address'] | ipv6 %} +-A INPUT {% if host['protocol'] == 'tcp' %}-m state --state NEW {% endif %}-m {{ host['protocol'] }} -p {{ host['protocol'] }} -s {{ host['address'] | ipv6 }} --dport {{ host['port'] }} -j ACCEPT +{% endif %} +{% for addr in host['address'] | dns_aaaa %} -A INPUT {% if host['protocol'] == 'tcp' %}-m state --state NEW {% endif %}-m {{ host['protocol'] }} -p {{ host['protocol'] }} -s {{ addr | ipv6 }} --dport {{ host['port'] }} -j ACCEPT {% endfor %} {% endfor %}