Version information
This version is compatible with:
- Puppet Enterprise 2023.8.x, 2023.7.x, 2023.6.x, 2023.5.x, 2023.4.x, 2023.3.x, 2023.2.x, 2023.1.x, 2023.0.x, 2021.7.x, 2021.6.x, 2021.5.x, 2021.4.x, 2021.3.x, 2021.2.x, 2021.1.x, 2021.0.x, 2019.8.x, 2019.7.x, 2019.5.x, 2019.4.x, 2019.3.x, 2019.2.x, 2019.1.x, 2019.0.x, 2018.1.x, 2017.3.x, 2017.2.x, 2017.1.x, 2016.5.x, 2016.4.x
- Puppet >= 4.0.0
- , , ,
Start using this module
Add this module to your Puppetfile:
mod 'puppetfinland-packetfilter', '2.0.3'
Learn more about managing modules with a PuppetfileDocumentation
packetfilter
A general-purpose packetfilter module for Puppet. Uses Puppet Labs firewall for the hard lifting. Supports both IPv4 (iptables) and IPv6 (ip6tables).
Module usage
To get a basic set of rules suitable for a traffic endpoint such as normal server or desktop:
include ::packetfilter::endpoint
To create a simple masquerading router:
class { '::packetfilter::router':
source => '192.168.0.50/24',
iniface => 'br0',
outiface => 'eth0',
}
Other modules can add their own firewall resources: the ::packetfilter class will realize all virtual firewall resources tagged with 'default'. This feature is quite useful when used within Puppet modules that manage a network-facing daemon (e.g. snmpd, apache2, ssh): the daemon module can open up holes into the firewall as needed. For a typical example see ::postfix::packetfilter.
Historical note on run stages
Previously this module added blanket DENY rules to INPUT and FORWARD chains. This was achieved with a separate run stage which came after the main stage. In Puppet 3 this was a "belt-and-suspenders" approach in that prepending the resource title with, say, '999' already had the same effect. Puppet's parse order changed, however, in Puppet 4, and there was no longer any reasonable way to order a resource except with explicit resource relationships or with run stages. Setting such explicit relationships (as described in current puppetlabs/firewall documentation) only works for simplistic cases, not when firewall rules are combined from several different, independent modules, and when one does not want to create arbitrary dependencies on the "packetfilter::deny" classes.
Unfortunately run stages had two major problems in Puppet 4 at least:
- Rules in post run stage were not saved to /etc/iptables.save or equivalent
- They could create dependency cycles in some cases
So run stages had to go. In lieue of explicit resource relationships the only fairly secure approach, which version 1.0.0 of this module uses, is to get rid of the DENY rules, and replace them with a DROP policy for the whole chain. As Puppet now applies resources in the parse order, we can be fairly certain that the ACCEPT rules in packetfilter module get applied first, and only after that the policy is set to DROP in the INPUT and FORWARD chains. Then other modules can apply their ACCEPT rules in whatever order they want.
All this said, puppetlabs-firewall has an interesting property: even though Puppet debug log clearly shows the rules being applied in run-time order, the actual order of the rules will end up being based on the title. So all the refactoring discussed about was probably unnecessary.
Many of the subclasses could probably be merged if parameters and their default values were chosen carefully.
Dependencies
- duritong/sysctl (>= 0.0.6)
- puppetlabs/firewall (>= 1.8.0)
Copyright 2017 Samuli Seppänen, 2017 OpenVPN, Inc and 2011 Mikko Vilpponen. Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.