Projet

Général

Profil

Paste
Télécharger au format
Statistiques
| Branche: | Révision:

root / manifests / rules / icmp.pp @ 2ad7193b

Historique | Voir | Annoter | Télécharger (1,37 ko)

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
#
8
class nftables::rules::icmp (
9
  Optional[Array[String]] $v4_types = undef,
10
  Optional[Array[String]] $v6_types = undef,
11
  String $order                     = '10',
12
) {
13
  if $v4_types {
14
    $v4_types.each | String $icmp_type | {
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,
18
      }
19
    }
20
  } elsif $v6_types {
21
    nftables::rule { 'default_in-accept_icmpv4':
22
      content => 'ip protocol icmp accept',
23
      order   => $order,
24
    }
25
  }
26

    
27
  if $v6_types {
28
    $v6_types.each | String $icmp_type | {
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,
32
      }
33
    }
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,
44
    }
45
  }
46
}