Projet

Général

Profil

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

root / manifests / rules / snat4.pp @ 11bf7237

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

1
# 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
  Optional[Enum['tcp','udp']]
16
  $proto = undef,
17
  Optional[Variant[String,Integer[1,65535]]]
18
  $dport = undef,
19
  Enum['present','absent']
20
  $ensure = 'present',
21
) {
22
  $oifname = $oif ? {
23
    undef   => '',
24
    default => "oifname ${oif} ",
25
  }
26
  $src = $saddr ? {
27
    undef   => '',
28
    default => "ip saddr ${saddr} ",
29
  }
30

    
31
  if $proto and $dport {
32
    $protocol = ''
33
    $port     = "${proto} dport ${dport} "
34
  } elsif $proto {
35
    $protocol = "${proto} "
36
    $port     = ''
37
  } elsif $dport {
38
    $protocol = ''
39
    $port     = "tcp dport ${dport} "
40
  } else {
41
    $protocol = ''
42
    $port     = ''
43
  }
44

    
45
  nftables::rule {
46
    "${chain}-${rulename}":
47
      ensure  => $ensure,
48
      table   => 'ip-nat',
49
      order   => $order,
50
      content => "${oifname}${src}${protocol}${port}snat ${snat}";
51
  }
52
}