FIREWALLD.ZONE(5)

๐ŸŒธ FIREWALLD.ZONE(5) ๐ŸŒธ

okay bestie, gather round, because firewalld.zone is genuinely one of those pages that looks scary and is actually just a very organized girlie ๐Ÿ’… this is the section 5 manual page for firewalld.zone โ€” the zone configuration files, periodt.


โœจ NAME โœจ

firewalld.zone โ€” firewalld zone configuration files ๐Ÿ’–


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

/etc/firewalld/zones/zone.xml

/usr/lib/firewalld/zones/zone.xml

๐Ÿ’– DESCRIPTION ๐Ÿ’–

so a firewalld zone configuration file is literally just where a zone keeps all its info. we're talking the zone description, services, ports, protocols, icmp-blocks, masquerade, forward-ports, intra-zone forwarding, and rich language rules โ€” all of it living in an XML file format. very demure, very structured ๐ŸŽ€

the file name has to be zone_name.xml, and ngl the length of zone_name is currently capped at 17 chars. that's the limit, no cap ๐Ÿงข

here's the whole structure of a zone configuration file, look at her:

<?xml version="1.0" encoding="utf-8"?>
<zone [version="versionstring"] [target="ACCEPT|%%REJECT%%|DROP"] [ingress-priority="priority"] [egress-priority="priority"]>
    [ <interface name="string"/> ]
    [ <source address="address[/mask]"|mac="MAC"|ipset="ipset"/> ]
    [ <icmp-block-inversion/> ]
    [ <forward/> ]

    [ <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>
    ]

</zone>

so the config can hold all these tags and attributes. some of them are mandatory, the rest are optional โ€” pick your faves ๐ŸŒˆ

zone ๐Ÿ‘‘

the mandatory zone start and end tag is what defines the zone. this tag can only be used once in a zone configuration file. there are optional attributes for zones, and they're giving:

  • version="string" โ€” gives the zone a version โœจ
  • target="ACCEPT|%%REJECT%%|DROP" โ€” this one can accept, reject, or drop every single packet that doesn't match any rule (port, service, etc.). ACCEPT is special, bestie: packets that are not addressed to the host will be forwarded to their destination no matter what the zone's forward setting says, or any policies attached to the zone. if you don't specify it, the default behavior applies: ICMP gets accepted and literally everything else gets rejected ๐Ÿ’€
  • ingress-priority="priority" โ€” ingress priority for classifying traffic into a zone. a zone with a lower priority value gets considered before a zone with a higher priority value. this lets you do custom ordering of zone dispatch ๐Ÿ‘‘
  • egress-priority="priority" โ€” same as ingress-priority, but for egress classification ๐Ÿฆ‹

interface ๐Ÿ”Œ

it's an optional empty-element tag and you can use it several times. it binds an interface to a zone. you don't need this for NetworkManager-managed interfaces, because NetworkManager binds interfaces to zones automatically (see also 'How to set or change a zone for a connection?' in firewalld.zones(5)). you can use it as a fallback mechanism for interfaces that can't be managed via NetworkManager. an interface entry has exactly one attribute:

  • name="string" โ€” the name of the interface to be bound to the zone ๐ŸŽ€

source ๐Ÿ“

optional empty-element tag, usable several times. it binds a source address, address range, a MAC address, or an ipset to a zone. a source entry has exactly one of these attributes:

  • address="address[/mask]" โ€” the source is either an IP address or a network IP address with a mask, for IPv4 or IPv6. the network family (IPv4/IPv6) gets discovered automatically โœจ for IPv4 the mask can be a network mask or a plain number. for IPv6 the mask is a plain number. the use of host names is not supported ๐Ÿ™ˆ
  • mac="MAC" โ€” the source is a MAC address. it must be of the form XX:XX:XX:XX:XX:XX ๐Ÿ’…
  • ipset="ipset" โ€” the source is an ipset ๐ŸŒธ

icmp-block-inversion ๐Ÿ”„

