Manage Firewalld in Fedora 39 From Terminal

In this guide, we want to show you how to Manage and Configure Firewalld in Fedora 39 from the Terminal Command Line. Firewalld is the default Firewall manager for Fedora Linux. You can increase your Fedora Linux security by managing Firewalld settings. You can proceed to the following steps to install and start using Firewalld in Fedora Linux.

Learn To Manage Firewalld in Fedora 39 From Terminal

To start your Firewalld configuration, you must have access to your server as a root or non-root user with sudo privileges. Then, proceed to the following steps to complete this guide.

Step 1 – Set up Firewalld in Fedora Linux

First, run the system update with the following command:

sudo dnf update -y

Then, you can use the following command to install firewalld in your Fedora 39:

sudo dnf install firewalld -y

When your installation is completed, proceed to the following steps to start and enable your firewalld service.

Step 2 – Start and Enable Firewalld in Fedora Linux

At this point, you can start your Firewalld service in Fedora 39 by using the command below:

sudo systemctl start firewalld

Then, you can enable your Firewalld service to start on boot:

sudo systemctl enable firewalld

Step 3 – Check Firewalld Status in Fedora Linux

Now you can verify your service is active and running on your server with the following command:

sudo systemctl status firewalld

In your output, you should see:

Check Firewalld Status in Fedora Linux

Step 4 – General Firewalld Syntax Command

The general syntax command of Firewalld is like the following command:

sudo firewall-cmd [options] command

To get Firewalld Options and Commands, you can run the command below:

sudo firewall-cmd --help

In your output, you will see:

Firewalld Options and Commands

Now follow the steps below to get some examples of using Firewalld.

Step 5 – Configure Firewalld Zone Settings in Fedora 39

The first concept of Firewalld is Zones. Zones are predefined sets of rules. Network interfaces and sources can be assigned to a zone. At this point, you can list Firewalld’s available zones, default zones, and all zones. To do this, you can use the following commands:

List Available Firewalld Zones in Fedora:

sudo firewall-cmd --get-zones

Example Output:

List Available Firewalld Zones in Fedora

List Default Firewalld Zones in Fedora:

sudo firewall-cmd --get-default-zone

Example Output:

FedoraWorkstation

List All Firewalld Zones:

sudo firewall-cmd --list-all-zones

Example Output:

List All Firewalld Zones

So you can easily set your Firewalld zone by using the command below:

sudo firewall-cmd --set-default-zone=your-desired-zone

For example, to set the public zone as your default zone, you can run the command below:

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

Step 6 – Configure Firewalld Services Settings in Fedora 39

Another concept of Firewalld is services. Services use one or more ports or addresses for network communication. Firewalls filter communication based on ports. To allow network traffic for a service, its ports must be open.

To list all available Firewalld services, you can run the command below:

sudo firewall-cmd --get-services

Example output:

list all available Firewalld services in fedora 39

To add a service to your Firewalld rules, you can use the following command:

sudo firewall-cmd --add-service=your-desired-service

For example, to add the DHCP service, you can run the command below:

sudo firewall-cmd --add-service=dhcp

Then, you can make your service permanent by using the following command:

sudo firewall-cmd --add-service=dhcp --permanent

Also, you can define rules for the network source range and open any one of the ports. For example, if you would like to open a network range say ‘192.168.0.0/24‘ and port ‘1935‘ use the following commands:

# sudo firewall-cmd --permanent --add-source=192.168.0.0/24
# sudo firewall-cmd --permanent --add-port=1935/tcp

Important Note: Remember to reload the firewall after any Firewalld configuration:

sudo firewall-cmd --reload

To remove a service from firewalld, you can simply use the command below:

sudo firewall-cmd --zone=public --remove-service=your-desired-service

For more information, you can visit the man page:

man firewalld

Conclusion

At this point, you have learned to Manage and Configure Firewalld in Fedora 39 from the Terminal Command Line. You have learned basic Firewalld zones and services and how to manage them. Hope you enjoy it. Also, you may like to read the following guides:

Steps To Install Fedora Linux 39 on VMware Workstation

Configure SELinux in Fedora Linux Command Line

Newsletter Updates

Enter your email address below and subscribe to our newsletter

Stay informed and not overwhelmed, subscribe now!