Projet

Général

Profil

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

root / manifests / rules / snat4.pp @ 215aee13

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

1 3d29a6eb tr
# manage a ipv4 snat rule
2
define nftables::rules::snat4(
3
  String[1]
4
    $snat,
5
  Pattern[/^[a-zA-Z0-9_]+$/]
6
    $rulename = $title,
7
  Pattern[/^\d\d$/]
8
    $order = '70',
9
  String[1]
10
    $chain = 'POSTROUTING',
11
  Optional[String[1]]
12
    $oif = undef,
13
  Optional[String[1]]
14
    $saddr = undef,
15 a6316327 tr
  Optional[Enum['tcp','udp']]
16 3d29a6eb tr
    $proto = undef,
17
  Optional[Variant[String,Integer[1,65535]]]
18
    $dport = undef,
19
  Enum['present','absent']
20
    $ensure = 'present',
21
) {
22
23
  $oifname = $oif ? {
24
    undef   => '',
25
    default => "oifname ${oif} ",
26
  }
27
  $src = $saddr ? {
28
    undef   => '',
29
    default => "ip saddr ${saddr} ",
30
  }
31
32
  if $proto and $dport {
33
    $protocol = ''
34
    $port     = "${proto} dport ${dport} "
35
  } elsif $proto {
36
    $protocol = "${proto} "
37
    $port     = ''
38
  } elsif $dport {
39
    $protocol = ''
40
    $port     = "tcp dport ${dport} "
41
  } else {
42
    $protocol = ''
43
    $port     = ''
44
  }
45
46
  nftables::rule{
47
    "${chain}-${rulename}":
48
      ensure  => $ensure,
49
      table   => 'ip-nat',
50
      order   => $order,
51
      content => "${oifname}${src}${protocol}${port}snat ${snat}";
52
  }
53
}