sammlinux sammlinux
  • Ubuntu
    UbuntuShow More
    How To Install and Use Docker CE on Ubuntu 22.04
    26 Min Read
    How To Install and Secure phpMyAdmin on Ubuntu 22.04
    5 Min Read
    How To Secure SSH with Fail2Ban on Ubuntu 22.04
    8 Min Read
    How To Install Uptime Kuma on Ubuntu 22.04
    17 Min Read
    How To Install Ubuntu Server 22.04 LTS with Screenshots
    14 Min Read
  • Rocky Linux
    Rocky LinuxShow More
    How To Install phpMyAdmin on Rocky Linux 9
    15 Min Read
    How To Secure SSH with Fail2Ban on Rocky Linux 9
    12 Min Read
    How To Install Rocky Linux 9.2 Server with Screenshots
    12 Min Read
    How To Set Up a Firewall Using FirewallD on Rocky Linux 9
    8 Min Read
    How To Install Nginx on Rocky Linux 9: A Comprehensive Guide
    10 Min Read
  • Debian
    DebianShow More
    How To Secure SSH with Fail2Ban on Debian 11
    8 Min Read
    How To Install Debian 11 (Bullseye) Server with Pictures
    12 Min Read
    How To Install and Setup Node.js on Debian 11
    6 Min Read
    How To Install PHP 8.2 on Debian 11
    12 Min Read
    How To Install Nginx on Debian 11: A Comprehensive Guide
    9 Min Read
  • Linux
    LinuxShow More
    Best Practices Linux Server Security for System Administrator
    8 Min Read
    A Simple Guide: How To Manage Groups on Linux
    5 Min Read
    How To Manage Log Files Using Logrotate In Linux
    7 Min Read
    The Easy Ways to Check File Size in Linux
    7 Min Read
    How To Backup Files From Remote Linux VPS Using Rsync Script
    12 Min Read
  • CentOS
    CentOSShow More
    How To Secure SSH with Fail2Ban on CentOS 7
    9 Min Read
    How To Install PHP 8.2 on CentOS 7 / RHEL 7
    18 Min Read
    How To Install Apache Web Server on CentOS 7
    11 Min Read
    How To Set Up a Firewall Using FirewallD on CentOS 7
    5 Min Read
    Initial Setup CentOS 7 Server: Secure and Efficient
    9 Min Read
  • DevOps
    DevOpsShow More
    How To Create AWS CloudFront: A Step-by-Step Guide
    10 Min Read
Reading: How To Set Up a Firewall Using FirewallD on Rocky Linux 9
Share
Font ResizerAa
Linux for BeginnersLinux for Beginners
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Search
  • Ubuntu
  • Rocky Linux
  • Debian
  • Linux
  • CentOS
  • DevOps
Follow US
Copyright © 2014-2023 Ruby Theme Ltd. All Rights Reserved.

How To Set Up a Firewall Using FirewallD on Rocky Linux 9

Samuel Siahaan
By Samuel Siahaan
Last updated: September 11, 2023
SHARE

In today’s digital landscape, securing your server is of utmost importance. Basically one of the fundamental components of server security is setting up a firewall. In this article, specifically we’ll walk you through the step-by-step process of how to set up a firewall using firewalld on Rocky Linux 9. On Rocky Linux 9, you can easily achieve this using the “firewalld” utility.

Contents
Table of ContentsWhat is firewalld?Step 1: Installation FirewallD on Rocky Linux 9Step 2: Starting FirewallDStep 3: Basic Configuration FirewallDStep 4: Adding RulesStep 5: Enabling SSH Access on Rocky Linux 9Step 6: Checking RulesStep 7: Custom RulesStep 8: Port ForwardingStep 9: Removing RulesStep 10: Managing Services FirewallDStep 11: Troubleshooting FirewallD on Rocky Linux 9Conclusion

