Management of firewalld
New in version 2015.8.0.
The following example applies changes to the public zone, blocks echo-reply and echo-request packets, does not set the zone to be the default, enables masquerading, and allows ports 22/tcp and 25/tcp. It will be applied permanently and directly before restart/reload.
public: firewalld.present: - name: public - block_icmp: - echo-reply - echo-request - default: False - masquerade: True - ports: - 22/tcp - 25/tcp
The following example applies changes to the public zone, enables masquerading and configures port forwarding TCP traffic from port 22 to 2222, and forwards TCP traffic from port 80 to 443 at 192.168.0.1.
my_zone: firewalld.present: - name: public - masquerade: True - port_fwd: - 22:2222:tcp - 80:443:tcp:192.168.0.1
The following example binds the public zone to interface eth0 and to all packets coming from the 192.168.1.0/24 subnet. It also removes the zone from all other interfaces or sources.
public: firewalld.present: - name: public - interfaces: - eth0 - sources: - 192.168.1.0/24
Here, we define a new service that encompasses TCP ports 4505 4506:
saltmaster: firewalld.service: - name: saltmaster - ports: - 4505/tcp - 4506/tcp
To make this new service available in a zone, the following can be used, which would allow access to the salt master from the 10.0.0.0/8 subnet:
saltzone: firewalld.present: - name: saltzone - services: - saltmaster - sources: - 10.0.0.0/8
ForwardingMapping(srcport, destport, protocol, destaddr)¶
Represents a port forwarding statement mapping a local port to a remote port for a specific protocol (TCP or UDP)
Returns a pretty dictionary meant for command line output.
present(name, block_icmp=None, prune_block_icmp=False, default=None, masquerade=False, ports=None, prune_ports=False, port_fwd=None, prune_port_fwd=False, services=None, prune_services=False, interfaces=None, prune_interfaces=False, sources=None, prune_sources=False, rich_rules=None, prune_rich_rules=False)¶
Ensure a zone has specific attributes.
True, remove all but the specified block_icmp from the zone.
True, remove all but the specified ports from the zone.
True, remove all but the specified port_fwd from the zone.
True, remove all but the specified services from the zone. .. note:: Currently defaults to True for compatibility, but will be changed to False in a future release.
True, remove all but the specified interfaces from the zone.
True, remove all but the specified sources from the zone.
True, remove all but the specified rich rules from the zone.
service(name, ports=None, protocols=None)¶
Ensure the service exists and encompasses the specified ports and protocols.
New in version 2016.11.0.