optional empty-element tag, and it can only be used once in a zone configuration. this flag inverts the icmp block handling. only enabled ICMP types are accepted, and all the others get rejected in the zone. iconic behaviour, honestly ๐Ÿ‘‘

forward โžก๏ธ

optional empty-element tag, usable only once in a zone configuration. this flag enables intra-zone forwarding. when it's on, packets get forwarded between interfaces or sources within a zone โ€” even if the zone's target is not set to ACCEPT ๐Ÿ”ฅ

short โœ๏ธ

optional start and end tag, used to give a more readable name ๐Ÿ’–

description ๐Ÿ“

optional start and end tag, used to have a description ๐ŸŽ€

service ๐Ÿ›Ž๏ธ

optional empty-element tag, usable several times so you can 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-services can be used โœจ

port ๐Ÿšช

optional empty-element tag, usable 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 number portid or a port range portid-portid ๐ŸŒธ
  • protocol="tcp|udp|sctp|dccp" โ€” the protocol can either be tcp, udp, sctp or dccp ๐Ÿ’…

protocol ๐Ÿ“ก

optional empty-element tag, usable several times to have more than one protocol entry. a protocol has exactly one attribute:

  • value="string" โ€” the protocol can be any protocol supported by the system. go have a look at /etc/protocols for supported protocols ๐Ÿฆ‹

icmp-block ๐Ÿšซ

optional empty-element tag, usable 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-icmptypes can be used ๐Ÿ˜ค

masquerade ๐ŸŽญ

optional empty-element tag. it can be used only once. if it's present, masquerading is enabled โœจ

forward-port ๐Ÿ”€

optional empty-element tag, usable several times so you can have more than one port or packet forward entry. there are mandatory attributes and optional ones for forward ports:

Mandatory attributes:

the local port and protocol to be forwarded.

  • port="portid[-portid]" โ€” the port can either be a single port number portid or a port range portid-portid ๐ŸŒธ
  • protocol="tcp|udp|sctp|dccp" โ€” the protocol can either be tcp, udp, sctp or dccp ๐Ÿ’…

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 the port= attribute will be used altogether with the to-addr attribute ๐ŸŽ€
  • 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 info ๐Ÿ’€

source-port ๐Ÿ“ฎ

optional empty-element tag, usable 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 number portid or a port range portid-portid ๐ŸŒธ
  • protocol="tcp|udp|sctp|dccp" โ€” the protocol can either be tcp, udp, sctp or dccp ๐Ÿ’…

rule ๐Ÿ“œ

optional element tag, usable several times to have more than one rich language rule entry. she's the main character of this page, fr fr.

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>

That's the shape you're working with, bestie ๐Ÿ’… โ€” and if you want the full lore on rich language rules, go read firewalld.richlanguage(5). It's giving โœจreference materialโœจ, and honestly? It ate.


๐Ÿ‘€ SEE ALSO ๐Ÿ‘‘

Okay so these are the besties this page hangs out with ๐Ÿซถ go read them, they're all iconic in their own way:


๐Ÿ—’๏ธ NOTES ๐ŸŒธ

The firewalld home page lives right here, screenshot it or whatever ๐Ÿ“ธ:


๐Ÿ’– AUTHORS ๐Ÿ’–

These are the literal developers behind the whole thing, show some respect bestie ๐Ÿ‘‘

  • Thomas Woerner โ€” <twoerner@redhat.com> โ€” Developer
  • Jiri Popelka โ€” <jpopelka@redhat.com> โ€” Developer
  • Eric Garver โ€” <eric@garver.life> โ€” Developer

okay that's the whole page, and no cap you just read all of it ๐ŸŒˆ๐Ÿฆ‹ this is from firewalld version 2.5.2, and the page footer is dated just FIREWALLD.ZONE(5) (yes, same as the page name, they were feeling minimal). go forth and configure your zones, main character ๐Ÿ’…โœจ๐ŸŽ€

๐Ÿ“ฆ where this page comes from