You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.markdown
+61-51Lines changed: 61 additions & 51 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -70,7 +70,7 @@ Therefore, the run order is:
70
70
The rules in the `pre` and `post` classes are fairly general. These two classes ensure that you retain connectivity and that you drop unmatched packets appropriately. The rules you define in your manifests are likely specific to the applications you run.
71
71
72
72
1.) Add the `pre` class to my_fw/manifests/pre.pp. Your pre.pp file should contain any default rules to be applied first. The rules in this class should be added in the order you want them to run.2.
73
-
```puppet
73
+
~~~puppet
74
74
class my_fw::pre {
75
75
Firewall {
76
76
require => undef,
@@ -98,30 +98,31 @@ The rules in the `pre` and `post` classes are fairly general. These two classes
98
98
action => 'accept',
99
99
}
100
100
}
101
-
```
101
+
~~~
102
102
103
103
The rules in `pre` should allow basic networking (such as ICMP and TCP) and ensure that existing connections are not closed.
104
104
105
105
2.) Add the `post` class to my_fw/manifests/post.pp and include any default rules to be applied last.
106
-
```puppet
106
+
107
+
~~~puppet
107
108
class my_fw::post {
108
109
firewall { '999 drop all':
109
110
proto => 'all',
110
111
action => 'drop',
111
112
before => undef,
112
113
}
113
114
}
114
-
```
115
+
~~~
115
116
116
117
Alternatively, the [firewallchain](#type-firewallchain) type can be used to set the default policy:
117
118
118
-
```puppet
119
+
~~~puppet
119
120
firewallchain { 'INPUT:filter:IPv4':
120
121
ensure => present,
121
122
policy => drop,
122
123
before => undef,
123
124
}
124
-
```
125
+
~~~
125
126
126
127
####Create Firewall Rules
127
128
@@ -132,41 +133,43 @@ Rules are persisted automatically between reboots, although there are known issu
132
133
1.) In site.pp or another top-scope file, add the following code to set up a metatype to purge unmanaged firewall resources. This will clear any existing rules and make sure that only rules defined in Puppet exist on the machine.
133
134
134
135
**Note** - This only purges IPv4 rules.
135
-
```puppet
136
+
137
+
~~~puppet
136
138
resources { 'firewall':
137
139
purge => true
138
140
}
139
-
```
141
+
~~~
140
142
141
143
To purge unmanaged firewall chains, also add:
142
144
143
-
```puppet
145
+
~~~puppet
144
146
resources { 'firewallchain':
145
147
purge => true
146
148
}
147
-
```
148
-
**Note** - If there are unmanaged rules in unmanaged chains it will take two Puppet runs before the firewall chain is purged. This is different than the `purge` parameter available in `firewallchain`.
149
+
~~~
150
+
151
+
**Note** - If there are unmanaged rules in unmanaged chains, it will take two Puppet runs before the firewall chain is purged. This is different than the `purge` parameter available in `firewallchain`.
149
152
150
153
2.) Use the following code to set up the default parameters for all of the firewall rules you will establish later. These defaults will ensure that the `pre` and `post` classes are run in the correct order to avoid locking you out of your box during the first Puppet run.
151
154
152
-
```puppet
155
+
~~~puppet
153
156
Firewall {
154
157
before => Class['my_fw::post'],
155
158
require => Class['my_fw::pre'],
156
159
}
157
-
```
160
+
~~~
158
161
159
162
3.) Then, declare the `my_fw::pre` and `my_fw::post` classes to satisfy dependencies. You can declare these classes using an External Node Classifier or the following code:
160
163
161
-
```puppet
164
+
~~~puppet
162
165
class { ['my_fw::pre', 'my_fw::post']: }
163
-
```
166
+
~~~
164
167
165
168
4.) Include the `firewall` class to ensure the correct packages are installed.
166
169
167
-
```puppet
170
+
~~~puppet
168
171
class { 'firewall': }
169
-
```
172
+
~~~
170
173
171
174
###Upgrading
172
175
@@ -194,32 +197,33 @@ In iptables, the title of the rule is stored using the comment feature of the un
194
197
195
198
Basic accept ICMP request example:
196
199
197
-
```puppet
200
+
~~~puppet
198
201
firewall { "000 accept all icmp requests":
199
202
proto => "icmp",
200
203
action => "accept",
201
204
}
202
-
```
205
+
~~~
206
+
203
207
Drop all:
204
208
205
-
```puppet
209
+
~~~puppet
206
210
firewall { "999 drop all other requests":
207
211
action => "drop",
208
212
}
209
-
```
213
+
~~~
210
214
211
215
#### Example of an IPv6 rule
212
216
213
217
IPv6 rules can be specified using the _ip6tables_ provider:
214
218
215
-
```puppet
219
+
~~~puppet
216
220
firewall { "006 Allow inbound SSH (v6)":
217
221
port => 22,
218
222
proto => tcp,
219
223
action => accept,
220
224
provider => 'ip6tables',
221
225
}
222
-
```
226
+
~~~
223
227
224
228
###Application-Specific Rules
225
229
@@ -232,7 +236,7 @@ remain close to the services managed by the profile.
232
236
233
237
This is an example of firewall rules in a profile:
234
238
235
-
```puppet
239
+
~~~puppet
236
240
class profile::apache {
237
241
include apache
238
242
apache::vhost { 'mysite': ensure => present }
@@ -243,7 +247,7 @@ class profile::apache {
243
247
action => accept,
244
248
}
245
249
}
246
-
```
250
+
~~~
247
251
248
252
###Rule inversion
249
253
Firewall rules may be inverted by prefixing the value of a parameter by "! ". If the value is an array, then every item in the array must be prefixed as iptables does not understand inverting a single value.
@@ -266,22 +270,23 @@ firewall { '002 drop NEW external website packets with FIN/RST/ACK set and SYN u
266
270
source => '! 10.0.0.0/8',
267
271
tcp_flags => '! FIN,SYN,RST,ACK SYN',
268
272
}
269
-
```
273
+
~~~
270
274
271
275
###Additional Uses for the Firewall Module
272
276
273
277
You can apply firewall rules to specific nodes. Usually, you will want to put the firewall rule in another class and apply that class to a node. Apply a rule to a node as follows:
274
278
275
-
```puppet
279
+
~~~puppet
276
280
node 'some.node.com' {
277
281
firewall { '111 open port 111':
278
282
dport => 111
279
283
}
280
284
}
281
-
```
285
+
~~~
282
286
283
287
You can also do more complex things with the `firewall` resource. This example sets up static NAT for the source network 10.1.2.0/24:
The following will mirror all traffic sent to the server to a secondary host on the LAN with the TEE target:
312
317
313
-
```puppet
318
+
~~~puppet
314
319
firewall { '503 Mirror traffic to IDS':
315
320
proto => all,
316
321
jump => 'TEE',
317
322
gateway => '10.0.0.2',
318
323
chain => 'PREROUTING',
319
324
table => 'mangle',
320
325
}
321
-
```
326
+
~~~
322
327
323
328
The following example creates a new chain and forwards any port 5000 access to it.
324
-
```puppet
329
+
~~~puppet
325
330
firewall { '100 forward to MY_CHAIN':
326
331
chain => 'INPUT',
327
332
jump => 'MY_CHAIN',
@@ -336,7 +341,7 @@ firewall { '100 my rule':
336
341
proto => 'tcp',
337
342
dport => 5000,
338
343
}
339
-
```
344
+
~~~
340
345
341
346
###Additional Information
342
347
@@ -487,9 +492,9 @@ If Puppet is managing the iptables or iptables-persistent packages, and the prov
487
492
488
493
*`chain`: Name of the chain to use. You can provide a user-based chain or use one of the following built-in chains:'INPUT','FORWARD','OUTPUT','PREROUTING', or 'POSTROUTING'. The default value is 'INPUT'. Values must match '/^[a-zA-Z0-9\-_]+$/'. Requires the `iptables` feature.
489
494
490
-
*`checksum_fill`: When using a `jump` value of 'CHECKSUM' this boolean will make sure that a checksum is calculated and filled in a packet that lacks a checksum. Valid values are true or false. Requires the `iptables` feature.
495
+
*`checksum_fill`: When using a `jump` value of 'CHECKSUM', this boolean makes sure that a checksum is calculated and filled in a packet that lacks a checksum. Valid values are 'true' or 'false'. Requires the `iptables` feature.
491
496
492
-
*`clamp_mss_to_pmtu`: Enables PMTU Clamping support when using a jump target of 'TCPMSS'. Valid values are true or false.
497
+
*`clamp_mss_to_pmtu`: Enables PMTU Clamping support when using a jump target of 'TCPMSS'. Valid values are 'true' or 'false'.
493
498
494
499
*`connlimit_above`: Connection limiting value for matched connections above n. Values must match '/^\d+$/'. Requires the `connection_limiting` feature.
495
500
@@ -575,22 +580,22 @@ If Puppet is managing the iptables or iptables-persistent packages, and the prov
575
580
576
581
*`mask`: Sets the mask to use when `recent` is enabled. Requires the `mask` feature.
577
582
578
-
*`month_days`: Only match on the given days of the month. Possible values are '1' to '31'. Note that specifying 31 will of course not match on months which do not have a 31st day; the same goes for 28- or 29-day February.
583
+
*`month_days`: Only match on the given days of the month. Possible values are '1' to '31'. Note that specifying '31' will not match on months that do not have a 31st day; the same goes for 28- or 29-day February.
579
584
580
-
*`match_mark`: Match the Netfilter mark value associated with the packet. Accepts either of mark/mask or mark. These will be converted to hex if they are not already. Requires the `mark` feature.
585
+
*`match_mark`: Match the Netfilter mark value associated with the packet. Accepts either of mark/mask or mark. These will be converted to hex if they are not already. Requires the `mark` feature.
581
586
582
587
*`mss`: Sets a given TCP MSS value or range to match.
583
588
584
589
*`name`: The canonical name of the rule. This name is also used for ordering, so make sure you prefix the rule with a number. For example:
585
590
586
-
```puppet
591
+
~~~puppet
587
592
firewall { '000 this runs first':
588
593
# this rule will run first
589
594
}
590
595
firewall { '999 this runs last':
591
596
# this rule will run last
592
597
}
593
-
```
598
+
~~~
594
599
595
600
Depending on the provider, the name of the rule can be stored using the comment feature of the underlying firewall subsystem. Values must match '/^\d+[[:alpha:][:digit:][:punct:][:space:]]+$/'.
596
601
@@ -632,7 +637,7 @@ firewall { '999 this runs last':
632
637
633
638
*`recent`: Enable the recent module. Valid values are: 'set', 'update', 'rcheck', or 'remove'. For example:
634
639
635
-
```puppet
640
+
~~~puppet
636
641
# If anyone's appeared on the 'badguy' blacklist within
637
642
# the last 60 seconds, drop their traffic, and update the timestamp.
Note that you specify flags in the order that iptables `--list` rules would list them to avoid having Puppet think you changed the flags. For example, 'FIN,SYN,RST,ACK SYN' matches packets with the SYN bit set and the ACK, RST and FIN bits cleared. Such packets are used to request TCP connection initiation. Requires the `tcp_flags` feature.
718
723
719
-
*`time_contiguous`: When time_stopis smaller than time_start value, match this as a single time period instead distinct intervals.
724
+
*`time_contiguous`: When the `time_stop` value is smaller than the `time_start` value, match this as a single time period instead of distinct intervals.
720
725
721
726
*`time_start`: Start time for the rule to match. The possible time range is '00:00:00' to '23:59:59'. Leading zeroes are allowed (e.g. '06:03') and correctly interpreted as base-10.
722
727
@@ -758,7 +763,7 @@ Currently this type supports only iptables, ip6tables, and ebtables on Linux. It
758
763
*`ignore`: Regex to perform on firewall rules to exempt unmanaged rules from purging (when enabled). This is matched against the output of iptables-save. This can be a single regex or an array of them. To support flags, use the ruby inline flag mechanism: a regex such as '/foo/i' can be written as '(?i)foo' or '(?i:foo)'. Only when purge is 'true'.
**Note** This `purge` is purging unmanaged rules in a firewall chain, not unmanaged firewall chains. To purge unmanaged firewall chains, use the following instead.
793
798
794
-
```puppet
799
+
~~~puppet
795
800
resources { 'firewallchain':
796
801
purge => true
797
802
}
798
-
```
803
+
~~~
799
804
800
805
###Fact: ip6tables_version
801
806
@@ -824,9 +829,14 @@ when the "Unbreakable" kernel is used. These may function correctly when using
824
829
the stock RedHat kernel instead. Declaring either of these parameters on an
825
830
unsupported system will result in iptable rules failing to apply.
826
831
832
+
### Debian 8 Support
833
+
834
+
As Puppet Enterprise itself does not yet support Debian 8, use of this module with Puppet Enterprise under a Debian 8
0 commit comments