• 学派吧-由新云网络独家赞助-https://www.sq9.cn。

CentOS7使用FirewallD管理防火墙教程及使用方法

unix admin 6年前 (2018-10-11) 2014次浏览 已收录 0个评论 扫描二维码

FirewallD 提供了支持网络/防火墙区域(zone)定义网络链接以及接口安全等级的动态防火墙管理工具,它拥有运行时配置和永久配置选项。CentOS 7中防火墙是一个非常的强大的功能,本文主要介绍FirewallD常用管理命令。

安装firewalld
Centos7自带FirewallD防火墙工具,如果你的系统是最小化安装的,可能就需要自己动手安装firewalld服务。

yum install firewalld firewall-config

运行和停止firewalld

systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。我们使用systemctl命令来控制firewalld。

启动防火墙:

systemctl start firewalld.service

关闭防火墙:

systemctl stop firewalld.service

重启防火墙:

systemctl restart firewalld.service

开机时启动防火墙:

systemctl enable firewalld.service

开机时禁用防火墙:

systemctl disable firewalld.service

查看防火墙运行状态:

systemctl status firewalld

配置firewalld-cmd管理防火墙端口
我们使用firewalld的字符界面管理工具firewall-cmd很方便就可以管理firewalld。

显示防火墙状态:

firewall-cmd --state

显示防火墙状态:

firewall-cmd --state

添加80端口,允许访问80端口,并永久生效:

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

添加服务,允许https访问,并永久生效:

firewall-cmd --zone=public --add-service=https --permanent

移除80端口:

firewall-cmd --zone=public --remove-port=80/tcp --permanent

重新载入使配置生效:

firewall-cmd --reload

查看开放的端口:

firewall-cmd --list-ports

当然,你也可以到/etc/firewalld/zones/目录下直接修改xml配置文件。
习惯用centos7以前版本的伙伴都喜欢用iptable来管理防火墙,设置在使用CentOS7后还把系统自带的firewalld服务弃用,转而用老版本的iptable,可我觉得firewalld很好用啊,简单又实在,好东西为什么不用呢。

欢迎大家投稿到我们学派吧


学派吧 , 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权
转载请注明原文链接:CentOS7使用FirewallD管理防火墙教程及使用方法
喜欢 (0)
[pay@sq9.cn]
分享 (0)
关于作者:
腾讯云-运维运维 QQ 690624
发表我的评论
取消评论
表情 贴图 加粗 删除线 居中 斜体 签到

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址