https://jingyan.baidu.com/article/cdddd41cb3bf6c53cb00e1ac.html
When CentOS7 installs software packages or class libraries, connection failures, data calls or remote failures are often caused by firewall interception and port opening. Therefore, when using CentOS, you need to learn how to operate firewalls and ports. . .
method/step
-
CentOS7 uses the systemctl command to manage a single service of the system. In CentOS7, the opening, closing and status query of the firewalld (firewall) service also uses this command. The operations are as follows:
-
Start the firewall: systemctl start firewalld
-
Check firewall status: systemctl status firewalld
-
Turn off the firewall: systemctl stop firewalld
-
Enable firewall service at boot: systemctl enable firewalld Disable firewall service at boot: systemctl disable firewalld
-
Query whether the firewall service is started at boot: systemctl is-enabled firewalld
-
Query the list of started services: systemctl list-unit-files|grep enabled
-
Query the list of services that failed to start: systemctl --failed
-
When installing software or a library, in addition to directly opening and closing the firewall, you can also directly open the connection by operating the port; add a port: firewall-cmd --zone=public --add-port=80/tcp --permanent
-
Update firewall rules: firewall-cmd --reload
View port status: firewall-cmd --zone=public --query-port=80/tcp
-
Remove open ports: firewall-cmd --zone=public --remove-port=80/tcp --permanent
-
Every time you update the firewall rules, you need to re-update: firewall-cmd --reload, update status;
-
In addition, after updating the firewall settings, you can also view all open ports: firewall-cmd --zone=public --list-ports