Configure Firewalld on centos 8

Configure Firewalld on centos 8

In this tutorial, we want to explain What is Firewalld and how to Configure Firewalld on centos 8 and other versions.

We will first look at the Firewalld to learn more about its benefits and features, and then look at its features and finally setup Firewalld and configure it.


what is Firewalld

According to the reference site, Firewalld provides a dynamically managed firewall with support for network/firewall zones that define the trust level of network connections or interfaces. It has support for IPv4, IPv6 firewall settings, Ethernet bridges, and IP sets. There is a separation of runtime and permanent configuration options. It also provides an interface for services or applications to add firewall rules directly.


Firewalld benefits

Changes can be done immediately in the runtime environment. No restart of the service or daemon is needed.

With the Firewalld D-Bus interface it is simple for services, applications, and also users to adapt firewall settings. The interface is complete and is used for the firewall configuration tools firewall-cmd, firewall-config, and firewall-applet.

Recommended Article: Tutorial Configure SSH Key-Based Authentication on a Linux Server

More Firewalld features

  • Complete D-Bus API
  • IPv4, IPv6, bridge and ipset support
  • IPv4 and IPv6 NAT support
  • Firewall zones
  • A predefined list of zones, services and ICMP types
  • Simple service, port, protocol, source port, masquerading, port forwarding, ICMP filter, rich rule, interface and source address handling in zones
  • Simple service definition with ports, protocols, source ports, modules (Netfilter helpers) and destination address handling
  • Integration with Puppet
  • Command-line clients for online and offline configuration
  • Graphical configuration tool using gtk3
  • Rich Language for more flexible and complex rules in zones
  • Timed firewall rules in zones
  • Simple log of denied packets
  • Direct interface
  • Lockdown: Whitelisting of applications that may modify the firewall
  • Automatic loading of Linux kernel modules
  • and etc…

Great. Now you know about Firewalld. we will now set up and Configure Firewalld on centos 8.

configure Firewalld on centos 8 

set up Firewalld on centos

The first point you know on set up Firewalld on centos is By default, Firewalld is installed on centos 7 and above, but if you want to install that on other Linux distribution or Firewalld didn’t preinstall on your centos server. please following this command to install it.

yum install Firewalld -y

For more information: if you want to install Firewalld on your Ubuntu or Debian distribution, you must be used APT command instead of YUM.


Working with Firewalld service

For start and stop Firewalld service on your centos, please following these commands.

systemctl start Firewalld  systemctl stop Firewalld

And for restart the Firewalld service, you can use this command.

systemctl restart Firewalld

After you learn about the start, stop, and restart Firewalld service, you have to know, how to enable and disable the Firewalld service on startup.

Enable or Disable Firewalld service on startup

For enabling Firewalld service on centos, following command.

systemctl enable Firewalld

Or if you want to disable Firewalld service on startup, following this command.

systemctl disable Firewalld


Check and verify service

Sometimes, you need to check the Firewalld service status. for check and verify the Firewalld, you can use the following command.

firewall-cmd --state  systemctl status Firewalld

both commands work well and you can understand and verify Firewalld status.


Getting Familiar with the Current Firewall Rules

OK, now you know about Firewalld service, after this on Configure Firewalld on centos 8 article we want to tell you some command for managing and check rules and situation on Firewalld.

Exploring the Defaults zone

firewall-cmd --get-default-zone

After executing the command you will see output like below

output  public  if you want to print all enable rule on your Firewalld service, use following command  firewall-cmd --list-all  after Enter the command, you will see output like this:  output  public (default, active)    target: default    icmp-block-inversion: no    interfaces: ens192    sources:    services: ssh dhcpv6-client    ports:    protocols:    masquerade: no    forward-ports:    source-ports:    icmp-blocks:    rich rules:

Changing the Zone of an Interface

For instance, we can transition our ens192 interface to the “private” zone by typing this:

firewall-cmd --zone=private --change-interface=ens192


Adjusting the Default Zone

If all of your interfaces can best be handled by a single zone, it’s probably easier to just select the best default zone and then use that for your configuration.

For example, in the following command, we set the public zone as a default zone.

firewall-cmd --set-default-zone=public


Setting Rules for your Applications

Adding a Service to Zones

The easiest method is to add the services or ports you need to the zones you are using.

firewall-cmd --zone=public --add-service=http

In this command, we added HTTP service to our zones and Port 80 and 433 available now.

for more information about all service, you can add on Firewalld, use the following command to show all service available.

firewall-cmd --get-services

After adding the service or service you want, you have to type the following command for reloading Firewalld


Reload Firewalld on centos 8

firewall-cmd --reload


Check all service enable on Firewalld

Now you can check all services available on Firewalld with the following command

firewall-cmd --zone=public --list-services

OK, now after the check services and … and make sure the Rule you add to Firewalld worked. you can add a permanent rule for using every time. because for now your rule will be deleted after restart Firewalld service or restart your CentOS. So you have to use –permanent switch for changing permanent rules.

firewall-cmd --zone=public --permanent --add-service=http

After entering the command and reload the firewall, the service will add permanent on your Firewalld.

Recommended Article: Configure Firewalld on centos 8

Open the port on Firewalld

For opening your favorite port on your Firewalld service, you can act like service but some difference.

For example, if you want to add port 2245 on your Firewalld you use the following command.

firewall-cmd --zone=public --add-port=2245/tcp

But if you want to add the port permanently, you have to use the –permanent like this.

firewall-cmd --zone=public --permanent --add-port=2245/tcp

If you need to open the range of ports, you can use a command like this.

firewall-cmd --zone=public --permanent --add-port=4990-4999/udp



In this article “configure Firewalld on centos 8 “, we try to talk about Firewalld on centos as a simple way and all command you have to know, but Firewalld has a lot of command and features and you can use rich language, create your own zone, create your desire service and port and etc…

We try to publish another article for advanced settings on Firewalld and explain other advanced things later.

Thanks for your attention, you can comment below, and ask your question or anything. Also, you can ask all your questions about VPS and Linux on the Ask page on Eldernode.

How useful was this post?

Click on a star to rate it!

Average rating 1 / 5. Vote count: 1

No votes so far! Be the first to rate this post.

We Are Waiting for your valuable comments and you can be sure that it will be answered in the shortest possible time.

Leave a Reply

Your email address will not be published. Required fields are marked *

We are by your side every step of the way

Think about developing your online business; We will protect it compassionately

We are by your side every step of the way


7 days a week, 24 hours a day