In Linux systems, Firewalld is a firewall management tool for Red Hat Enterprise Linux, CentOS, and Fedora. It allows you to configure the firewall rules on your system. Furthermore, it can control incoming and outgoing network traffic via open ports.
Today, this guide explains possible ways to list the open ports in Firewalld. The content of this tutorial is mentioned-below:
- Prerequisite: Check the Firewalld Services
- List Open Ports in Firewalld
- List the Open Ports for a Specific Zone
- Detailed Information About the Open Ports
Let’s first check the Firewalld services.
Prerequisite: Check the Firewalld Services
To check the services of “Firewalld” (firewall management tool), the systemctl is used with the “sudo” command as below:
$ sudo systemctl status firewalld
The output confirms that “Firewalld” services are in “active(running)” state.
List Open Ports in Firewalld
The “Firewalld” assists an interface for managing firewall rules. To list the open ports in firewalld, you can use the “firewall-cmd” command with the “–list-ports” option. To do so, execute the below script:
$ sudo firewall-cmd --list-ports
The output displays the “443/tcp” and “80/tcp” ports that are currently open in firewalld. Here, “tcp” represents the protocol used by the “443” and “80” port numbers.
List the Open Ports for a Specific Zone
Users can use the “–zone” option to list the open ports for a specific zone (represents the trust level for network connections). For instance, the “public” zone is specified to display the available ports:
$ sudo firewall-cmd --zone=public --list-ports
The output displays a list of the open ports for the “public” zone.
Detailed Information About the Open Ports
If you want to see more detailed information about the ports that are open in firewalld, users can assist the “–list-all” option:
$ sudo firewall-cmd --list-all
The output shows the open ports “443/tcp” and “80/tcp” as well as other information about the firewall rules such as services “dhcpv6-client ssh”.
That is all about listing open ports in firewalld.
Conclusion
To list the open ports in firewalld, the “firewall-cmd” command is utilized with the “–list-ports” option. The “firewall-cmd” command manages the firewall rules on your system. Additionally, users can display the open ports by specifying the zone. This guide has explained all possible methods to list the available open ports in firewalld.