FIREWALLD.POLICY(5)
β¨ NAME β¨
firewalld.policy β firewalld policy configuration files π
okay so bestie, strap in, because this page is literally the blueprint for firewalld policy config files and it's giving main character energy π
π¦ SYNOPSIS π¦
/etc/firewalld/policies/policy.xml
/usr/lib/firewalld/policies/policy.xml
π DESCRIPTION π
A firewalld policy configuration file holds all the tea for one single policy. Inside you'll find the policy descriptions, services, ports, protocols, icmp-blocks, masquerade, forward-ports and rich language rules β all in XML format. β¨
Real talk though: the file name has to be policy_name.xml, and the length of policy_name is currently limited to 17 chars. Not 18. Seventeen. Respect the limit bestie π«Ά
This is the structure of a policy configuration file, look at her:
<?xml version="1.0" encoding="utf-8"?>
<policy [version="versionstring"] [target="CONTINUE|ACCEPT|REJECT|DROP"] [priority="priority"]>
[ <disable/> ]
[ <ingress-zone name="zone"/> ]
[ <egress-zone name="zone"/> ]
[ <short>short description</short> ]
[ <description>description</description> ]
[ <service name="string"/> ]
[ <port port="portid[-portid]" protocol="tcp|udp|sctp|dccp"/> ]
[ <protocol value="protocol"/> ]
[ <icmp-block name="string"/> ]
[ <masquerade/> ]
[ <forward-port port="portid[-portid]" protocol="tcp|udp|sctp|dccp" [to-port="portid[-portid]"] [to-addr="IP address"]/> ]
[ <source-port port="portid[-portid]" protocol="tcp|udp|sctp|dccp"/> ]
[
<rule [family="ipv4|ipv6"] [priority="priority"]>
[ <source address="address[/mask]"|mac="MAC"|ipset="ipset" [invert="True"]/> ]
[ <destination address="address[/mask]"|ipset="ipset" [invert="True"]/> ]
[
<service name="string"/> |
<port port="portid[-portid]" protocol="tcp|udp|sctp|dccp"/> |
<protocol value="protocol"/> |
<icmp-block name="icmptype"/> |
<icmp-type name="icmptype"/> |
<masquerade/> |
<forward-port port="portid[-portid]" protocol="tcp|udp|sctp|dccp" [to-port="portid[-portid]"] [to-addr="address"]/>
]
[
<log [prefix="prefix text"] [level="emerg|alert|crit|err|warn|notice|info|debug"]> [<limit value="rate/duration"/>] </log> |
<nflog [group="group id"] [prefix="prefix text"] [queue-size="threshold"]> [<limit value="rate/duration"/>] </nflog>
]
[ <audit> [<limit value="rate/duration"/>] </audit> ]
[
<accept> [<limit value="rate/duration"/>] </accept> |
<reject [type="rejecttype"]> [<limit value="rate/duration"/>] </reject> |
<drop> [<limit value="rate/duration"/>] </drop> |
<mark set="mark[/mask]"> [<limit value="rate/duration"/>] </mark>
]
</rule>
]
</policy>
The config can contain these tags and attributes. Some of them are mandatory, others are optional β like, some of them HAVE to show up and some are just there if they feel like it π
π policy π
The mandatory policy start and end tag defines the policy. This tag can only be used once in a policy configuration file β no double dipping β
There are optional attributes for policy:
version="string"β gives the policy a version, cute little label energy πtarget="CONTINUE|ACCEPT|REJECT|DROP"β can be used to accept, reject or drop every packet that doesn't match any rule (port, service, etc.). TheCONTINUEis the default and is used for policies that are non-terminal. π¦
π disable π
Is an optional empty-element tag. It can be used only once. If it's present, the policy is disabled and will not activate. Like, she's off the clock, do not disturb π
πΈ ingress-zone πΈ
An optional element that can be used several times. It can be the name of a firewalld zone or one of the symbolic zones: HOST, ANY. See firewalld.policies(5) for information about symbolic zones.
π¦ egress-zone π¦
An optional element that can be used several times. It can be the name of a firewalld zone or one of the symbolic zones: HOST, ANY. See firewalld.policies(5) for information about symbolic zones.
π short π
Is an optional start and end tag and is used to give a more readable name. Basically a nickname for your policy π
π description π
Is an optional start and end tag to have a description. Tell us more, bestie π
β service β
Is an optional empty-element tag and can be used several times to have more than one service entry enabled. A service entry has exactly one attribute:
name="string"β the name of the service to be enabled. To get a list of valid service names,firewall-cmd --get-servicescan be used. π₯
π port π
Is an optional empty-element tag and can be used several times to have more than one port entry. All attributes of a port entry are mandatory:
port="portid[-portid]"β the port can either be a single port numberportidor a port rangeportid-portid.protocol="tcp|udp|sctp|dccp"β the protocol can either betcp,udp,sctpordccp.
β¨ protocol β¨
Is an optional empty-element tag and can be used several times to have more than one protocol entry. All protocol has exactly one attribute:
value="string"β the protocol can be any protocol supported by the system. Please have a look at/etc/protocolsfor supported protocols. π
π icmp-block π
Is an optional empty-element tag and can be used several times to have more than one icmp-block entry. Each icmp-block tag has exactly one mandatory attribute:
name="string"β the name of the Internet Control Message Protocol (ICMP) type to be blocked. To get a list of valid ICMP types,firewall-cmd --get-icmptypescan be used. π«
π masquerade π
Is an optional empty-element tag. It can be used only once. If it's present, masquerading is enabled. She's incognito, periodt πΆοΈ
π₯ forward-port π₯
Is an optional empty-element tag and can be used several times to have more than one port or packet forward entry. There are mandatory and also optional attributes for forward ports:
Mandatory attributes:
The local port and protocol to be forwarded.
port="portid[-portid]"β the port can either be a single port numberportidor a port rangeportid-portid.protocol="tcp|udp|sctp|dccp"β the protocol can either betcp,udp,sctpordccp.
Optional attributes:
The destination of the forward. For local forwarding, add to-port only. For remote forwarding, add to-addr and use to-port optionally if the destination port on the destination machine should be different.
to-port="portid[-portid]"β the destination port or port range to forward to. If omitted, the value of theport=attribute will be used altogether with theto-addrattribute.to-addr="address"β the destination IP address either for IPv4 or IPv6.
Special Note:
When used with a policy, it's impossible for the firewall backend to determine the egress zone. See section UNKNOWN DESTINATIONS in firewall-cmd(1) for more information.
π§ source-port π§
Is an optional empty-element tag and can be used several times to have more than one source port entry. All attributes of a source port entry are mandatory:
port="portid[-portid]"β the port can either be a single port numberportidor a port rangeportid-portid.protocol="tcp|udp|sctp|dccp"β the protocol can either betcp,udp,sctpordccp.
π rule π
Is an optional element tag and can be used several times to have more than one rich language rule entry.
The general rule structure:
<rule [family="ipv4|ipv6"] [priority="priority"]>
[ <source address="address[/mask]"|mac="MAC"|ipset="ipset" [invert="True"]/> ]
[ <destination address="address[/mask]"|ipset="ipset" [invert="True"]/> ]
[
<service name="string"/> |
<port port="portid[-portid]" protocol="tcp|udp|sctp|dccp"/> |
<protocol value="protocol"/> |
<icmp-block name="icmptype"/> |
<icmp-type name="icmptype"/> |
<masquerade/> |
<forward-port port="portid[-portid]" protocol="tcp|udp|sctp|dccp" [to-port="portid[-portid]"] [to-addr="address"]/> |
<source-port port="portid[-portid]" protocol="tcp|udp|sctp|dccp"/> |
]
[
<log [prefix="prefix text"] [level="emerg|alert|crit|err|warn|notice|info|debug"]> [<limit value="rate/duration"/>] </log> |
<nflog [group="group id"] [prefix="prefix text"] [queue-size="threshold"]> [<limit value="rate/duration"/>] </nflog>
]
[ <audit> [<limit value="rate/duration"/>] </audit> ]
[
<accept> [<limit value="rate/duration"/>] </accept> |
<reject [type="rejecttype"]> [<limit value="rate/duration"/>] </reject> |
<drop> [<limit value="rate/duration"/>] </drop> |
<mark set="mark[/mask]"> [<limit value="rate/duration"/>] </mark>
]
</rule>
Rule structure for source black or white listing:
<rule [family="ipv4|ipv6"] [priority="priority"]>
<source address="address[/mask]"|mac="MAC"|ipset="ipset" [invert="True"]/>
[
<log [prefix="prefix text"] [level="emerg|alert|crit|err|warn|notice|info|debug"]> [<limit value="rate/duration"/>] </log> |
<nflog [group="group id"] [prefix="prefix text"] [queue-size="threshold"]> [<limit value="rate/duration"/>] </nflog>
]
[ <audit> [<limit value="rate/duration"/>] </audit> ]
<accept> [<limit value="rate/duration"/>] </accept> |
<reject [type="rejecttype"]> [<limit value="rate/duration"/>] </reject> |
<drop> [<limit value="rate/duration"/>] </drop>
</rule>
For a full description on rich language rules, please have a look at firewalld.richlanguage(5). It's a whole vibe, I promise π
π SEE ALSO π
firewall-applet(1), firewalld(1), firewall-cmd(1), firewall-config(1), firewalld.conf(5), firewalld.direct(5), firewalld.dbus(5), firewalld.icmptype(5), firewall-offline-cmd(1), firewalld.richlanguage(5), firewalld.service(5), firewalld.zone(5), firewalld.zones(5), firewalld.policy(5), firewalld.policies(5), firewalld.ipset(5), firewalld.helper(5)
(the whole friend group, basically π«)
π NOTES π
firewalld home page:
π AUTHORS π
- Thomas Woerner
<twoerner@redhat.com>β Developer - Jiri Popelka
<jpopelka@redhat.com>β Developer - Eric Garver
<eric@garver.life>β Developer
and that's the whole page bestie π this one came from firewalld 2.5.2, and it lives under the name FIREWALLD.POLICY(5) β go forth and configure your policies, you absolute icon πβ¨π¦
π¦ where this page comes from
- arch rolling: firewalld 2.5.2-1 Β· GPL-2.0-or-later
- ubuntu stonking: firewalld 2.5.2-1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms