Open a Firewall Port On Linux CentOS 7

This post will show you how to open a firewall port of a Linux CentOS server using the command line.

Firewall-Cmd

In CentOS, 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.

Check Zone

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.

firewall-cmd --get-active-zones

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

Open Port

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.

firewall-cmd --reload

At this stage the change is completed and the port is open.

To read more about the firewall-cmd command run.

man firewall-cmd

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.