initial commit

This commit is contained in:
nd 2020-04-30 13:51:19 +02:00
commit 88b851cfff
No known key found for this signature in database
GPG key ID: 21B5CD4DEE3670E9
4 changed files with 109 additions and 0 deletions

View file

@ -0,0 +1,56 @@
#jinja2:lstrip_blocks: True
#!/usr/sbin/nft -f
{%- macro nftrule(name, rule) -%}
{{rule.matches }} {{ rule.statement }} comment "{{ name }}"
{% endmacro %}
{%- macro nftchain(name) -%}
{% for i in firewall.chains[name] %}
{% if not firewall.chains[name][i] is mapping %}
{% set tmprule = { 'matches': firewall.chains[name][i] }%}
{% else %}
{% set tmprule = firewall.chains[name][i] %}
{% endif%}
{% set rule = {}|combine(firewall.defaults.all, firewall.defaults[name], tmprule, recursive=True) %}
{{ nftrule(i, rule) }}
{% endfor %}
{% endmacro%}
flush ruleset
table inet filter {
chain input {
type filter hook input priority 0;
policy {{ firewall.policies.input }};
iif lo accept comment "Accept any localhost traffic"
ct state invalid drop comment "Drop invalid connections"
ct state established,related accept comment "Accept traffic originated from us"
ip6 nexthdr icmpv6 accept comment "Accept ICMPv6"
ip protocol icmp accept comment "Accept ICMP"
ip protocol igmp accept comment "Accept IGMP"
{{ nftchain('input') }}
counter comment "Count dropped"
}
chain forward {
type filter hook forward priority 0;
policy {{ firewall.policies.forward }};
{{ nftchain('forward') }}
counter comment "Count dropped"
}
chain output {
type filter hook output priority 0;
policy {{ firewall.policies.output }};
{{ nftchain('output') }}
}
}
include "/etc/nftables/*.nft"