root / manifests / rules / masquerade.pp @ ffc8b86f
Historique | Voir | Annoter | Télécharger (1,24 ko)
1 | 2a3b45ec | tr | # masquerade all outgoing traffic |
---|---|---|---|
2 | 11bf7237 | Steve Traylen | define nftables::rules::masquerade ( |
3 | 09cba182 | Steve Traylen | # lint:ignore:parameter_documentation |
4 | 31b17627 | Steve Traylen | Pattern[/^[a-zA-Z0-9_]+$/] $rulename = $title, |
5 | Pattern[/^\d\d$/] $order = '70', |
||
6 | String[1] $chain = 'POSTROUTING', |
||
7 | Optional[String[1]] $oif = undef, |
||
8 | Optional[String[1]] $saddr = undef, |
||
9 | Optional[String[1]] $daddr = undef, |
||
10 | Optional[Enum['tcp','udp']] $proto = undef, |
||
11 | 94a80621 | Steve Traylen | Optional[Variant[String,Stdlib::Port]] $dport = undef, |
12 | 31b17627 | Steve Traylen | Enum['present','absent'] $ensure = 'present', |
13 | 09cba182 | Steve Traylen | # lint:endignore |
14 | 2a3b45ec | tr | ) { |
15 | $oifname = $oif ? { |
||
16 | undef => '', |
||
17 | default => "oifname ${oif} ", |
||
18 | } |
||
19 | $src = $saddr ? { |
||
20 | undef => '', |
||
21 | default => "ip saddr ${saddr} ", |
||
22 | } |
||
23 | $dst = $daddr ? { |
||
24 | undef => '', |
||
25 | default => "ip daddr ${daddr} ", |
||
26 | } |
||
27 | |||
28 | if $proto and $dport { |
||
29 | $protocol = '' |
||
30 | $port = "${proto} dport ${dport} " |
||
31 | } elsif $proto { |
||
32 | $protocol = "${proto} " |
||
33 | $port = '' |
||
34 | } elsif $dport { |
||
35 | $protocol = '' |
||
36 | $port = "tcp dport ${dport} " |
||
37 | } else { |
||
38 | $protocol = '' |
||
39 | $port = '' |
||
40 | } |
||
41 | |||
42 | 11bf7237 | Steve Traylen | nftables::rule { |
43 | 2a3b45ec | tr | "${chain}-${rulename}": |
44 | ensure => $ensure, |
||
45 | fcb79d73 | Ben Morrice | table => "ip-${nftables::nat_table_name}", |
46 | 2a3b45ec | tr | order => $order, |
47 | content => "${oifname}${src}${dst}${protocol}${port}masquerade"; |
||
48 | } |
||
49 | } |