<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.virusstyle.synology.me/index.php?action=history&amp;feed=atom&amp;title=CentOS%2FUseful_Examples_of_firewall-cmd_command</id>
	<title>CentOS/Useful Examples of firewall-cmd command - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.virusstyle.synology.me/index.php?action=history&amp;feed=atom&amp;title=CentOS%2FUseful_Examples_of_firewall-cmd_command"/>
	<link rel="alternate" type="text/html" href="https://wiki.virusstyle.synology.me/index.php?title=CentOS/Useful_Examples_of_firewall-cmd_command&amp;action=history"/>
	<updated>2026-04-21T12:38:18Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.43.5</generator>
	<entry>
		<id>https://wiki.virusstyle.synology.me/index.php?title=CentOS/Useful_Examples_of_firewall-cmd_command&amp;diff=35&amp;oldid=prev</id>
		<title>Kaspars: 1 revision imported</title>
		<link rel="alternate" type="text/html" href="https://wiki.virusstyle.synology.me/index.php?title=CentOS/Useful_Examples_of_firewall-cmd_command&amp;diff=35&amp;oldid=prev"/>
		<updated>2026-04-16T08:41:31Z</updated>

		<summary type="html">&lt;p&gt;1 revision imported&lt;/p&gt;
&lt;table style=&quot;background-color: #fff; color: #202122;&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #202122; text-align: center;&quot;&gt;Revision as of 10:41, 16 April 2026&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;4&quot; class=&quot;diff-notice&quot; lang=&quot;en&quot;&gt;&lt;div class=&quot;mw-diff-empty&quot;&gt;(No difference)&lt;/div&gt;
&lt;/td&gt;&lt;/tr&gt;
&lt;!-- diff cache key mediawiki:diff:1.41:old-34:rev-35 --&gt;
&lt;/table&gt;</summary>
		<author><name>Kaspars</name></author>
	</entry>
	<entry>
		<id>https://wiki.virusstyle.synology.me/index.php?title=CentOS/Useful_Examples_of_firewall-cmd_command&amp;diff=34&amp;oldid=prev</id>
		<title>Kaspars at 07:19, 13 September 2018</title>
		<link rel="alternate" type="text/html" href="https://wiki.virusstyle.synology.me/index.php?title=CentOS/Useful_Examples_of_firewall-cmd_command&amp;diff=34&amp;oldid=prev"/>
		<updated>2018-09-13T07:19:30Z</updated>

		<summary type="html">&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;&amp;lt;div class=&amp;quot;mw-parser-output&amp;quot;&amp;gt;&amp;amp;nbsp;&amp;lt;/div&amp;gt; &amp;lt;div class=&amp;quot;mw-parser-output&amp;quot;&amp;gt;&lt;br /&gt;
