Friday 6 December 2019

How to Add a Port in Firewall Configuration on CentOS 7 (firewall-cmd)




Firewall is a network security tool that provide network level security based on a set of rules. It has controls on incoming and outgoing traffic.

This article describes How to Add a Port in Firewall Configuration on CentOS7 (firewall-cmd).

Follow the article Howto Install Firewalld on CentOS 7 if already not installed.

Step 1. Check the Service Status: Run the following command to check firewall running status:

[root@linuxcnf ~]# firewall-cmd --stat
running
[root@linuxcnf ~]#

Step 2. Adding Port: Run the following command to allow port in firewall:

[root@linuxcnf ~]# firewall-cmd --permanent --zone=public --add-port=80/tcp
success
[root@linuxcnf ~]#

Change the port and protocol (tcp/udp) as desire.

Step 3. Reloading the Service: Run the following command for soft reloading firewall service to reflect the changes:

[root@linuxcnf ~]# firewall-cmd --reload
success
[root@linuxcnf ~]#

Step 4. Validate the Configuration: Run the following command to verify the configuration:

[root@linuxcnf ~]# firewall-cmd --list-ports | grep 80
80/tcp
[root@linuxcnf ~]#

Done!!! Port 80 is successfully allowed from Linux Firewall.

No comments:

Post a Comment