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=public
modifying the public area is specified, --add-port=端口号/tcp
which means adding a certain TCP port, --permanent
which means it will take effect permanently.
For example, to open 8080
a 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 8080
the port, the command is as follows:
firewall-cmd --zone=public --remove-port=8080/tcp --permanent
8. Restart the firewall
firewall-cmd --reload