root / manifests / rules / snat4.pp @ 31b17627
Historique | Voir | Annoter | Télécharger (1,05 ko)
1 | 3d29a6eb | tr | # manage a ipv4 snat rule |
---|---|---|---|
2 | 11bf7237 | Steve Traylen | define nftables::rules::snat4 ( |
3 | 31b17627 | Steve Traylen | String[1] $snat, |
4 | 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[Enum['tcp','udp']] $proto = undef, |
||
10 | Optional[Variant[String,Integer[1,65535]]] $dport = undef, |
||
11 | Enum['present','absent'] $ensure = 'present', |
||
12 | 3d29a6eb | tr | ) { |
13 | $oifname = $oif ? { |
||
14 | undef => '', |
||
15 | default => "oifname ${oif} ", |
||
16 | } |
||
17 | $src = $saddr ? { |
||
18 | undef => '', |
||
19 | default => "ip saddr ${saddr} ", |
||
20 | } |
||
21 | |||
22 | if $proto and $dport { |
||
23 | $protocol = '' |
||
24 | $port = "${proto} dport ${dport} " |
||
25 | } elsif $proto { |
||
26 | $protocol = "${proto} " |
||
27 | $port = '' |
||
28 | } elsif $dport { |
||
29 | $protocol = '' |
||
30 | $port = "tcp dport ${dport} " |
||
31 | } else { |
||
32 | $protocol = '' |
||
33 | $port = '' |
||
34 | } |
||
35 | |||
36 | 11bf7237 | Steve Traylen | nftables::rule { |
37 | 3d29a6eb | tr | "${chain}-${rulename}": |
38 | ensure => $ensure, |
||
39 | table => 'ip-nat', |
||
40 | order => $order, |
||
41 | content => "${oifname}${src}${protocol}${port}snat ${snat}"; |
||
42 | } |
||
43 | } |