Linux:端口:修订间差异
来自康健生活
创建页面,内容为“== 端口(Centos7) == 开放端口 <syntaxhighlight lang="bash"> firewall-cmd --zone=public --add-port=5672/tcp --permanent # 开放5672端口 firewall-cmd --…” |
无编辑摘要 |
||
| 第2行: | 第2行: | ||
开放端口 | 开放端口 | ||
<syntaxhighlight lang="bash"> | {{shc|<syntaxhighlight lang="bash"> | ||
firewall-cmd --zone=public --add-port=5672/tcp --permanent # 开放5672端口 | firewall-cmd --zone=public --add-port=5672/tcp --permanent # 开放5672端口 | ||
firewall-cmd --zone=public --remove-port=5672/tcp --permanent #关闭5672端口</syntaxhighlight> | firewall-cmd --zone=public --remove-port=5672/tcp --permanent #关闭5672端口 | ||
firewall-cmd --reload # 配置立即生效</syntaxhighlight>}} | |||
查看防火墙所有开放的端口 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
firewall-cmd --zone=public --list-ports</syntaxhighlight>}} | |||
关闭防火墙,如果要开放的端口太多,嫌麻烦,可以关闭防火墙,安全性自行评估 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
systemctl stop firewalld.service</syntaxhighlight>}} | |||
查看防火墙状态 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
firewall-cmd --state</syntaxhighlight>}} | |||
查看监听的端口 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
netstat -lnpt</syntaxhighlight>}} | |||
检查端口被哪个进程占用 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
netstat -lnpt |grep 5672</syntaxhighlight>}} | |||
查看进程的详细信息 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
ps 6832</syntaxhighlight>}} | |||
中止进程 | |||
{{shc|<syntaxhighlight lang="bash"> | |||
kill -9 6832</syntaxhighlight>}} | |||
kill -9 6832 | |||