How To Add Ports In The Firewall Rules On CentOS 7
How to add ports, we can allow and check open ports in firewall Linux but you can also block the port. Firewall defines the rules for your server where you allow or block the ports using the rule defined in the file and filters the traffic.
This is most important to configure and control the traffic or access to the server.
Check Out: Useful Commands Of Firewall
Step 1: you can check port allowed in the firewall
As you can see there is only one port added in my machine which is for PostgreSQL.
Let’s suppose, we have to add port 80 in firewall using firewalld command in RedHat 7 version and you can use iptables in RedHat version 6. you can add port 80 and protocol TCP that's for the webserver. firewall-cmd --permanent --zone=public --add-port=80/tcp In a similar way, you can also add the service instead of the port number. firewall-cmd --permanent --zone=public --add-service=http/tcp
We have added port 80 of httpd in firewall it will work until you do not reload the firewall.
Check Out: Enable/Disable Firewall
Step 2: Check port added in firewall firewall-cmd --list-ports Step 3: Now restart the service of the firewall. systemctl restart firewalld