&amp;lt;div class=&amp;quot;mw-parser-output&amp;quot;&amp;gt;&lt;br /&gt;
== Installing firewalld ==&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; By default, firewalld is included in the “core” rpm group, but if in case it is not installed, you can always install it using yum.&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# yum install -y firewalld&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; Enable the firewalld to start at boot:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# systemctl enable firewalld&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; Restart the firewalld service now.&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# systemctl restart firewalld&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; Available options with firewall-cmd command&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;&amp;lt;br/&amp;gt; # firewall-cmd --help&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
Usage: firewall-cmd [OPTIONS...]&lt;br /&gt;
&lt;br /&gt;
General Options&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;-h, --help &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; Prints a short help text and exists&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;-V, --version &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;Print the version string of firewalld&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;-q, --quiet &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;Do not print status messages&lt;br /&gt;
&lt;br /&gt;
Status Options&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;--state &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;Return and print firewalld state&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;--reload &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; Reload firewall and keep state information&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;--complete-reload &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp; &amp;amp;nbsp;Reload firewall and lose state information&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;--runtime-to-permanent &amp;amp;nbsp; Create permanent from runtime configuration&amp;lt;br/&amp;gt; The firewall-cmd command offers categories of options such as General, Status, Permanent, Zone, IcmpType, Service, Adapt and Query Zones, Direct, Lockdown, Lockdown Whitelist, and Panic. Refer to the firewall-cmd man page for more information.&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;br /&gt;
&lt;br /&gt;
== Useful firewall-cmd Examples ==&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;br/&amp;gt; List all zones ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; Use the following command to list information for all zones. Only partial output is displayed.&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --list-all-zones&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; work&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;target: default&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;icmp-block-inversion: no&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;interfaces:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;sources:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;services: dhcpv6-client ssh&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;ports:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;protocols:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;masquerade: no&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;forward-ports:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;sourceports:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;icmp-blocks:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;rich rules:&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
drop&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;target: DROP&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;icmp-block-inversion: no&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;interfaces:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;sources:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;services:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;ports:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;protocols:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;masquerade: no&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;forward-ports:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;sourceports:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;icmp-blocks:&amp;amp;nbsp;&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;amp;nbsp; &amp;amp;nbsp;rich rules:&amp;amp;nbsp;&amp;lt;br/&amp;gt; .....&amp;lt;br/&amp;gt; Public is the default zone set, if you do not change it. To check the currently set default zone use the below command:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --get-default-zone&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; public&lt;br /&gt;
&lt;br /&gt;
=== &amp;lt;br/&amp;gt; List allowed service and ports on the system ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; To show currently allowed service on your system use the below command.&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --list-services&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; dhcpv6-client ssh&amp;lt;br/&amp;gt; To list the ports that are open on your system:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --list-ports&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; You would normally see no ports listed here when you have just enabled the firewalld.&lt;br /&gt;
&lt;br /&gt;
=== To Enable all the incoming ports for a service ===&lt;br /&gt;
&lt;br /&gt;
&amp;lt;br/&amp;gt; You can also open the required ports for a service by using the –add-seervice option. To permit access by HTTP clients for the public zone:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --zone=public --add-service=http&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; success&amp;lt;br/&amp;gt; To list services that are allowed for the public zone:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --zone=work --list-services&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; dhcpv6-client http ssh&amp;lt;br/&amp;gt; Using this command only changes the Runtime configuration and does not update the configuration files. The following sequence of commands shows that configuration changes made in Runtime configuration mode are lost when the firewalld service is restarted:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# systemctl restart firewalld&amp;lt;br/&amp;gt; # firewall-cmd --zone=work --list-services&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; dhcpv6-client ssh&amp;lt;br/&amp;gt; To make changes permanent, use the –permanent option. Example:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --permanent --zone=public --add-service=http&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; success&amp;lt;br/&amp;gt; Changes made in Permanent configuration mode are not implemented immediately. Example:&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --zone=work --list-services&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;lt;br/&amp;gt; dhcpv6-client ssh&amp;lt;br/&amp;gt; However, changes made in a Permanent configuration are written to configuration files. Restarting the firewalld service reads the configuration files and implements the changes.&lt;br /&gt;
&lt;br /&gt;
=== Example: ===&lt;br /&gt;
&amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# systemctl restart firewalld&amp;lt;br/&amp;gt; # firewall-cmd --zone=work --list-services&amp;lt;br/&amp;gt; dhcpv6-client http ssh&amp;lt;br/&amp;gt; 4. Allow traffic on an incoming port&amp;lt;br/&amp;gt; The command below will open the port 2222 effective immediately, but will not persist across reboots:&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --add-port=[YOUR PORT]/tcp&amp;lt;br/&amp;gt; For example, to open TCP port 2222 :&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --add-port=2222/tcp&amp;lt;br/&amp;gt; The following command will create a persistent rule, but will not be put into effect immediately:&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --permanent --add-port=[YOUR PORT]/tcp&amp;lt;br/&amp;gt; For Example, to open TCP port 2222 :&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd --permanent --add-port=2222/tcp&amp;lt;br/&amp;gt; To list the open ports, use the command :&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# firewall-cmd –-list-ports&amp;lt;br/&amp;gt; 2222/tcp&amp;lt;br/&amp;gt; 5. Start and stop firewalld service&amp;lt;br/&amp;gt; To start/stop/status firewalld service use the below commands:&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# systemctl start firewalld.service&amp;lt;br/&amp;gt; # systemctl stop firewalld.service&amp;lt;br/&amp;gt; To check the status of the firewalld service:&amp;lt;/div&amp;gt; &amp;lt;div style=&amp;quot;background:#eee;border:1px solid #ccc;padding:5px 10px;&amp;quot;&amp;gt;# systemctl status firewalld.service&amp;lt;br/&amp;gt; &amp;amp;nbsp;&amp;lt;/div&amp;gt; &lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&lt;br /&gt;
&amp;amp;nbsp;&lt;br /&gt;
&amp;lt;/div&amp;gt;&lt;/div&gt;</summary>
		<author><name>Kaspars</name></author>
	</entry>
</feed>