Table of Contents

  • What is firewalld?
    • Step 1: Installation FirewallD on Rocky Linux 9
    • Step 2: Starting FirewallD
    • Step 3: Basic Configuration FirewallD
    • Step 4: Adding Rules
    • Step 5: Enabling SSH Access on Rocky Linux 9
    • Step 6: Checking Rules
    • Step 7: Custom Rules
    • Step 8: Port Forwarding
    • Step 9: Removing Rules
    • Step 10: Managing Services FirewallD
    • Step 11: Troubleshooting FirewallD on Rocky Linux 9
  • Conclusion

What is firewalld?

Before diving into the setup process, let’s briefly discuss what firewalld is and why it’s essential for server security. Firewalld is a dynamic firewall management tool that simplifies the process of configuring and managing firewalls on Linux systems. Generally it provides a user-friendly interface and allows you to define rules and zones to control incoming and outgoing network traffic.

Step 1: Installation FirewallD on Rocky Linux 9

The first step in setting up a firewall with firewalld on Rocky Linux 9 is to ensure that the software is installed on your system. You can do this by running the following command in your terminal:

Bash
$ sudo dnf install firewalld

Step 2: Starting FirewallD

Once firewalld is installed on your Rocky Linux 9, you need to start the service and enable it to start at boot. Execute the following commands:

- Advertisement -
Bash
$ sudo systemctl start firewalld
$ sudo systemctl enable firewalld
$ sudo systemctl status firewalld
Set Up Firewalld on Rocky Linux 9
Status Firewalld on Rocky Linux 9

Step 3: Basic Configuration FirewallD

Now that firewalld is up and running, let’s configure some basic firewall settings. The primary unit of configuration in firewalld is the “zone.” Zones determine how traffic is filtered and what level of trust is assigned to a network connection. Rocky Linux 9 includes several predefined zones, such as “public,” “home,” and “work.” You can view the available zones by running following command:

Bash
$ sudo firewall-cmd --get-zones

To assign a zone to your network interface (e.g., “public”), use the following command:

Bash
$ sudo firewall-cmd --zone=public --change-interface=eth0

Step 4: Adding Rules

With the zone configured, thus you can now define rules for controlling traffic. Let’s say you want to allow incoming traffic on port 80 (HTTP). You can add the rule like this, use the following command:

Bash
$ sudo firewall-cmd --zone=public --add-service=http --permanent

Don’t forget to reload the firewall to apply the changes, use the following command:

Bash
$ sudo firewall-cmd --reload

Step 5: Enabling SSH Access on Rocky Linux 9

If you’re remotely managing your Rocky Linux 9 server, you’ll want to enable SSH access. To do this, use the following command:

- Advertisement -
Bash
$ sudo firewall-cmd --zone=public --add-service=ssh --permanent

Afterwards remember to reload the firewall:

Bash
$ sudo firewall-cmd --reload

Step 6: Checking Rules

You can verify the rules that have been added to your firewall by running:

Bash
$ sudo firewall-cmd --list-all

This command will display a list of active zones, services, and ports, allowing you to ensure that your firewall is configured as intended.

- Advertisement -

Now that we’ve covered the basic setup of firewalld on Rocky Linux 9, let’s explore some advanced configurations to enhance your server’s security.

Step 7: Custom Rules

Firewalld allows you to create custom rules tailored to your specific requirements. For example, if you want to block a specific IP address, you can use the following command:

Bash
$ sudo firewall-cmd --zone=public --add-rich-rule='rule family="ipv4" source address="x.x.x.x" reject'

Replace “x.x.x.x” with the actual IP address you want to block.

Step 8: Port Forwarding

If you’re hosting services on your server, you may need to set up port forwarding. This can be achieved with firewalld as well. To forward incoming traffic from one port to another, use the following syntax:

Bash
$ sudo firewall-cmd --zone=public --add-forward-port=port=8080:proto=tcp:toport=80

This command forwards incoming TCP traffic from port 8080 to port 80.

Step 9: Removing Rules

To remove a rule, use the “–remove” flag followed by the rule specification. For example, to remove the HTTP rule, execute:

Bash
$ sudo firewall-cmd --zone=public --remove-service=http --permanent

Remember to reload the firewall after making changes.

In the final section of this guide, we’ll cover some essential maintenance tasks for your firewalld configuration.

