It is important to note that the firewall is managed by iptables in CentOS 6 and the firewall is managed by FIREWALLD in CentOS 7.
1. In CentOS 7
Use the following command
Firewall-cmd [--zone=<zone>]--add-port=<port>[-<port>]/<protocol> [--timeout=<seconds ;]
As an example,
Firewall-cmd--zone=public--add-port=8080/tcp--permanent
Explain:
--zone Scope
--ADD-PROT=8080/TCP Port/Communication protocol
--permanent is permanently active and will not expire if this parameter is not restarted
Executing the command prompt success indicates that the add succeeds, at this point if the query will find that port 8080 is not released because the firewall needs to be restarted
2. In CentOS 6:
If you are accustomed to iptables, you can also install Iptables-service in CentOS 7
Yum Install iptables-Services# set boot systemctl enable iptables
Also take open 8080 port as an example
Execute vim /etc/sysconfig/iptables command
Add in File
-A input-p tcp-m state–state new-m tcp–dport 8080-j ACCEPT
Restart Iptables When you are finished modifying
Service Iptables Restart
Execute iptables-l command to view firewall rules
Linux Open Ports