Projet

Général

Profil

Révision 8cdd24a5

ID8cdd24a57d35b45133c2dd904664509ec8a21064
Parent add6257b
Enfant 483d0a96

Ajouté par Tim Meusel il y a plus d'un an

rules::icmp: Allow ICMP packets with extensions

Voir les différences:

manifests/rules/icmp.pp
1
#
2
# @summary allows incoming ICMP
3
#
4
# @param v4_types ICMP v4 types that should be allowed
5
# @param v6_types ICMP v6 types that should be allowed
6
# @param order the ordering of the rules
7
#
1 8
class nftables::rules::icmp (
2
  # lint:ignore:parameter_documentation
3 9
  Optional[Array[String]] $v4_types = undef,
4 10
  Optional[Array[String]] $v6_types = undef,
5 11
  String $order                     = '10',
6
  # lint:endignore
7 12
) {
8 13
  if $v4_types {
9 14
    $v4_types.each | String $icmp_type | {
10
      nftables::rule {
11
        "default_in-accept_icmpv4_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
12
          content => "ip protocol icmp icmp type ${icmp_type} accept",
13
          order   => $order,
15
      nftables::rule { "default_in-accept_icmpv4_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
16
        content => "ip protocol icmp icmp type ${icmp_type} accept",
17
        order   => $order,
14 18
      }
15 19
    }
16
  } else {
17
    nftables::rule {
18
      'default_in-accept_icmpv4':
19
        content => 'ip protocol icmp accept',
20
        order   => $order,
20
  } elsif $v6_types {
21
    nftables::rule { 'default_in-accept_icmpv4':
22
      content => 'ip protocol icmp accept',
23
      order   => $order,
21 24
    }
22 25
  }
23 26

  
24 27
  if $v6_types {
25 28
    $v6_types.each | String $icmp_type | {
26
      nftables::rule {
27
        "default_in-accept_icmpv6_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
28
          content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept",
29
          order   => $order,
29
      nftables::rule { "default_in-accept_icmpv6_${regsubst(split($icmp_type, ' ')[0], '-', '_', 'G')}":
30
        content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept",
31
        order   => $order,
30 32
      }
31 33
    }
32
  } else {
33
    nftables::rule {
34
      'default_in-accept_icmpv6':
35
        content => 'ip6 nexthdr ipv6-icmp accept',
36
        order   => $order,
34
  } elsif $v4_types {
35
    nftables::rule { 'default_in-accept_icmpv6':
36
      content => 'meta l4proto icmpv6 accept',
37
      order   => $order,
38
    }
39
  }
40
  if $v6_types == undef and $v4_types == undef {
41
    nftables::rule { 'default_in-accept_icmp':
42
      content => 'meta l4proto { icmp, icmpv6} accept',
43
      order   => $order,
37 44
    }
38 45
  }
39 46
}

Formats disponibles : Unified diff