Step 10: Managing Services FirewallD

You can enable or disable services in specific zones with ease. To disable a service, use the following command::

Bash
$ sudo firewall-cmd --zone=public --remove-service=service-name --permanent

And to enable a service:

Bash
$ sudo firewall-cmd --zone=public --add-service=service-name --permanent

Don’t forget to reload the firewall after any changes.

Step 11: Troubleshooting FirewallD on Rocky Linux 9

If you encounter any issues with your firewall configuration, firewalld on Rocky Linux 9 provides helpful logging to diagnose problems. Check the logs with the following command::

Bash
$ sudo journalctl -u firewalld

This command will display firewall-related log entries, aiding you in identifying and resolving issues.

Conclusion

In this comprehensive guide, we’ve walked you through the process of setting up a firewall using firewalld on Rocky Linux 9. By following these steps, you’ve taken a crucial step in securing your server and protecting it from unauthorized access and potential threats. First thing to remember regularly review and update your firewall rules to adapt to changing security needs. With firewalld on Rocky Linux 9, you have a powerful tool at your disposal to maintain a robust and secure server environment. Stay safe, and happy server management!

Also Read Our Other Guides :

  • How To Set Up a Firewall Using FirewallD on CentOS 7
  • How To Set Up a Firewall with UFW on Debian 11
  • How To Set Up a Firewall with UFW on Ubuntu 22.04
  • Initial Setup Debian 11 Server: Secure and Efficient
  • Initial Setup Ubuntu Server 22.04: Secure and Efficient
  • Initial Setup Rocky Linux 9 Server: Secure and Efficient
  • How To Install Rocky Linux 9.2 Server with Screenshots

Finally, now you have learned how to set up a firewall using FirewallD on Rocky Linux 9.

TAGGED:FirewallFirewallDRocky LinuxSecurityServer Guide

Sign Up For Daily Newsletter

Be keep up! Get the latest breaking news delivered straight to your inbox.
[mc4wp_form]
By signing up, you agree to our Terms of Use and acknowledge the data practices in our Privacy Policy. You may unsubscribe at any time.
Share This Article
Facebook Copy Link Print
Previous Article How To Set Up a Firewall Using FirewallD on CentOS 7
Next Article How To Install PHP 8.2 on Debian 11
Leave a Comment

Leave a Reply Cancel reply

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

How To Install and Secure phpMyAdmin on Ubuntu 22.04
Ubuntu
Install and Configure Docker Swarm Mode on Centos 7
CentOS
How To Install and Config Thumbor on Debian 10
Debian
How To Install MariaDB 10.6 on Debian 11 Server
Debian
How To Install MongoDB 6.0 on Debian 10 & 11
Debian

You Might Also Like

Debian

How To Install Debian 12 (Bookworm) Server with Screenshots

13 Min Read
Rocky Linux

How To Install a MinIO Object Storage Server on Rocky Linux (Part 2)

14 Min Read
Rocky Linux

How To Build NGINX from Source (Compile) on Rocky Linux 9

14 Min Read
Rocky Linux

How To Install Rocky Linux 9.2 Server with Screenshots

12 Min Read
Rocky Linux

How To Secure SSH with Fail2Ban on Rocky Linux 9

12 Min Read
Debian

Initial Setup Debian 11 Server: Secure and Efficient

17 Min Read
Rocky Linux

How To Install Node.js on Rocky Linux 9 With 3 Different Ways

17 Min Read
Rocky Linux

How To Install phpMyAdmin on Rocky Linux 9

15 Min Read
Show More

Always Stay Up to Date

Subscribe to our newsletter to get our newest articles instantly!

sammlinux sammlinux

Providing beginner-friendly Linux tutorials and open-source guides to simplify your digital infrastructure.

www.sammlinux.com © 2026 | All Rights Reserved

Join Us!
Subscribe to our newsletter and never miss our latest news, podcasts etc.

Subscribe to our newsletter to get our newest articles instantly!

Zero spam, Unsubscribe at any time.
Welcome Back!

Sign in to your account

Username or Email Address
Password

Lost your password?