firewall-cmd — firewalld command line client
firewall-cmd[OPTIONS...]
firewall-cmd is the command line client of the firewalld daemon. It provides interface to manage runtime and permanent configuration.
The runtime configuration in firewalld is separated from the permanent configuration. This means that things can get changed in the runtime or permanent configuration.
For sequence options, this are the options that can be specified multiple times, the exit code is 0 if there is at least one item that succeded. TheALREADY_ENABLED(11),NOT_ENABLED(12) and alsoZONE_ALREADY_SET(16) errors are treated as succeeded. If there are issues while parsing the items, then these are treated as warnings and will not change the result as long as there is a succeeded one. Without any succeeded item, the exit code will depend on the error codes. If there is exactly one error code, then this is used. If there are more than one thenUNKNOWN_ERROR(254) will be used.
The following options are supported:
Status Options
--stateCheck whether the firewalld daemon is active (i.e. running). Returns an exit code 0 if it is active,
NOT_RUNNINGotherwise (see the section called “Exit Codes”). This will also print the state toSTDOUT.--reloadReload firewall rules and keep state information. Current permanent configuration will become new runtime configuration, i.e. all runtime only changes done until reload are lost with reload if they have not been also in permanent configuration.
--complete-reloadReload firewall completely, even netfilter kernel modules. This will most likely terminate active connections, because state information is lost. This option should only be used in case of severe firewall problems. For example if there are state information problems that no connection can be established with correct firewall rules.
--runtime-to-permanentSave active runtime configuration and overwrite permanent configuration with it. The way this is supposed to work is that when configuring firewalld you do runtime changes only and once you're happy with the configuration and you tested that it works the way you want, you save the configuration to disk.
Log Denied Options
--get-log-deniedPrint the log denied setting.
--set-log-denied=valueAdd logging rules right before reject and drop rules in the INPUT, FORWARD and OUTPUT chains for the default rules and also final reject and drop rules in zones for the configured link-layer packet type. The possible values are:
all,unicast,broadcast,multicastandoff. The default setting isoff, which disables the logging.This is a runtime and permanent change and will also reload the firewall to be able to add the logging rules.
Automatic Helpers Options
--get-automatic-helpersPrint the automatic helpers setting.
--set-automatic-helpers=valueFor the secure use of iptables and connection tracking helpers it is recommended to turn AutomaticHelpers off. But this might have side effects on other services using the netfilter helpers as the sysctl setting in
/proc/sys/net/netfilter/nf_conntrack_helperwill be changed. With the system setting, the default value set in the kernel or with sysctl will be used. Possible values are:yes,noandsystem. The default value issystem.This is a runtime and permanent change and will also reload the firewall to be able to make the helpers usable.
Permanent Options
--permanentThe permanent option
--permanentcan be used to set options permanently. These changes are not effective immediately, only after service restart/reload or system reboot. Without the--permanentoption, a change will only be part of the runtime configuration.If you want to make a change in runtime and permanent configuration, use the same call with and without the
--permanentoption.The
--permanentoption can be optionally added to all options further down where it is supported.
Zone Options
--get-default-zonePrint default zone for connections and interfaces.
--set-default-zone=zoneSet default zone for connections and interfaces where no zone has been selected. Setting the default zone changes the zone for the connections or interfaces, that are using the default zone.
This is a runtime and permanent change.
--get-active-zonesPrint currently active zones altogether with interfaces and sources used in these zones. Active zones are zones, that have a binding to an interface or source. The output format is:
zone1interfaces:interface1interface2.. sources:source1..zone2interfaces:interface3..zone3sources:source2..If there are no interfaces or sources bound to the zone, the corresponding line will be omitted.
[ --permanent]--get-zonesPrint predefined zones as a space separated list.
[ --permanent]--get-servicesPrint predefined services as a space separated list.
[ --permanent]--get-icmptypesPrint predefined icmptypes as a space separated list.
[ --permanent]--get-zone-of-interface=interfacePrint the name of the zone the
interfaceis bound to or no zone.[ --permanent]--get-zone-of-source=source[/mask]|MAC|ipset:ipsetPrint the name of the zone the source is bound to or no zone.
[ --permanent]--info-zone=zonePrint information about the zone
zone. The output format is:zoneinterfaces:interface1.. sources:source1.. services:service1.. ports:port1.. protocols:protocol1.. forward-ports:forward-port1.. source-ports:source-port1.. icmp-blocks:icmp-type1.. rich rules:rich-rule1..
[ --permanent]--list-all-zonesList everything added for or enabled in all zones. The output format is:
zone1interfaces:interface1.. sources:source1.. services:service1.. ports:port1.. protocols:protocol1.. forward-ports:forward-port1.. icmp-blocks:icmp-type1.. rich rules:rich-rule1.. ..
--permanent--new-zone=zoneAdd a new permanent and empty zone.
--permanent--new-zone-from-file=filename[--name=zone]Add a new permanent zone from a prepared zone file with an optional name override.
--permanent--delete-zone=zoneDelete an existing permanent zone.
--permanent--load-zone-defaults=zoneLoad zone default settings or report NO_DEFAULTS error.
--permanent--path-zone=zonePrint path of the zone configuration file.
--permanent--zone=zone--set-description=descriptionSet new description to zone
--permanent--zone=zone--get-descriptionPrint description for zone
--permanent--zone=zone--set-short=descriptionSet short description to zone
--permanent--zone=zone--get-shortPrint short description for zone
--permanent[--zone=zone]--get-targetGet the target of a permanent zone.
--permanent[--zone=zone]--set-target=targetSet the target of a permanent zone.
targetis one of:default,ACCEPT,DROP,REJECT
Options to Adapt and Query Zones
Options in this section affect only one particular zone. If used with--zone=zoneoption, they affect the zonezone. If the option is omitted, they affect default zone (see--get-default-zone).[ --permanent] [--zone=zone]--list-allList everything added for or enabled in
zone. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--list-servicesList services added for
zoneas a space separated list. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-service=service[--timeout=timeval]Add a service for
zone. If zone is omitted, default zone will be used. This option can be specified multiple times. If a timeout is supplied, the rule will be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.The service is one of the firewalld provided services. To get a list of the supported services, use firewall-cmd --get-services.
The
--timeoutoption is not combinable with the--permanentoption.[ --permanent] [--zone=zone]--remove-service=serviceRemove a service from
zone. This option can be specified multiple times. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--query-service=serviceReturn whether
servicehas been added forzone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.[ --permanent] [--zone=zone]--list-portsList ports added for
zoneas a space separated list. A port is of the formportid[-portid]/protocol, it can be either a port and protocol pair or a port range with a protocol. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-port=portid[-portid]/protocol[--timeout=timeval]Add the port for
zone. If zone is omitted, default zone will be used. This option can be specified multiple times. If a timeout is supplied, the rule will be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.The port can either be a single port number or a port range
portid-portid. The protocol can either betcp,udp,sctpordccp.The
--timeoutoption is not combinable with the--permanentoption.[ --permanent] [--zone=zone]--remove-port=portid[-portid]/protocolRemove the port from
zone. If zone is omitted, default zone will be used. This option can be specified multiple times.[ --permanent] [--zone=zone]--query-port=portid[-portid]/protocolReturn whether the port has been added for
zone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.[ --permanent] [--zone=zone]--list-protocolsList protocols added for
zoneas a space separated list. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-protocol=protocol[--timeout=timeval]Add the protocol for
zone. If zone is omitted, default zone will be used. This option can be specified multiple times. If a timeout is supplied, the rule will be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.The protocol can be any protocol supported by the system. Please have a look at
/etc/protocolsfor supported protocols.The
--timeoutoption is not combinable with the--permanentoption.[ --permanent] [--zone=zone]--remove-protocol=protocolRemove the protocol from
zone. If zone is omitted, default zone will be used. This option can be specified multiple times.[ --permanent] [--zone=zone]--query-protocol=protocolReturn whether the protocol has been added for
zone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.[ --permanent] [--zone=zone]--list-source-portsList source ports added for
zoneas a space separated list. A port is of the formportid[-portid]/protocol. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-source-port=portid[-portid]/protocol[--timeout=timeval]Add the source port for
zone. If zone is omitted, default zone will be used. This option can be specified multiple times. If a timeout is supplied, the rule will be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.The port can either be a single port number or a port range
portid-portid. The protocol can either betcp,udp,sctpordccp.The
--timeoutoption is not combinable with the--permanentoption.[ --permanent] [--zone=zone]--remove-source-port=portid[-portid]/protocolRemove the source port from
zone. If zone is omitted, default zone will be used. This option can be specified multiple times.[ --permanent] [--zone=zone]--query-source-port=portid[-portid]/protocolReturn whether the source port has been added for
zone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.[ --permanent] [--zone=zone]--list-icmp-blocksList Internet Control Message Protocol (ICMP) type blocks added for
zoneas a space separated list. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-icmp-block=icmptype[--timeout=timeval]Add an ICMP block for
icmptypeforzone. If zone is omitted, default zone will be used. This option can be specified multiple times. If a timeout is supplied, the rule will be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.The
icmptypeis the one of the icmp types firewalld supports. To get a listing of supported icmp types: firewall-cmd --get-icmptypesThe
--timeoutoption is not combinable with the--permanentoption.[ --permanent] [--zone=zone]--remove-icmp-block=icmptypeRemove the ICMP block for
icmptypefromzone. If zone is omitted, default zone will be used. This option can be specified multiple times.[ --permanent] [--zone=zone]--query-icmp-block=icmptypeReturn whether an ICMP block for
icmptypehas been added forzone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.[ --permanent] [--zone=zone]--list-forward-portsList IPv4 forward ports added for
zoneas a space separated list. If zone is omitted, default zone will be used.For IPv6 forward ports, please use the rich language.
[ --permanent] [--zone=zone]--add-forward-port=port=portid[-portid]:proto=protocol[:toport=portid[-portid]][:toaddr=address[/mask]] [--timeout=timeval]Add the IPv4 forward port for
zone. If zone is omitted, default zone will be used. This option can be specified multiple times. If a timeout is supplied, the rule will be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.The port can either be a single port number
portidor a port rangeportid-portid. The protocol can either betcp,udp,sctpordccp. The destination address is a simple IP address.The
--timeoutoption is not combinable with the--permanentoption.For IPv6 forward ports, please use the rich language.
[ --permanent] [--zone=zone]--remove-forward-port=port=portid[-portid]:proto=protocol[:toport=portid[-portid]][:toaddr=address[/mask]]Remove the IPv4 forward port from
zone. If zone is omitted, default zone will be used. This option can be specified multiple times.For IPv6 forward ports, please use the rich language.
[ --permanent] [--zone=zone]--query-forward-port=port=portid[-portid]:proto=protocol[:toport=portid[-portid]][:toaddr=address[/mask]]Return whether the IPv4 forward port has been added for
zone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.For IPv6 forward ports, please use the rich language.
[ --permanent] [--zone=zone]--add-masquerade[--timeout=timeval]Enable IPv4 masquerade for
zone. If zone is omitted, default zone will be used. If a timeout is supplied, masquerading will be active for the specified amount of time.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h. Masquerading is useful if the machine is a router and machines connected over an interface in another zone should be able to use the first connection.The
--timeoutoption is not combinable with the--permanentoption.For IPv6 masquerading, please use the rich language.
[ --permanent] [--zone=zone]--remove-masqueradeDisable IPv4 masquerade for
zone. If zone is omitted, default zone will be used. If the masquerading was enabled with a timeout, it will be disabled also.For IPv6 masquerading, please use the rich language.
[ --permanent] [--zone=zone]--query-masqueradeReturn whether IPv4 masquerading has been enabled for
zone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.For IPv6 masquerading, please use the rich language.
[ --permanent] [--zone=zone]--list-rich-rulesList rich language rules added for
zoneas a newline separated list. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-rich-rule='rule' [--timeout=timeval]Add rich language rule '
rule' forzone. This option can be specified multiple times. If zone is omitted, default zone will be used. If a timeout is supplied, therulewill be active for the specified amount of time and will be removed automatically afterwards.timevalis either a number (of seconds) or number followed by one of characterss(seconds),m(minutes),h(hours), for example20mor1h.For the rich language rule syntax, please have a look at firewalld.richlanguage(5).
The
--timeoutoption is not combinable with the--permanentoption.[ --permanent] [--zone=zone]--remove-rich-rule='rule'Remove rich language rule '
rule' fromzone. This option can be specified multiple times. If zone is omitted, default zone will be used.For the rich language rule syntax, please have a look at firewalld.richlanguage(5).
[ --permanent] [--zone=zone]--query-rich-rule='rule'Return whether a rich language rule '
rule' has been added forzone. If zone is omitted, default zone will be used. Returns 0 if true, 1 otherwise.For the rich language rule syntax, please have a look at firewalld.richlanguage(5).
Options to Handle Bindings of Interfaces
Binding an interface to a zone means that this zone settings are used to restrict traffic via the interface.Options in this section affect only one particular zone. If used with--zone=zoneoption, they affect the zonezone. If the option is omitted, they affect default zone (see--get-default-zone).For a list of predefined zones use firewall-cmd --get-zones.An interface name is a string up to 16 characters long, that may not contain' ','/','!'and'*'.[ --permanent] [--zone=zone]--list-interfacesList interfaces that are bound to zone
zoneas a space separated list. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-interface=interfaceBind interface
interfaceto zonezone. If zone is omitted, default zone will be used.If the interface is under control of NetworkManager, it is at first connected to change the zone for the connection that is using the interface. If this fails, the zone binding is created in firewalld and the limitations below apply. For interfaces that are not under control of NetworkManager, firewalld tries to change the ZONE setting in the ifcfg file, if the file exists.
As a end user you don't need this in most cases, because NetworkManager (or legacy network service) adds interfaces into zones automatically (according to
ZONE=option from ifcfg-interfacefile) ifNM_CONTROLLED=nois not set. You should do it only if there's no /etc/sysconfig/network-scripts/ifcfg-interfacefile. If there is such file and you add interface to zone with this--add-interfaceoption, make sure the zone is the same in both cases, otherwise the behaviour would be undefined. Please also have a look at the firewalld(1) man page in theConceptssection. For permanent association of interface with a zone, see also 'How to set or change a zone for a connection?' in firewalld.zones(5).[ --zone=zone]--change-interface=interfaceIf the interface is under control of NetworkManager, it is at first connected to change the zone for the connection that is using the interface. If this fails, the zone binding is created in firewalld and the limitations below apply. For interfaces that are not under control of NetworkManager, firewalld tries to change the ZONE setting in the ifcfg file, if the file exists.
Change zone the interface
interfaceis bound to to zonezone. It's basically--remove-interfacefollowed by--add-interface. If the interface has not been bound to a zone before, it behaves like--add-interface. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--query-interface=interfaceQuery whether interface
interfaceis bound to zonezone. Returns 0 if true, 1 otherwise.[ --permanent]--remove-interface=interfaceIf the interface is under control of NetworkManager, it is at first connected to change the zone for the connection that is using the interface. If this fails, the zone binding is created in firewalld and the limitations below apply.
For the addion or change of interfaces that are not under control of NetworkManager: firewalld tries to change the ZONE setting in the ifcfg file, if an ifcfg file exists that is using the interface.
Only for the removal of interfaces that are not under control of NetworkManager: firewalld is not trying to change the ZONE setting in the ifcfg file. This is needed to make sure that an ifdown of the interface will not result in a reset of the zone setting to the default zone. Only the zone binding is then removed in firewalld then.
Remove binding of interface
interfacefrom zone it was previously added to.
Options to Handle Bindings of Sources
Binding a source to a zone means that this zone settings will be used to restrict traffic from this source.A source address or address range is either an IP address or a network IP address with a mask for IPv4 or IPv6 or a MAC address or an ipset with the ipset: prefix. 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.Options in this section affect only one particular zone. If used with--zone=zoneoption, they affect the zonezone. If the option is omitted, they affect default zone (see--get-default-zone).For a list of predefined zones use firewall-cmd [--permanent] --get-zones.[ --permanent] [--zone=zone]--list-sourcesList sources that are bound to zone
zoneas a space separated list. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--add-source=source[/mask]|MAC|ipset:ipsetBind the source to zone
zone. If zone is omitted, default zone will be used.[ --zone=zone]--change-source=source[/mask]|MAC|ipset:ipsetChange zone the source is bound to to zone
zone. It's basically--remove-sourcefollowed by--add-source. If the source has not been bound to a zone before, it behaves like--add-source. If zone is omitted, default zone will be used.[ --permanent] [--zone=zone]--query-source=source[/mask]|MAC|ipset:ipsetQuery whether the source is bound to the zone
zone. Returns 0 if true, 1 otherwise.[ --permanent]--remove-source=source[/mask]|MAC|ipset:ipsetRemove binding of the source from zone it was previously added to.
IPSet Options
--get-ipset-typesPrint the supported ipset types.
--permanent--new-ipset=ipset--type=type[--family=inet|inet6] [--option=key[=value]]Add a new permanent and empty ipset with specifying the type and optional the family and options like
timeout,hashsizeandmaxelem. For more information please have a look at ipset(8) man page.--permanent--new-ipset-from-file=filename[--name=ipset]Add a new permanent ipset from a prepared ipset file with an optional name override.
--permanent--delete-ipset=ipsetDelete an existing permanent ipset.
--permanent--load-ipset-defaults=ipsetLoad ipset default settings or report NO_DEFAULTS error.
[ --permanent]--info-ipset=ipsetPrint information about the ipset
ipset. The output format is:ipsettype:typeoptions:option1[=value1].. entries:entry1..
[ --permanent]--get-ipsetsPrint predefined ipsets as a space separated list.
--permanent--ipset=ipset--set-description=descriptionSet new description to ipset
--permanent--ipset=ipset--get-descriptionPrint description for ipset
--permanent--ipset=ipset--set-short=descriptionSet short description to ipset
--permanent--ipset=ipset--get-shortPrint short description for ipset
[ --permanent]--ipset=ipset--add-entry=entryAdd a new entry to the ipset.
[ --permanent]--ipset=ipset--remove-entry=entryRemove an entry from the ipset.
[ --permanent]--ipset=ipset--query-entry=entryReturn whether the entry has been added to an ipset. Returns 0 if true, 1 otherwise.
[ --permanent]--ipset=ipset--get-entriesList all entries of the ipset.
[ --permanent]--ipset=ipset--add-entries-from-file=filenameAdd a new entries to the ipset from the file. For all entries that are listed in the file but already in the ipset, a warning will be printed.
The file should contain an entry per line. Lines starting with an hash or semicolon are ignored. Also empty lines.
[ --permanent]--ipset=ipset--remove-entries-from-file=filenameRemove existing entries from the ipset from the file. For all entries that are listed in the file but not in the ipset, a warning will be printed.
The file should contain an entry per line. Lines starting with an hash or semicolon are ignored. Also empty lines.
--permanent--path-ipset=ipsetPrint path of the ipset configuration file.
Service Options
Options in this section affect only one particular service.[ --permanent]--info-service=servicePrint information about the service
service. The output format is:serviceports:port1.. protocols:protocol1.. source-ports:source-port1.. modules:module1.. destination:ipv1:address1..
The following options are only usable in the permanent configuration.--permanent--new-service=serviceAdd a new permanent and empty service.
--permanent--new-service-from-file=filename[--name=service]Add a new permanent service from a prepared service file with an optional name override.
--permanent--delete-service=serviceDelete an existing permanent service.
--permanent--load-service-defaults=serviceLoad service default settings or report NO_DEFAULTS error.
--permanent--path-service=servicePrint path of the service configuration file.
--permanent--service=service--set-description=descriptionSet new description to service
--permanent--service=service--get-descriptionPrint description for service
--permanent--service=service--set-short=descriptionSet short description to service
--permanent--service=service--get-shortPrint short description for service
--permanent--service=service--add-port=portid[-portid]/protocolAdd a new port to the permanent service.
--permanent--service=service--remove-port=portid[-portid]/protocolRemove a port from the permanent service.
--permanent--service=service--query-port=portid[-portid]/protocolReturn wether the port has been added to the permanent service.
--permanent--service=service--get-portsList ports added to the permanent service.
--permanent--service=service--add-protocol=protocolAdd a new protocol to the permanent service.
--permanent--service=service--remove-protocol=protocolRemove a protocol from the permanent service.
--permanent--service=service--query-protocol=protocolReturn wether the protocol has been added to the permanent service.
--permanent--service=service--get-protocolsList protocols added to the permanent service.
--permanent--service=service--add-source-port=portid[-portid]/protocolAdd a new source port to the permanent service.
--permanent--service=service--remove-source-port=portid[-portid]/protocolRemove a source port from the permanent service.
--permanent--service=service--query-source-port=portid[-portid]/protocolReturn wether the source port has been added to the permanent service.
--permanent--service=service--get-source-portsList source ports added to the permanent service.
--permanent--service=service--add-module=moduleAdd a new module to the permanent service.
--permanent--service=service--remove-module=moduleRemove a module from the permanent service.
--permanent--service=service--query-module=moduleReturn wether the module has been added to the permanent service.
--permanent--service=service--get-modulesList modules added to the permanent service.
--permanent--service=service--set-destination=ipv:address[/mask]Set destination for ipv to address[/mask] in the permanent service.
--permanent--service=service--remove-destination=ipvRemove the destination for ipv from the permanent service.
--permanent--service=service--query-destination=ipv:address[/mask]Return wether the destination ipv to address[/mask] has been set in the permanent service.
--permanent--service=service--get-destinationsList destinations added to the permanent service.
Helper Options
Options in this section affect only one particular helper.[ --permanent]--info-helper=helperPrint information about the helper
helper. The output format is:helperfamily:familymodule:moduleports:port1..
The following options are only usable in the permanent configuration.--permanent--new-helper=helper--module=nf_conntrack_module[--family=ipv4|ipv6]Add a new permanent helper with module and optionally family defined.
--permanent--new-helper-from-file=filename[--name=helper]Add a new permanent helper from a prepared helper file with an optional name override.
--permanent--delete-helper=helperDelete an existing permanent helper.
--permanent--load-helper-defaults=helperLoad helper default settings or report NO_DEFAULTS error.
--permanent--path-helper=helperPrint path of the helper configuration file.
[ --permanent]--get-helpersPrint predefined helpers as a space separated list.
--permanent--helper=helper--set-description=descriptionSet new description to helper
--permanent--helper=helper--get-descriptionPrint description for helper
--permanent--helper=helper--set-short=descriptionSet short description to helper
--permanent--helper=helper--get-shortPrint short description for helper
--permanent--helper=helper--add-port=portid[-portid]/protocolAdd a new port to the permanent helper.
--permanent--helper=helper--remove-port=portid[-portid]/protocolRemove a port from the permanent helper.
--permanent--helper=helper--query-port=portid[-portid]/protocolReturn wether the port has been added to the permanent helper.
--permanent--helper=helper--get-portsList ports added to the permanent helper.
--permanent--helper=helper--set-module=descriptionSet module description for helper
--permanent--helper=helper--get-modulePrint module description for helper
--permanent--helper=helper--set-family=descriptionSet family description for helper
--permanent--helper=helper--get-familyPrint family description of helper
Internet Control Message Protocol (ICMP) type Options
Options in this section affect only one particular icmptype.[ --permanent]--info-icmptype=icmptypePrint information about the icmptype
icmptype. The output format is:icmptypedestination:ipv1..
The following options are only usable in the permanent configuration.--permanent--new-icmptype=icmptypeAdd a new permanent and empty icmptype.
--permanent--new-icmptype-from-file=filename[--name=icmptype]Add a new permanent icmptype from a prepared icmptype file with an optional name override.
--permanent--delete-icmptype=icmptypeDelete an existing permanent icmptype.
--permanent--load-icmptype-defaults=icmptypeLoad icmptype default settings or report NO_DEFAULTS error.
--permanent--icmptype=icmptype--set-description=descriptionSet new description to icmptype
--permanent--icmptype=icmptype--get-descriptionPrint description for icmptype
--permanent--icmptype=icmptype--set-short=descriptionSet short description to icmptype
--permanent--icmptype=icmptype--get-shortPrint short description for icmptype
--permanent--icmptype=icmptype--add-destination=ipvEnable destination for ipv in permanent icmptype. ipv is one of
ipv4oripv6.--permanent--icmptype=icmptype--remove-destination=ipvDisable destination for ipv in permanent icmptype. ipv is one of
ipv4oripv6.--permanent--icmptype=icmptype--query-destination=ipvReturn whether destination for ipv is enabled in permanent icmptype. ipv is one of
ipv4oripv6.--permanent--icmptype=icmptype--get-destinationsList destinations in permanent icmptype.
--permanent--path-icmptype=icmptypePrint path of the icmptype configuration file.
Direct Options
The direct options give a more direct access to the firewall. These options require user to know basic iptables concepts, i.e.table(filter/mangle/nat/...),chain(INPUT/OUTPUT/FORWARD/...),commands(-A/-D/-I/...),parameters(-p/-s/-d/-j/...) andtargets(ACCEPT/DROP/REJECT/...).Direct options should be used only as a last resort when it's not possible to use for example--add-service=serviceor--add-rich-rule='rule'.The first argument of each option has to beipv4oripv6oreb. Withipv4it will be for IPv4 (iptables(8)), withipv6for IPv6 (ip6tables(8)) and withebfor ethernet bridges (ebtables(8)).[ --permanent]--direct--get-all-chainsGet all chains added to all tables. This option concerns only chains previously added with
--direct --add-chain.[ --permanent]--direct--get-chains{ipv4|ipv6|eb}tableGet all chains added to table
tableas a space separated list. This option concerns only chains previously added with--direct --add-chain.[ --permanent]--direct--add-chain{ipv4|ipv6|eb}tablechainAdd a new chain with name
chainto tabletable. Make sure there's no other chain with this name already.There already exist basic chains to use with direct options, for example
INPUT_directchain (seeiptables-save | grep directoutput for all of them). These chains are jumped into before chains for zones, i.e. every rule put intoINPUT_directwill be checked before rules in zones.[ --permanent]--direct--remove-chain{ipv4|ipv6|eb}tablechainRemove chain with name
chainfrom tabletable. Only chains previously added with--direct --add-chaincan be removed this way.[ --permanent]--direct--query-chain{ipv4|ipv6|eb}tablechainReturn whether a chain with name
chainexists in tabletable. Returns 0 if true, 1 otherwise. This option concerns only chains previously added with--direct --add-chain.[ --permanent]--direct--get-all-rulesGet all rules added to all chains in all tables as a newline separated list of the priority and arguments. This option concerns only rules previously added with
--direct --add-rule.[ --permanent]--direct--get-rules{ipv4|ipv6|eb}tablechainGet all rules added to chain
chainin tabletableas a newline separated list of the priority and arguments. This option concerns only rules previously added with--direct --add-rule.[ --permanent]--direct--add-rule{ipv4|ipv6|eb}tablechainpriorityargsAdd a rule with the arguments
argsto chainchainin tabletablewith prioritypriority.The
priorityis used to order rules. Priority 0 means add rule on top of the chain, with a higher priority the rule will be added further down. Rules with the same priority are on the same level and the order of these rules is not fixed and may change. If you want to make sure that a rule will be added after another one, use a low priority for the first and a higher for the following.[ --permanent]--direct--remove-rule{ipv4|ipv6|eb}tablechainpriorityargsRemove a rule with
priorityand the argumentsargsfrom chainchainin tabletable. Only rules previously added with--direct --add-rulecan be removed this way.[ --permanent]--direct--remove-rules{ipv4|ipv6|eb}tablechainRemove all rules in the chain with name
chainexists in tabletable. This option concerns only rules previously added with--direct --add-rulein this chain.[ --permanent]--direct--query-rule{ipv4|ipv6|eb}tablechainpriorityargsReturn whether a rule with
priorityand the argumentsargsexists in chainchainin tabletable. Returns 0 if true, 1 otherwise. This option concerns only rules previously added with--direct --add-rule.--direct--passthrough{ipv4|ipv6|eb}argsPass a command through to the firewall.
argscan be all iptables, ip6tables and ebtables command line arguments. This command is untracked, which means that firewalld is not able to provide information about this command later on, also not a listing of the untracked passthoughs.[ --permanent]--direct--get-all-passthroughsGet all passthrough rules as a newline separated list of the ipv value and arguments.
[ --permanent]--direct--get-passthroughs{ipv4|ipv6|eb}Get all passthrough rules for the ipv value as a newline separated list of the priority and arguments.
[ --permanent]--direct--add-passthrough{ipv4|ipv6|eb}argsAdd a passthrough rule with the arguments
argsfor the ipv value.[ --permanent]--direct--remove-passthrough{ipv4|ipv6|eb}argsRemove a passthrough rule with the arguments
argsfor the ipv value.[ --permanent]--direct--query-passthrough{ipv4|ipv6|eb}argsReturn whether a passthrough rule with the arguments
argsexists for the ipv value. Returns 0 if true, 1 otherwise.
Lockdown Options
Local applications or services are able to change the firewall configuration if they are running as root (example: libvirt) or are authenticated using PolicyKit. With this feature administrators can lock the firewall configuration so that only applications on lockdown whitelist are able to request firewall changes.The lockdown access check limits D-Bus methods that are changing firewall rules. Query, list and get methods are not limited.The lockdown feature is a very light version of user and application policies for firewalld and is turned off by default.--lockdown-onEnable lockdown. Be careful - if firewall-cmd is not on lockdown whitelist when you enable lockdown you won't be able to disable it again with firewall-cmd, you would need to edit firewalld.conf.
This is a runtime and permanent change.
--lockdown-offDisable lockdown.
This is a runtime and permanent change.
--query-lockdownQuery whether lockdown is enabled. Returns 0 if lockdown is enabled, 1 otherwise.
Lockdown Whitelist Options
The lockdown whitelist can containcommands,contexts,usersanduser ids.If a command entry on the whitelist ends with an asterisk '*', then all command lines starting with the command will match. If the '*' is not there the absolute command inclusive arguments must match.Commands for user root and others is not always the same. Example: As root /bin/firewall-cmd is used, as a normal user /usr/bin/firewall-cmd is be used on Fedora.The context is the security (SELinux) context of a running application or service. To get the context of a running application use ps -e --context.Warning: If the context is unconfined, then this will open access for more than the desired application.The lockdown whitelist entries are checked in the following order:
1. context2. uid3. user4. command[ --permanent]--list-lockdown-whitelist-commandsList all command lines that are on the whitelist.
[ --permanent]--add-lockdown-whitelist-command=commandAdd the
commandto the whitelist.[ --permanent]--remove-lockdown-whitelist-command=commandRemove the
commandfrom the whitelist.[ --permanent]--query-lockdown-whitelist-command=commandQuery whether the
commandis on the whitelist. Returns 0 if true, 1 otherwise.[ --permanent]--list-lockdown-whitelist-contextsList all contexts that are on the whitelist.
[ --permanent]--add-lockdown-whitelist-context=contextAdd the context
contextto the whitelist.[ --permanent]--remove-lockdown-whitelist-context=contextRemove the
contextfrom the whitelist.[ --permanent]--query-lockdown-whitelist-context=contextQuery whether the
contextis on the whitelist. Returns 0 if true, 1 otherwise.[ --permanent]--list-lockdown-whitelist-uidsList all user ids that are on the whitelist.
[ --permanent]--add-lockdown-whitelist-uid=uidAdd the user id
uidto the whitelist.[ --permanent]--remove-lockdown-whitelist-uid=uidRemove the user id
uidfrom the whitelist.[ --permanent]--query-lockdown-whitelist-uid=uidQuery whether the user id
uidis on the whitelist. Returns 0 if true, 1 otherwise.[ --permanent]--list-lockdown-whitelist-usersList all user names that are on the whitelist.
[ --permanent]--add-lockdown-whitelist-user=userAdd the user name
userto the whitelist.[ --permanent]--remove-lockdown-whitelist-user=userRemove the user name
userfrom the whitelist.[ --permanent]--query-lockdown-whitelist-user=userQuery whether the user name
useris on the whitelist. Returns 0 if true, 1 otherwise.
Panic Options
--panic-onEnable panic mode. All incoming and outgoing packets are dropped, active connections will expire. Enable this only if there are serious problems with your network environment. For example if the machine is getting hacked in.
This is a runtime only change.
--panic-offDisable panic mode. After disabling panic mode established connections might work again, if panic mode was enabled for a short period of time.
This is a runtime only change.
--query-panicReturns 0 if panic mode is enabled, 1 otherwise.
For more examples see http://fedoraproject.org/wiki/FirewallD
Example 2
Enable port 443/tcp immediately and permanently in default zone. To make the change effective immediately and also after restart we need two commands. The first command makes the change in runtime configuration, i.e. makes it effective immediately, until restart. The second command makes the change in permanent configuration, i.e. makes it effective after restart.firewall-cmd --add-port=443/tcp firewall-cmd --permanent --add-port=443/tcp
On success 0 is returned. On failure the output is red colored and exit code is either 2 in case of wrong command-line option usage or one of the following error codes in other cases:
String Code ALREADY_ENABLED 11 NOT_ENABLED 12 COMMAND_FAILED 13 NO_IPV6_NAT 14 PANIC_MODE 15 ZONE_ALREADY_SET 16 UNKNOWN_INTERFACE 17 ZONE_CONFLICT 18 BUILTIN_CHAIN 19 EBTABLES_NO_REJECT 20 NOT_OVERLOADABLE 21 NO_DEFAULTS 22 BUILTIN_ZONE 23 BUILTIN_SERVICE 24 BUILTIN_ICMPTYPE 25 NAME_CONFLICT 26 NAME_MISMATCH 27 PARSE_ERROR 28 ACCESS_DENIED 29 UNKNOWN_SOURCE 30 RT_TO_PERM_FAILED 31 IPSET_WITH_TIMEOUT 32 BUILTIN_IPSET 33 ALREADY_SET 34 MISSING_IMPORT 35 DBUS_ERROR 36 BUILTIN_HELPER 37 NOT_APPLIED 38 INVALID_ACTION 100 INVALID_SERVICE 101 INVALID_PORT 102 INVALID_PROTOCOL 103 INVALID_INTERFACE 104 INVALID_ADDR 105 INVALID_FORWARD 106 INVALID_ICMPTYPE 107 INVALID_TABLE 108 INVALID_CHAIN 109 INVALID_TARGET 110 INVALID_IPV 111 INVALID_ZONE 112 INVALID_PROPERTY 113 INVALID_VALUE 114 INVALID_OBJECT 115 INVALID_NAME 116 INVALID_FILENAME 117 INVALID_DIRECTORY 118 INVALID_TYPE 119 INVALID_SETTING 120 INVALID_DESTINATION 121 INVALID_RULE 122 INVALID_LIMIT 123 INVALID_FAMILY 124 INVALID_LOG_LEVEL 125 INVALID_AUDIT_TYPE 126 INVALID_MARK 127 INVALID_CONTEXT 128 INVALID_COMMAND 129 INVALID_USER 130 INVALID_UID 131 INVALID_MODULE 132 INVALID_PASSTHROUGH 133 INVALID_MAC 134 INVALID_IPSET 135 INVALID_ENTRY 136 INVALID_OPTION 137 INVALID_HELPER 138 MISSING_TABLE 200 MISSING_CHAIN 201 MISSING_PORT 202 MISSING_PROTOCOL 203 MISSING_ADDR 204 MISSING_NAME 205 MISSING_SETTING 206 MISSING_FAMILY 207 NOT_RUNNING 252 NOT_AUTHORIZED 253 UNKNOWN_ERROR 254
firewall-applet(1), firewalld(1), firewall-cmd(1), firewall-config(1), firewallctl(1), firewalld.conf(5), firewalld.direct(5), firewalld.dbus(5), firewalld.icmptype(5), firewalld.lockdown-whitelist(5), firewall-offline-cmd(1), firewalld.richlanguage(5), firewalld.service(5), firewalld.zone(5), firewalld.zones(5), firewalld.ipset(5), firewalld.helper(5)