aboutsummaryrefslogtreecommitdiff
path: root/REFERENCE.md
blob: 6db3b49cb812a524fa764a5718cf5f9e623cba76 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
# Reference

<!-- DO NOT EDIT: This document was generated by Puppet Strings -->

## Table of Contents

### Classes

#### Public Classes

* [`ferm`](#ferm): This class manages ferm installation and rule generation on modern linux systems

#### Private Classes

* `ferm::config`: This class handles the configuration file. Avoid modifying private classes.
* `ferm::install`: This class handles the configuration file. Avoid modifying private classes.
* `ferm::service`: This class handles the configuration file. Avoid modifying private classes.

### Defined types

* [`ferm::chain`](#fermchain): This defined resource manages ferm/iptables chains
* [`ferm::ipset`](#fermipset): a defined resource that can match for ipsets at the top of a chain. This is a per-chain resource. You cannot mix IPv4 and IPv6 sets.
* [`ferm::rule`](#fermrule): This defined resource manages a single rule in a specific chain

### Data types

* [`Ferm::Actions`](#fermactions): a list of allowed actions for a rule
* [`Ferm::Policies`](#fermpolicies): a list of allowed policies for a chain
* [`Ferm::Port`](#fermport): ferm port-spec
* [`Ferm::Protocols`](#fermprotocols): a list of allowed protocolls to match
* [`Ferm::Tables`](#fermtables): a list of available tables

## Classes

### <a name="ferm"></a>`ferm`

This class manages ferm installation and rule generation on modern linux systems

#### Examples

##### deploy ferm without any configured rules, but also don't start the service or modify existing config files

```puppet
include ferm
```

##### deploy ferm and start it, on nodes with only ipv6 enabled

```puppet
class{'ferm':
  manage_service  => true,
  ip_versions     => ['ip6'],
}
```

##### deploy ferm and don't touch chains from other software, like fail2ban and docker

```puppet
class{'ferm':
  manage_service            => true,
  preserve_chains_in_tables => {
    'filter' => [
      'f2b-sshd',
      'DOCKER',
      'DOCKER-ISOLATION-STAGE-1',
      'DOCKER-ISOLATION-STAGE-2',
      'DOCKER-USER',
      'FORWARD',
    ],
    'nat' => [
      'DOCKER',
    ],
  },
}
```

#### Parameters

The following parameters are available in the `ferm` class:

* [`manage_service`](#manage_service)
* [`manage_configfile`](#manage_configfile)
* [`configfile`](#configfile)
* [`configdirectory`](#configdirectory)
* [`forward_disable_conntrack`](#forward_disable_conntrack)
* [`output_disable_conntrack`](#output_disable_conntrack)
* [`input_disable_conntrack`](#input_disable_conntrack)
* [`forward_policy`](#forward_policy)
* [`output_policy`](#output_policy)
* [`input_policy`](#input_policy)
* [`input_drop_invalid_packets_with_conntrack`](#input_drop_invalid_packets_with_conntrack)
* [`rules`](#rules)
* [`chains`](#chains)
* [`forward_log_dropped_packets`](#forward_log_dropped_packets)
* [`output_log_dropped_packets`](#output_log_dropped_packets)
* [`input_log_dropped_packets`](#input_log_dropped_packets)
* [`ip_versions`](#ip_versions)
* [`preserve_chains_in_tables`](#preserve_chains_in_tables)
* [`install_method`](#install_method)
* [`package_ensure`](#package_ensure)
* [`vcsrepo`](#vcsrepo)
* [`vcstag`](#vcstag)

##### <a name="manage_service"></a>`manage_service`

Data type: `Boolean`

Disable/Enable the management of the ferm daemon

Default value: ``false``

##### <a name="manage_configfile"></a>`manage_configfile`

Data type: `Boolean`

Disable/Enable the management of the ferm default config

Default value: ``false``

##### <a name="configfile"></a>`configfile`

Data type: `Stdlib::Absolutepath`

Path to the config file

##### <a name="configdirectory"></a>`configdirectory`

Data type: `Stdlib::Absolutepath`

Path to the directory where the module stores ferm configuration files

##### <a name="forward_disable_conntrack"></a>`forward_disable_conntrack`

Data type: `Boolean`

Enable/Disable the generation of conntrack rules for the FORWARD chain

Default value: ``true``

##### <a name="output_disable_conntrack"></a>`output_disable_conntrack`

Data type: `Boolean`

Enable/Disable the generation of conntrack rules for the OUTPUT chain

Default value: ``true``

##### <a name="input_disable_conntrack"></a>`input_disable_conntrack`

Data type: `Boolean`

Enable/Disable the generation of conntrack rules for the INPUT chain

Default value: ``false``

##### <a name="forward_policy"></a>`forward_policy`

Data type: `Ferm::Policies`

Default policy for the FORWARD chain

Default value: `'DROP'`

##### <a name="output_policy"></a>`output_policy`

Data type: `Ferm::Policies`

Default policy for the OUTPUT chain

Default value: `'ACCEPT'`

##### <a name="input_policy"></a>`input_policy`

Data type: `Ferm::Policies`

Default policy for the INPUT chain

Default value: `'DROP'`

##### <a name="input_drop_invalid_packets_with_conntrack"></a>`input_drop_invalid_packets_with_conntrack`

Data type: `Boolean`

Enable/Disable the `mod conntrack ctstate INVALID DROP` statement. Only works if `$disable_conntrack` is `false`. You can set this to false if your policy is DROP. This only effects the INPUT chain.

Default value: ``false``

##### <a name="rules"></a>`rules`

Data type: `Hash`

A hash that holds all data for ferm::rule

Default value: `{}`

##### <a name="chains"></a>`chains`

Data type: `Hash`

A hash that holds all data for ferm::chain

Default value: `{}`

##### <a name="forward_log_dropped_packets"></a>`forward_log_dropped_packets`

Data type: `Boolean`

Enable/Disable logging in the FORWARD chain of packets to the kernel log, if no explicit chain matched

Default value: ``false``

##### <a name="output_log_dropped_packets"></a>`output_log_dropped_packets`

Data type: `Boolean`

Enable/Disable logging in the OUTPUT chain of packets to the kernel log, if no explicit chain matched

Default value: ``false``

##### <a name="input_log_dropped_packets"></a>`input_log_dropped_packets`

Data type: `Boolean`

Enable/Disable logging in the INPUT chain of packets to the kernel log, if no explicit chain matched

Default value: ``false``

##### <a name="ip_versions"></a>`ip_versions`

Data type: `Array[Enum['ip','ip6']]`

Set list of versions of ip we want ot use.

Default value: `['ip','ip6']`

##### <a name="preserve_chains_in_tables"></a>`preserve_chains_in_tables`

Data type: `Hash[String[1],Array[String[1]]]`

Hash with table:chains[] to use ferm @preserve for (since ferm v2.4)
Example: {'nat' => ['PREROUTING', 'POSTROUTING']}

Default value: `{}`

##### <a name="install_method"></a>`install_method`

Data type: `Enum['package','vcsrepo']`

method used to install ferm

Default value: `'package'`

##### <a name="package_ensure"></a>`package_ensure`

Data type: `String[1]`

sets the ensure parameter for the package resource

Default value: `'installed'`

##### <a name="vcsrepo"></a>`vcsrepo`

Data type: `Stdlib::HTTPSUrl`

git repository where ferm sources are hosted

Default value: `'https://github.com/MaxKellermann/ferm.git'`

##### <a name="vcstag"></a>`vcstag`

Data type: `String[1]`

git tag used when install_method is vcsrepo

Default value: `'v2.5.1'`

## Defined types

### <a name="fermchain"></a>`ferm::chain`

This defined resource manages ferm/iptables chains

#### Examples

##### create a custom chain, e.g. for all incoming SSH connections

```puppet
ferm::chain{'check-ssh':
  chain               => 'SSH',
  disable_conntrack   => true,
  log_dropped_packets => true,
}
```

#### Parameters

The following parameters are available in the `ferm::chain` defined type:

* [`disable_conntrack`](#disable_conntrack)
* [`drop_invalid_packets_with_conntrack`](#drop_invalid_packets_with_conntrack)
* [`log_dropped_packets`](#log_dropped_packets)
* [`policy`](#policy)
* [`chain`](#chain)
* [`table`](#table)
* [`ip_versions`](#ip_versions)
* [`content`](#content)

##### <a name="disable_conntrack"></a>`disable_conntrack`

Data type: `Boolean`

Disable/Enable usage of conntrack. By default, we enable conntrack only for the filter INPUT chain

Default value: ``true``

##### <a name="drop_invalid_packets_with_conntrack"></a>`drop_invalid_packets_with_conntrack`

Data type: `Boolean`

Enable/Disable the `mod conntrack ctstate INVALID DROP` statement. Only works if `$disable_conntrack` is `false` in this chain. You can set this to false if your policy is DROP.

Default value: ``false``

##### <a name="log_dropped_packets"></a>`log_dropped_packets`

Data type: `Boolean`

Enable/Disable logging of packets to the kernel log, if no explicit chain matched

Default value: ``false``

##### <a name="policy"></a>`policy`

Data type: `Optional[Ferm::Policies]`

Set the default policy for CHAIN (works only for builtin chains)
Allowed values: (ACCEPT|DROP) (see Ferm::Policies type)

Default value: ``undef``

##### <a name="chain"></a>`chain`

Data type: `String[1]`

Name of the chain that should be managed
Allowed values: String[1]

Default value: `$name`

##### <a name="table"></a>`table`

Data type: `Ferm::Tables`

Select the target table (filter/raw/mangle/nat)
Allowed values: (filter|raw|mangle|nat) (see Ferm::Tables type)

Default value: `'filter'`

##### <a name="ip_versions"></a>`ip_versions`

Data type: `Array[Enum['ip', 'ip6']]`

Set list of versions of ip we want ot use.

Default value: `$ferm::ip_versions`

##### <a name="content"></a>`content`

Data type: `Optional[String[1]]`

custom string that will be written into th chain file

Default value: ``undef``

### <a name="fermipset"></a>`ferm::ipset`

a defined resource that can match for ipsets at the top of a chain. This is a per-chain resource. You cannot mix IPv4 and IPv6 sets.

* **See also**
  * http://ferm.foo-projects.org/download/2.1/ferm.html#set

#### Examples

##### Create an iptables rule that allows traffic that matches the ipset `internet`

```puppet
ferm::ipset { 'CONSUL':
  sets => {
    'internet' => 'ACCEPT'
  },
}
```

##### create two matches for IPv6, both at the end of the `INPUT` chain. Explicitly mention the `filter` table.

```puppet
ferm::ipset { 'INPUT':
  prepend_to_chain => false,
  table            => 'filter',
  ip_version       => 'ip6',
  sets             => {
    'testset01'      => 'ACCEPT',
    'anothertestset' => 'DROP'
  },
}
```

#### Parameters

The following parameters are available in the `ferm::ipset` defined type:

* [`sets`](#sets)
* [`chain`](#chain)
* [`table`](#table)
* [`ip_version`](#ip_version)
* [`prepend_to_chain`](#prepend_to_chain)

##### <a name="sets"></a>`sets`

Data type: `Hash[String[1], Ferm::Actions]`

A hash with multiple sets. For each hash you can provide an action like `DROP` or `ACCEPT`.

##### <a name="chain"></a>`chain`

Data type: `String[1]`

name of the chain we want to apply those rules to. The name of the defined resource will be used as default value for this.

Default value: `$name`

##### <a name="table"></a>`table`

Data type: `Ferm::Tables`

name of the table where we want to apply  this. Defaults to `filter` because that's the most common usecase.

Default value: `'filter'`

##### <a name="ip_version"></a>`ip_version`

Data type: `Enum['ip','ip6']`

sadly, ip sets are version specific. You cannot mix IPv4 and IPv6 addresses. Because of this you need to provide the version.

Default value: `'ip'`

##### <a name="prepend_to_chain"></a>`prepend_to_chain`

Data type: `Boolean`

By default, ipset rules are added to the top of the chain. Set this to false to append them to the end instead.

Default value: ``true``

### <a name="fermrule"></a>`ferm::rule`

This defined resource manages a single rule in a specific chain

#### Examples

##### Jump to the 'SSH' chain for all incoming SSH traffic (see chain.pp examples on how to create the chain)

```puppet
ferm::rule{'incoming-ssh':
  chain  => 'INPUT',
  action => 'SSH',
  proto  => 'tcp',
  dport  => 22,
}
```

##### Create a rule in the 'SSH' chain to allow connections from localhost

```puppet
ferm::rule{'allow-ssh-localhost':
  chain  => 'SSH',
  action => 'ACCEPT',
  proto  => 'tcp',
  dport  => 22,
  saddr  => '127.0.0.1',
}
```

##### Confuse people that do a traceroute/mtr/ping to your system

```puppet
ferm::rule{'drop-icmp-time-exceeded':
  chain         => 'OUTPUT',
  action        => 'DROP',
  proto         => 'icmp',
  proto_options => 'icmp-type time-exceeded',
}
```

##### allow multiple protocols

```puppet
ferm::rule{'allow_consul':
  chain  => 'INPUT',
  action => 'ACCEPT',
  proto  => ['udp', 'tcp'],
  dport  => 8301,
}
```

#### Parameters

The following parameters are available in the `ferm::rule` defined type:

* [`chain`](#chain)
* [`proto`](#proto)
* [`comment`](#comment)
* [`action`](#action)
* [`dport`](#dport)
* [`sport`](#sport)
* [`saddr`](#saddr)
* [`daddr`](#daddr)
* [`proto_options`](#proto_options)
* [`interface`](#interface)
* [`ensure`](#ensure)
* [`table`](#table)

##### <a name="chain"></a>`chain`

Data type: `String[1]`

Configure the chain where we want to add the rule

##### <a name="proto"></a>`proto`

Data type: `Ferm::Protocols`

Which protocol do we want to match, typically UDP or TCP

##### <a name="comment"></a>`comment`

Data type: `String`

A comment that will be added to the ferm config and to ip{,6}tables

Default value: `$name`

##### <a name="action"></a>`action`

Data type: `Ferm::Actions`

Configure what we want to do with the packet (drop/accept/reject, can also be a target chain name). The parameter is mandatory.
Allowed values: (RETURN|ACCEPT|DROP|REJECT|NOTRACK|LOG|MARK|DNAT|SNAT|MASQUERADE|REDIRECT|String[1])

##### <a name="dport"></a>`dport`

Data type: `Optional[Ferm::Port]`

The destination port, can be a single port number as integer or an Array of integers (which will then use the multiport matcher)

Default value: ``undef``

##### <a name="sport"></a>`sport`

Data type: `Optional[Ferm::Port]`

The source port, can be a single port number as integer or an Array of integers (which will then use the multiport matcher)

Default value: ``undef``

##### <a name="saddr"></a>`saddr`

Data type: `Optional[Variant[Array, String[1]]]`

The source address we want to match

Default value: ``undef``

##### <a name="daddr"></a>`daddr`

Data type: `Optional[Variant[Array, String[1]]]`

The destination address we want to match

Default value: ``undef``

##### <a name="proto_options"></a>`proto_options`

Data type: `Optional[String[1]]`

Optional parameters that will be passed to the protocol (for example to match specific ICMP types)

Default value: ``undef``

##### <a name="interface"></a>`interface`

Data type: `Optional[String[1]]`

an Optional interface where this rule should be applied

Default value: ``undef``

##### <a name="ensure"></a>`ensure`

Data type: `Enum['absent','present']`

Set the rule to present or absent

Default value: `'present'`

##### <a name="table"></a>`table`

Data type: `Ferm::Tables`

Select the target table (filter/raw/mangle/nat)
Default value: filter
Allowed values: (filter|raw|mangle|nat) (see Ferm::Tables type)

Default value: `'filter'`

## Data types

### <a name="fermactions"></a>`Ferm::Actions`

As you can also *jump* to other chains, each chain-name is also a valid action/target

Alias of

```puppet
Variant[Enum['RETURN', 'ACCEPT', 'DROP', 'REJECT', 'NOTRACK', 'LOG', 'MARK', 'DNAT', 'SNAT', 'MASQUERADE', 'REDIRECT'], String[1]]
```

### <a name="fermpolicies"></a>`Ferm::Policies`

a list of allowed policies for a chain

Alias of

```puppet
Enum['ACCEPT', 'DROP']
```

### <a name="fermport"></a>`Ferm::Port`

allowed variants:
-----------------
+ single Integer port
+ Array of Integers (creates a multiport matcher)
+ ferm range port-spec (pair of colon-separated integer, assumes 0 if first is omitted)

Alias of

```puppet
Variant[Stdlib::Port, Array[Stdlib::Port], Pattern['^\d*:\d+$']]
```

### <a name="fermprotocols"></a>`Ferm::Protocols`

a list of allowed protocolls to match

Alias of

```puppet
Variant[Integer[0, 255], Array[Integer[0, 255]], Enum['icmp', 'tcp', 'udp', 'udplite', 'icmpv6', 'esp', 'ah', 'sctp', 'mh', 'all'], Array[Enum['icmp', 'tcp', 'udp', 'udplite', 'icmpv6', 'esp', 'ah', 'sctp', 'mh', 'all']]]
```

### <a name="fermtables"></a>`Ferm::Tables`

a list of available tables

Alias of

```puppet
Enum['raw', 'mangle', 'nat', 'filter']
```