ferm
: This class manages ferm installation and rule generation on modern linux systems
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.
ferm::chain
: This defined resource manages ferm/iptables chainsferm::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.ferm::rule
: This defined resource manages a single rule in a specific chain
Ferm::Actions
: a list of allowed actions for a ruleFerm::Negation
: list of keywords that support negationFerm::Policies
: a list of allowed policies for a chainFerm::Port
: ferm port-specFerm::Protocols
: a list of allowed protocolls to matchFerm::Tables
: a list of available tables
This class manages ferm installation and rule generation on modern linux systems
deploy ferm without any configured rules, but also don't start the service or modify existing config files
include ferm
class{'ferm':
manage_service => true,
ip_versions => ['ip6'],
}
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',
],
},
}
The following parameters are available in the ferm
class:
manage_service
manage_configfile
manage_package
configfile
configdirectory
forward_disable_conntrack
output_disable_conntrack
input_disable_conntrack
forward_policy
output_policy
input_policy
input_drop_invalid_packets_with_conntrack
rules
chains
forward_log_dropped_packets
output_log_dropped_packets
input_log_dropped_packets
ip_versions
preserve_chains_in_tables
install_method
package_ensure
vcsrepo
vcstag
Data type: Boolean
Disable/Enable the management of the ferm daemon
Default value: false
Data type: Boolean
Disable/Enable the management of the ferm default config
Default value: false
Data type: Boolean
Disable/Enable the management of the ferm package
Default value: true
Data type: Stdlib::Absolutepath
Path to the config file
Data type: Stdlib::Absolutepath
Path to the directory where the module stores ferm configuration files
Data type: Boolean
Enable/Disable the generation of conntrack rules for the FORWARD chain
Default value: true
Data type: Boolean
Enable/Disable the generation of conntrack rules for the OUTPUT chain
Default value: true
Data type: Boolean
Enable/Disable the generation of conntrack rules for the INPUT chain
Default value: false
Data type: Ferm::Policies
Default policy for the FORWARD chain
Default value: 'DROP'
Data type: Ferm::Policies
Default policy for the OUTPUT chain
Default value: 'ACCEPT'
Data type: Ferm::Policies
Default policy for the INPUT chain
Default value: 'DROP'
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
Data type: Hash
A hash that holds all data for ferm::rule
Default value: {}
Data type: Hash
A hash that holds all data for ferm::chain
Default value: {}
Data type: Boolean
Enable/Disable logging in the FORWARD chain of packets to the kernel log, if no explicit chain matched
Default value: false
Data type: Boolean
Enable/Disable logging in the OUTPUT chain of packets to the kernel log, if no explicit chain matched
Default value: false
Data type: Boolean
Enable/Disable logging in the INPUT chain of packets to the kernel log, if no explicit chain matched
Default value: false
Data type: Array[Enum['ip','ip6']]
Set list of versions of ip we want ot use.
Default value: ['ip','ip6']
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: {}
Data type: Enum['package','vcsrepo']
method used to install ferm
Default value: 'package'
Data type: String[1]
sets the ensure parameter for the package resource
Default value: 'installed'
Data type: Stdlib::HTTPSUrl
git repository where ferm sources are hosted
Default value: 'https://github.com/MaxKellermann/ferm.git'
Data type: String[1]
git tag used when install_method is vcsrepo
Default value: 'v2.6'
This defined resource manages ferm/iptables chains
ferm::chain{'check-ssh':
chain => 'SSH',
disable_conntrack => true,
log_dropped_packets => true,
}
The following parameters are available in the ferm::chain
defined type:
disable_conntrack
drop_invalid_packets_with_conntrack
log_dropped_packets
policy
chain
table
ip_versions
content
Data type: Boolean
Disable/Enable usage of conntrack. By default, we enable conntrack only for the filter INPUT chain
Default value: true
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
Data type: Boolean
Enable/Disable logging of packets to the kernel log, if no explicit chain matched
Default value: false
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
Data type: String[1]
Name of the chain that should be managed Allowed values: String[1]
Default value: $name
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'
Data type: Array[Enum['ip', 'ip6']]
Set list of versions of ip we want ot use.
Default value: $ferm::ip_versions
Data type: Optional[String[1]]
custom string that will be written into th chain file
Default value: undef
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::ipset { 'CONSUL':
sets => {
'internet' => 'ACCEPT'
},
}
create two matches for IPv6, both at the end of the INPUT
chain. Explicitly mention the filter
table.
ferm::ipset { 'INPUT':
prepend_to_chain => false,
table => 'filter',
ip_version => 'ip6',
sets => {
'testset01' => 'ACCEPT',
'anothertestset' => 'DROP'
},
}
The following parameters are available in the ferm::ipset
defined type:
Data type: Hash[String[1], Ferm::Actions]
A hash with multiple sets. For each hash you can provide an action like DROP
or ACCEPT
.
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
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'
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'
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
This defined resource manages a single rule in a specific chain
Jump to the 'SSH' chain for all incoming SSH traffic (see chain.pp examples on how to create the chain)
ferm::rule{'incoming-ssh':
chain => 'INPUT',
action => 'SSH',
proto => 'tcp',
dport => 22,
}
ferm::rule{'allow-ssh-localhost':
chain => 'SSH',
action => 'ACCEPT',
proto => 'tcp',
dport => 22,
saddr => '127.0.0.1',
}
ferm::rule{'drop-icmp-time-exceeded':
chain => 'OUTPUT',
action => 'DROP',
proto => 'icmp',
proto_options => 'icmp-type time-exceeded',
}
ferm::rule{'allow_consul':
chain => 'INPUT',
action => 'ACCEPT',
proto => ['udp', 'tcp'],
dport => 8301,
}
The following parameters are available in the ferm::rule
defined type:
Data type: String[1]
Configure the chain where we want to add the rule
Data type: Ferm::Protocols
Which protocol do we want to match, typically UDP or TCP
Data type: String
A comment that will be added to the ferm config and to ip{,6}tables
Default value: $name
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])
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
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
Data type: Optional[Variant[Array, String[1]]]
The source address we want to match
Default value: undef
Data type: Optional[Variant[Array, String[1]]]
The destination address we want to match
Default value: undef
Data type: Optional[String[1]]
Optional parameters that will be passed to the protocol (for example to match specific ICMP types)
Default value: undef
Data type: Optional[String[1]]
an Optional interface where this rule should be applied
Default value: undef
Data type: Enum['absent','present']
Set the rule to present or absent
Default value: 'present'
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 type: Optional[Ferm::Negation]
Single keyword or array of keywords to negate Default value: undef Allowed values: (saddr|daddr|sport|dport) (see Ferm::Negation type)
Default value: undef
As you can also jump to other chains, each chain-name is also a valid action/target
Alias of Variant[Enum['RETURN', 'ACCEPT', 'DROP', 'REJECT', 'NOTRACK', 'LOG', 'MARK', 'DNAT', 'SNAT', 'MASQUERADE', 'REDIRECT'], String[1]]
list of keywords that support negation
Alias of Variant[Enum['saddr', 'daddr', 'sport', 'dport'], Array[Enum['saddr', 'daddr', 'sport', 'dport']]]
a list of allowed policies for a chain
Alias of Enum['ACCEPT', 'DROP']
- 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 Variant[Stdlib::Port, Array[Stdlib::Port], Pattern['^\d*:\d+$']]
a list of allowed protocolls to match
Alias of 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 list of available tables
Alias of Enum['raw', 'mangle', 'nat', 'filter']