2023-11-20 12:03:19 +00:00
|
|
|
#!/usr/sbin/nft -f
|
|
|
|
|
|
|
|
flush ruleset
|
|
|
|
|
|
|
|
table inet filter {
|
2024-03-01 07:43:15 +00:00
|
|
|
set cluster {
|
|
|
|
type ipv4_addr; flags interval; auto-merge
|
|
|
|
elements = {
|
|
|
|
{{ nodes | map('device_address') | flatten | selectattr('family.value', '==', 4) | map(attribute='address') | join(',\n') | indent(12, first=True) }}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
set cluster/6 {
|
|
|
|
type ipv6_addr; flags interval; auto-merge
|
|
|
|
elements = {
|
|
|
|
{{ nodes | map('device_address') | flatten | selectattr('family.value', '==', 6) | map(attribute='address') | join(',\n') | indent(12, first=True) }}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
# Just a temporary filter until we get our shit together policy-wise.
|
2023-11-20 12:03:19 +00:00
|
|
|
set allowed {
|
2024-01-17 18:19:55 +00:00
|
|
|
type ipv4_addr; flags interval
|
2024-03-01 07:43:15 +00:00
|
|
|
elements = { 10.32.0.0/14, 193.2.76.176/24, 192.168.251.0/24, 88.200.23.0/24 }
|
2024-01-17 18:19:55 +00:00
|
|
|
}
|
|
|
|
set allowed/6 {
|
|
|
|
type ipv6_addr; flags interval
|
2024-03-01 07:43:15 +00:00
|
|
|
elements = { 2001:1470:fffd:3432::/64, 2001:1470:fffd:a000::/64 }
|
2023-11-20 12:03:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chain input {
|
|
|
|
type filter hook input priority filter; policy drop
|
|
|
|
|
|
|
|
ct state vmap { invalid : drop, established : accept, related : accept }
|
|
|
|
iif lo accept
|
|
|
|
|
2024-03-14 13:34:44 +00:00
|
|
|
ip protocol icmp icmp type {
|
|
|
|
echo-request, echo-reply, destination-unreachable,
|
|
|
|
parameter-problem, time-exceeded,
|
|
|
|
} accept comment "accept some ICMPv4"
|
|
|
|
|
|
|
|
ip6 nexthdr icmpv6 icmpv6 type {
|
|
|
|
echo-request, echo-reply, destination-unreachable,
|
|
|
|
packet-too-big, parameter-problem, time-exceeded,
|
|
|
|
} accept comment "accept some ICMPv6"
|
|
|
|
|
2023-11-20 12:03:19 +00:00
|
|
|
# BGP / BFD sessions
|
|
|
|
iif lan0 ip6 saddr fe80::/64 accept
|
|
|
|
iif lan1 ip6 saddr fe80::/64 accept
|
|
|
|
|
2024-05-18 16:35:41 +00:00
|
|
|
iifname mgmt accept comment "management access"
|
|
|
|
|
2024-03-01 07:43:15 +00:00
|
|
|
ip saddr @cluster accept comment "accept connections from other nodes"
|
|
|
|
ip6 saddr @cluster/6 accept comment "accept connections from other nodes"
|
|
|
|
|
2024-05-18 16:35:41 +00:00
|
|
|
ip saddr @allowed accept # TODO remove exceptions
|
|
|
|
ip6 saddr @allowed/6 accept # TODO remove exceptions
|
|
|
|
|
2024-11-08 15:32:06 +00:00
|
|
|
meta nfproto ipv6 tcp dport 80 accept comment "for certificate renewal"
|
|
|
|
|
2024-06-19 11:33:32 +00:00
|
|
|
{% for service in cluster_services %}
|
2024-04-05 04:12:58 +00:00
|
|
|
{% set prefixes = service | allowed_prefixes %}
|
|
|
|
{% set ports = service.ports | compact_numlist %}
|
|
|
|
# service {{ service.name }}
|
2024-08-03 09:44:03 +00:00
|
|
|
{% if prefixes | ipv4 %}
|
|
|
|
ip saddr { {{ prefixes | ipv4 | join(', ') }} } tcp dport { {{ ports }} } accept
|
2024-04-05 04:12:58 +00:00
|
|
|
{% endif %}
|
2024-08-03 09:44:03 +00:00
|
|
|
{% if prefixes | ipv6 %}
|
|
|
|
ip6 saddr { {{ prefixes | ipv6 | join(', ') }} } tcp dport { {{ ports }} } accept
|
2024-04-05 04:12:58 +00:00
|
|
|
{% endif %}
|
|
|
|
|
|
|
|
{% endfor %}
|
2023-11-20 12:03:19 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
chain forward {
|
|
|
|
type filter hook forward priority filter; policy accept
|
|
|
|
}
|
|
|
|
|
|
|
|
chain output {
|
|
|
|
type filter hook output priority filter; policy accept
|
|
|
|
}
|
|
|
|
}
|