Centos open port and view port and firewall configuration commands

Check if a port in the firewall is open

firewall-cmd --query-port=8080/tcp

Open firewall port 8080

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

After opening the port, you need to execute firewall-cmd --reload to make it take effect

reload firewall rules

firewall-cmd --reload

Close firewall ports

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

View firewall status

systemctl status firewalld 

start firewall

systemctl start firewalld

turn off firewall

systemctl stop firewalld

Set boot to enable firewall

systemctl enable firewalld.service

Set boot to disable firewall

systemctl disable firewalld.service

View list of open ports
firewall-cmd --zone=public --list-ports

View the port being listened on (Listen)
netstat -lntp

Check which process the port is occupied by
netstat -lnp|grep 8080

或者使用lsof查看端口占用

lsof -i:8080

Guess you like

Origin blog.csdn.net/weixin_42599091/article/details/131431521