Tuesday 24 January 2023

How to Add a Port in Firewall Configuration on CentOS 8 (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 CentOS 8 (firewall-cmd).
 
[root@linuxcnf ~]# cat /etc/redhat-release
CentOS Linux release 8.5.2111
[root@linuxcnf ~]#
 
Step 1. Check the Service Status: Run the following command to check firewall running status:
 
[root@linuxcnf ~]# firewall-cmd --stat
running
[root@linuxcnf ~]#
 
[root@linuxcnf ~]# firewall-cmd --list-ports
 
[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
80/tcp
[root@linuxcnf ~]#
 
Done!!! Port 80 is successfully allowed from Linux Firewall on CentOS 8.

No comments:

Post a Comment