Tuesday, 24 January 2023

How to Add a Service 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 Service 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-services
cockpit dhcpv6-client ssh
[root@linuxcnf ~]#
 
Step 2. Adding Service: Run the following command to allow a service in firewall:
 
[root@linuxcnf ~]# firewall-cmd --permanent --zone=public --add-service=http
success
[root@linuxcnf ~]#
 
Change the service name as per your requirements.
 
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 if the service is allowed or not:
 
[root@linuxcnf ~]# firewall-cmd --list-services
cockpit dhcpv6-client http ssh
[root@linuxcnf ~]#
 
Done!!! Now the service http is successfully allowed from Linux Firewall on CentOS 8.

No comments:

Post a Comment