1. 开放端口
| firewall-cmd --zone=public --add-port=5672/tcp --permanent
firewall-cmd --zone=public --remove-port=5672/tcp --permanent
firewall-cmd --reload
|
2. 查看防火墙所有开放的端口
| firewall-cmd --zone=public --list-ports
|
3. 关闭防火墙
如果要开放的端口太多,嫌麻烦,可以关闭防火墙,安全性自行评估
| systemctl stop firewalld.service
|
4. 查看防火墙状态
5. 查看监听的端口
| [logan@localhost ~]$ sudo netstat -lnpt Active Internet connections (only servers) Proto Recv-Q Send-Q Local Address Foreign Address State PID/Program name tcp 0 0 0.0.0.0:111 0.0.0.0:* LISTEN 1/systemd tcp 0 0 0.0.0.0:80 0.0.0.0:* LISTEN 13883/nginx: master tcp 0 0 192.168.122.1:53 0.0.0.0:* LISTEN 1594/dnsmasq tcp 0 0 0.0.0.0:22 0.0.0.0:* LISTEN 1127/sshd tcp 0 0 127.0.0.1:631 0.0.0.0:* LISTEN 1128/cupsd tcp6 0 0 :::111 :::* LISTEN 1/systemd tcp6 0 0 :::22 :::* LISTEN 1127/sshd tcp6 0 0 ::1:631 :::* LISTEN 1128/cupsd
|
PS:centos7 默认没有 netstat 命令,需要安装 net-tools 工具,yum install -y net-tools
6. 查看进程的详细信息
| [logan@localhost ~]$ ps 13883 PID TTY STAT TIME COMMAND 13883 ? Ss 0:00 nginx: master process nginx
|
7. 中止进程
本文参考:https://www.cnblogs.com/heqiuyong/p/10460150.html