Puppet Class: nftables::rules::icmp

Defined in:
manifests/rules/icmp.pp

Summary

allows incoming ICMP

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



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
# File 'manifests/rules/icmp.pp', line 8

class nftables::rules::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_in-accept_icmpv4_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
        content => "ip protocol icmp icmp type ${icmp_type} accept",
        order   => $order,
      }
    }
  } elsif $v6_types {
    nftables::rule { 'default_in-accept_icmpv4':
      content => 'ip protocol icmp accept',
      order   => $order,
    }
  }

  if $v6_types {
    $v6_types.each | String $icmp_type | {
      nftables::rule { "default_in-accept_icmpv6_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
        content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept",
        order   => $order,
      }
    }
  } elsif $v4_types {
    nftables::rule { 'default_in-accept_icmpv6':
      content => 'meta l4proto icmpv6 accept',
      order   => $order,
    }
  }
  if $v6_types == undef and $v4_types == undef {
    nftables::rule { 'default_in-accept_icmp':
      content => 'meta l4proto { icmp, icmpv6} accept',
      order   => $order,
    }
  }
}