How to Open and Manage Ports with firewalld on AlmaLinux

In this video script, we will show you how to open and manage ports with firewalld on AlmaLinux.

Introduction (30 seconds)

Hello everyone. Welcome to my channel! Today, I will show you how to open and manage ports with firewalld in AlmaLinux.

So let’s get started!

Checking default zone (1 minute)

firewalld uses zones to define trust levels for different network interfaces. To see the active zone, type:

sudo firewall-cmd --get-active-zones

Most of the time, it’s set to public, which is a good default for a server.

We will prepare a detailed video about zones in the future but for now, just know that zones help you manage your firewall rules based on the network you’re connected to.

Listing Open Ports (1 minute)

To see which ports are currently open in the active zone, run:

sudo firewall-cmd --list-ports

You can also list allowed services:

sudo firewall-cmd --list-services

This will show you the services that are allowed through the firewall. The ports for these services are automatically opened.


Opening and Managing Ports (2 minutes)

Let’s say you want to open port 8080 for a web application.

Here’s how:

sudo firewall-cmd --zone=public --add-port=8080/tcp

But this is temporary — it will be reset after a reboot or reload.

To make it permanent, add --permanent like this:

sudo firewall-cmd --zone=public --add-port=8080/tcp --permanent

Then reload the firewall to apply the change:

sudo firewall-cmd --reload

Opening Services (1 minute)

Instead of specifying a port, you can also open a named service like HTTP or SSH.

Example:

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

This automatically opens port 80 for you.

To list all available services:

sudo firewall-cmd --get-services

Closing Ports and Services (1 minute)

To close a port, you can use the same command but with --remove-port:

sudo firewall-cmd --zone=public --remove-port=8080/tcp --permanent
sudo firewall-cmd --reload

To remove a service:

sudo firewall-cmd --zone=public --remove-service=http --permanent
sudo firewall-cmd --reload

Always reload after making permanent changes.


Conclusion (30 seconds)

If you found this tutorial helpful, please like and subscribe for more Linux administration videos. Drop any questions in the comments below!

Thanks for watching, and happy Linux administrating!

Optional Thumbnail Text Ideas

  • How to Open and Manage Ports with firewalld on AlmaLinux
  • Open Ports in AlmaLinux with firewalld