root / manifests / rules / out / icmp.pp @ fc8e52ed
Historique | Voir | Annoter | Télécharger (1,51 ko)
1 |
# @summary control outbound icmp packages |
---|---|
2 |
# |
3 |
# @param v4_types ICMP v4 types that should be allowed |
4 |
# @param v6_types ICMP v6 types that should be allowed |
5 |
# @param order the ordering of the rules |
6 |
# |
7 |
class nftables::rules::out::icmp ( |
8 |
Optional[Array[String]] $v4_types = undef, |
9 |
Optional[Array[String]] $v6_types = undef, |
10 |
String $order = '10', |
11 |
) { |
12 |
if $v4_types { |
13 |
$v4_types.each | String $icmp_type | { |
14 |
nftables::rule { 'default_out-accept_icmpv4': |
15 |
content => "ip protocol icmp icmp type ${icmp_type} accept", |
16 |
order => $order, |
17 |
} |
18 |
} |
19 |
} elsif $v6_types { |
20 |
nftables::rule { 'default_out-accept_icmpv4': |
21 |
content => 'ip protocol icmp accept', |
22 |
order => $order, |
23 |
} |
24 |
} |
25 |
|
26 |
if $v6_types { |
27 |
$v6_types.each | String $icmp_type | { |
28 |
nftables::rule { 'default_out-accept_icmpv6': |
29 |
content => "ip6 nexthdr ipv6-icmp icmpv6 type ${icmp_type} accept", |
30 |
order => $order, |
31 |
} |
32 |
} |
33 |
} elsif $v4_types { |
34 |
# `ip6 nexthdr ipv6-icmp accept` doesn't match for IPv6 ICMP with extensions |
35 |
# context: https://www.rfc-editor.org/rfc/rfc3810#section-5 |
36 |
# https://wiki.nftables.org/wiki-nftables/index.php/Matching_packet_headers#Matching_IPv6_headers |
37 |
nftables::rule { 'default_out-accept_icmpv6': |
38 |
content => 'meta l4proto icmpv6 accept', |
39 |
order => $order, |
40 |
} |
41 |
} |
42 |
|
43 |
if $v6_types == undef and $v4_types == undef { |
44 |
nftables::rule { 'default_out-accept_icmp': |
45 |
content => 'meta l4proto { icmp, icmpv6} accept', |
46 |
order => $order, |
47 |
} |
48 |
} |
49 |
} |