This post will show you how to open a firewall port of a Linux Red Hat server using the command line.
In RHEL, the firewall is managed by the firewall-cmd command that control which port is open or blocked between the defined network zones. In most systems, you will probably have a single zone (public).
The firewall-cmd command is the client of the firewall daemon that handles the firewall.
Now that we know a bit about the firewall daemon, let us first check which zone is active on our systems by running the following command.
My output is shown below and with no surprise, I only have a public zone which I will take note of and use to open a port.
[root@web ~]# firewall-cmd --get-active-zones public interfaces: ens3
To open a port, I will run the following commmand.
firewall-cmd --zone=public --add-port=3100/tcp --permanent
After opening the port, we need to reload the daemon to apply the changes.
At this stage the change is completed and the port is open.
To read more about the firewall-cmd command run.