firewalld使用

巧了我就是萌 提交于 2019-12-21 11:57:05

1 安装firewalld

yum install firewalld firewall-config
systemctl start  firewalld # 启动
systemctl status firewalld # 或者 firewall-cmd --state 查看状态
systemctl disable firewalld # 停止
systemctl stop firewalld  # 禁用

# 关闭服务的方法
# 你也可以关闭目前还不熟悉的FirewallD防火墙,而使用iptables,命令如下:

systemctl stop firewalld
systemctl disable firewalld
yum install iptables-services
systemctl start iptables
systemctl enable iptables

2 使用firewalld

firewall-cmd --state        查看firewall的状态

systemctl status firewalld  查看firewall服务状态

# 查询端口是否开放
firewall-cmd --query-port=8080/tcp

# 开放80端口
firewall-cmd --permanent --add-port=80/tcp

# 移除端口
firewall-cmd --permanent --remove-port=8080/tcp

查看已经开放的所有端口
firewall-cmd --list-ports


#重启防火墙(修改配置后要重启防火墙)
firewall-cmd --reload

用nmap 192.168.4.10 -p 8080 查看端口是否打开。

3 关闭防火墙与selinux关闭

[root@localhost ~]# systemctl stop firewalld

[root@localhost ~]# systemctl disable firewalld

[root@localhost ~]# sed -i '/SELINUX/s/enforcing/disabled/' /etc/selinux/config

 

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!