CentOS7默认使用firewall
-
查看防火墙是否开启:systemctl status firewalld
-
开启防火墙:systemctl start firewalld.service
如果出现Failed to start firewalld.service: Unit is masked的错误,说明firewalld服务被锁定了
可执行:systemctl unmask firewalld 解除锁定 -
查看防火墙监听的端口号:
firewall-cmd --list-ports -
防火墙开启80端口访问:
firewall-cmd --zone=public --add-port=80/tcp --permanent -
重启防火墙:firewall-cmd --reload
防火墙相关命令:
- 开启开机启动:systemctl enable firewalld.service
- 关闭开机自启动:systemctl disable firewalld.service
- 查看防火墙状态:firewall-cmd --state
- 停止firewall:systemctl stop firewalld
- 禁用firewall:systemctl mask firewalld
评论区