From 24616de43c39da3fe7efd72426fce078a3afdaea Mon Sep 17 00:00:00 2001 From: Guilhem Moulin Date: Tue, 3 Nov 2020 02:26:43 +0100 Subject: Firewall: Move IPsec/ICMP/ICMPv6 rules to ingress chain. This is required to receive incoming traffic to our IPsec IP in 172.16.0.0/24, as well as linked-scoped ICMPv6 traffic from/to fe80::/10 (for neighbour discovery). Regression from a6b8c0b3a4758f8d84a7ad07bb9e068075d098d3. --- roles/common/templates/etc/nftables.conf.j2 | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'roles/common/templates') diff --git a/roles/common/templates/etc/nftables.conf.j2 b/roles/common/templates/etc/nftables.conf.j2 index d788457..bbc0e7c 100755 --- a/roles/common/templates/etc/nftables.conf.j2 +++ b/roles/common/templates/etc/nftables.conf.j2 @@ -53,6 +53,20 @@ table netdev filter { type filter hook ingress device {{ if }} priority -499 policy accept + # IPsec traffic (refined later in the filter rule) + ip saddr {{ ipsec_subnet }} ip daddr {{ ipsec[inventory_hostname_short] }} meta secpath exists accept + + # rate-limiting is done directly by the kernel (net.ipv4.icmp_{ratelimit,ratemask} runtime options) + icmp type { echo-reply, echo-request, destination-unreachable } counter accept + icmpv6 type { echo-reply, echo-request, destination-unreachable, + packet-too-big, time-exceeded, parameter-problem } counter accept + + # accept neighbour discovery for autoconfiguration, RFC 4890 sec. 4.4.1 + ip6 hoplimit 255 icmpv6 type { 133,134,135,136,141,142 } counter accept + + # reject all remaining ICMP/ICMPv6 traffic + meta l4proto { icmp, icmpv6 } drop + # bogon filter (cf. RFC 6890 for non-global ip addresses) define bogon = { 0.0.0.0/8 # this host, on this network (RFC 1122 sec. 3.2.1.3) @@ -151,13 +165,7 @@ table inet filter { # ip saddr {{ ipsec_subnet }} ip daddr {{ ipsec[inventory_hostname_short] }} ipsec in reqid $i accept ip saddr {{ ipsec_subnet }} ip daddr {{ ipsec[inventory_hostname_short] }} meta secpath exists accept - # rate-limiting is done directly by the kernel (net.ipv4.icmp_{ratelimit,ratemask} runtime options) - icmp type { echo-reply, echo-request, destination-unreachable } counter accept - icmpv6 type { echo-reply, echo-request, destination-unreachable, - packet-too-big, time-exceeded, parameter-problem } counter accept - - # accept neighbour discovery for autoconfiguration, RFC 4890 sec. 4.4.1 - icmpv6 type { 133,134,135,136,141,142 } ip6 hoplimit 255 counter accept + meta l4proto { icmp, icmpv6 } counter accept udp sport 123 udp dport 123 ct state related,established accept {% if groups.all | length > 1 %} @@ -195,7 +203,7 @@ table inet filter { # ip saddr {{ ipsec[inventory_hostname_short] }} ip daddr {{ ipsec_subnet }} ipsec out reqid $i accept ip saddr {{ ipsec[inventory_hostname_short] }} ip daddr {{ ipsec_subnet }} accept - meta l4proto { icmp, icmpv6 } accept + meta l4proto { icmp, icmpv6 } counter accept udp sport 123 udp dport 123 ct state new,related,established accept {% if groups.all | length > 1 %} -- cgit v1.2.3