root / manifests / rules / icmp.pp @ 51850192
Historique | Voir | Annoter | Télécharger (1,37 ko)
1 | 8cdd24a5 | Tim Meusel | # |
---|---|---|---|
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 | 79e9a23f | Nacho Barrientos | 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 | 8cdd24a5 | Tim Meusel | 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 | 79e9a23f | Nacho Barrientos | } |
19 | } |
||
20 | 8cdd24a5 | Tim Meusel | } elsif $v6_types { |
21 | nftables::rule { 'default_in-accept_icmpv4': |
||
22 | content => 'ip protocol icmp accept', |
||
23 | order => $order, |
||
24 | 11bf7237 | Steve Traylen | } |
25 | 79e9a23f | Nacho Barrientos | } |
26 | |||
27 | if $v6_types { |
||
28 | $v6_types.each | String $icmp_type | { |
||
29 | 8cdd24a5 | Tim Meusel | 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 | 79e9a23f | Nacho Barrientos | } |
33 | } |
||
34 | 8cdd24a5 | Tim Meusel | } 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 | 11bf7237 | Steve Traylen | } |
45 | 79e9a23f | Nacho Barrientos | } |
46 | } |