Puppet Class: nftables::rules::out::icmp

Defined in:
manifests/rules/out/icmp.pp

Summary

control outbound icmp packages

Overview

Parameters:

  • v4_types (Optional[Array[String]]) (defaults to: undef)

    ICMP v4 types that should be allowed

  • v6_types (Optional[Array[String]]) (defaults to: undef)

    ICMP v6 types that should be allowed

  • order (String) (defaults to: '10')

    the ordering of the rules



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'manifests/rules/out/icmp.pp', line 7

class nftables::rules::out::icmp (
  Optional[Array[String]] $v4_types = undef,
  Optional[Array[String]] $v6_types = undef,
  String $order = '10',
) {
  if $v4_types {
    $v4_types.each | String $icmp_type | {
      nftables::rule { 'default_out-accept_icmpv4':
        content => "ip protocol icmp icmp type ${icmp_type} accept",
        order   => $order,
      }
    }
  } elsif $v6_types {
    nftables::rule { 'default_out-accept_icmpv4':
      content => 'ip protocol icmp accept',
      order   => $order,
    }
  }

  if $v6_types {
    $v6_types.each | String $icmp_type | {
      nftables::rule { 'default_out-accept_icmpv6':
        content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept",
        order   => $order,
      }
    }
  } elsif $v4_types {
    # `ip6 nexthdr ipv6-icmp accept` doesn't match for IPv6 ICMP with extensions
    # context: https://www.rfc-editor.org/rfc/rfc3810#section-5
    # https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_headers#Matching_IPv6_headers
    nftables::rule { 'default_out-accept_icmpv6':
      content => 'meta l4proto icmpv6 accept',
      order   => $order,
    }
  }

  if $v6_types == undef and $v4_types == undef {
    nftables::rule { 'default_out-accept_icmp':
      content => 'meta l4proto { icmp, icmpv6} accept',
      order   => $order,
    }
  }
}