servers/roles/alpine/templates/local.nft.j2
Timotej Lazar 3261bc7f98 alpine: don’t hardcode nftables input rule for SSH
Instead configure it in NetBox like all other services.
2024-08-14 12:46:23 +02:00

23 lines
649 B
Django/Jinja

table inet filter {
chain input {
{% for service in services %}
{% set prefixes = service | allowed_prefixes %}
{% set ports = service.ports | compact_numlist %}
{% if 'name' in service %}
# service {{ service.name }}
{% endif %}
{% if prefixes %}
{% if prefixes | ipv4 %}
ip saddr { {{ prefixes | ipv4 | join(', ') }} } {{ service.protocol.value }} dport { {{ ports }} } accept
{% endif %}
{% if prefixes | ipv6 %}
ip6 saddr { {{ prefixes | ipv6 | join(', ') }} } {{ service.protocol.value }} dport { {{ ports }} } accept
{% endif %}
{% else %}
tcp dport { {{ ports }} } accept
{% endif %}
{% endfor %}
}
}