Centos7 open and view ports
- Install a firewall
yum install -y firewalld yum install -y firewall-config
Open / close ports
firewall-cmd --zone=public --add-port=5672/tcp --permanent # 开放5672端口 firewall-cmd --zone=public --remove-port=5672/tcp --permanent #关闭5672端口 firewall-cmd --reload # 配置立即生效
View all open firewall ports
firewall-cmd --zone=public --list-ports
If you want to turn off the firewall ports open too much, too much trouble, you can turn off the firewall, security self-assessment
systemctl stop firewalld.service
Check firewall status
firewall-cmd --state
- Check listening port
netstat -lnpt
PS: centos7 no default netstat command, net-tools tools need to be installed
yum install -y net-tools
- Check the port is occupied by what process
netstat -lnpt |grep 5672
- To view the details of the process
ps 6832
Abort the process
kill -9 6832