本文最后更新于:6 个月前
防火墙相关命令
查看防火墙状态
firewall-cmd --state
1 2 3
| [root@???????????? /] running [root@???????????? /]
|
开启防火墙
systemctl start firewalld.service
1 2 3 4
| [root@???????????? /] [root@???????????? /] running [root@???????????? /]
|
关闭防火墙
systemctl stop firewalld.service
1 2 3 4 5
| [root@???????????? /] [root@???????????? /] not running [root@???????????? /]
|
查看所有开放的端口
firewall-cmd --zone=public --list-ports
1 2 3
| [root@???????????? /] 80/tcp 443/tcp 3306/tcp 2222/tcp [root@???????????? /]
|
开放端口
firewall-cmd --zone=public --add-port=3001/tcp --permanent
1 2 3 4 5 6 7 8 9
| [root@???????????? /] success [root@???????????? /] 80/tcp 443/tcp 3306/tcp 2222/tcp [root@???????????? /] success [root@???????????? /] 80/tcp 443/tcp 3306/tcp 2222/tcp 3001/tcp [root@???????????? /]
|
关闭端口
firewall-cmd --zone=public --remove-port=3001/tcp --permanent
1 2 3 4 5
| [root@???????????? /] success [root@???????????? /] success
|
配置生效
firewall-cmd --reload
1 2 3
| [root@???????????? /] success
|