Centos7 常用防火墙操作命令

最后编辑时间: 2023-02-01
ystemctl start  firewalld # 启动systemctl status firewalld # 或者 firewall-cmd --state 查看状态systemctl disable firewalld # 停止systemctl stop firewalld  # 禁用

Bash

允许 SSH 服务通过

firewall-cmd --enable service=ssh

Bash

禁止 SSH 服务通过

firewall-cmd --disable service=ssh

Bash

打开 TCP 的 8080 端口

firewall-cmd --enable ports=8080/tcp

Bash

临时允许 Samba 服务通过 600 秒

firewall-cmd --enable service=samba --timeout=600

Bash

查看防火墙锁开放的端口

firewall-cmd --zone=public --list-ports

显示当前服务

firewall-cmd --list-services

Bash

添加 HTTP 服务到内部区域(internal)

firewall-cmd --permanent --zone=internal --add-service=http
firewall-cmd --reload     # 在不改变状态的条件下重新加载防火墙

Bash

打开 443/TCP 端口

firewall-cmd --add-port=443/tcp

Bash

永久打开 3690/TCP 端口

firewall-cmd --zone=public --add-port=3690/tcp --permanent

Bash

重载防火墙

firewall-cmd --reload

 

请在下方留下您的评论.加入TG吹水群