Centos Open Ports Centos Use Firewall Open Ports Centos Common Commands CentOS 7 Firewall Tutorial: How to Use Common Commands to Open Ports

On CentOS 7, we can use the firewall tool firewalld to manage ports. The following are some commonly used firewalld commands for reference:

1. View the status of the firewall

systemctl status firewalld

2. Start the firewall

systemctl start firewalld

3. Stop the firewall

systemctl stop firewalld

4. Start the firewall automatically

systemctl enable firewalld

5. Disable the boot-up self-starting firewall

systemctl disable firewalld

6. Open port

firewall-cmd --zone=public --add-port=端口号/tcp --permanent

Among them, --zone=publicmodifying the public area is specified, --add-port=端口号/tcpwhich means adding a certain TCP port, --permanentwhich means it will take effect permanently.

For example, to open 8080a port, the command is as follows:

firewall-cmd --zone=public --add-port=8080/tcp --permanent

7. Close the port

firewall-cmd --zone=public --remove-port=端口号/tcp --permanent

For example, to close 8080the port, the command is as follows:

firewall-cmd --zone=public --remove-port=8080/tcp --permanent

8. Restart the firewall

firewall-cmd --reload

Guess you like

Origin blog.csdn.net/qq_40739917/article/details/130891755