Centos7.x防火墙,命令实际操作firewall

有些用户,之前一直习惯centos5.x  6.x的iptables防火墙,一旦换到centos7.x上进行操作的时候就麻爪了。

今天给大家带来一些实际可行的命令。演示操作给大家看一下

第一条:查看 firewall 防火墙状态,可使用一下命令查看

1、[root@localhost ~]# firewall-cmd --state 

2、[root@localhost ~]# systemctl status firewalld.service

反馈结果如下

运行状态

运行状态

不运行状态


不运行防火墙状态

第二条:查看完防火墙状态后,可以选择运行或关闭,可使用一下命令

启动:[root@localhost ~]#   systemctl start firewalld

停止:[root@localhost ~]#   systemctl stop firewalld

重启:[root@localhost ~]#  systemctl restart firewalld

启动:[root@localhost ~]#  systemctl start firewalld.service

关闭:[root@localhost ~]#  systemctl stop firewalld.service

重启:[root@localhost ~]#  systemctl restart firewalld.service     (以上命令输入后无反馈,不做图片演示。执行后可用第一条命令查看)

第三条:开机启用或禁用防火墙

启用:[root@localhost ~]#  systemctl enable firewalld.service

禁用:[root@localhost ~]#  systemctl disable firewalld.service


启用:[root@localhost ~]# systemctl enable firewalld

禁用: [root@localhost ~]# systemctl disable firewalld


查看是否开机启动

 [root@localhost ~]#  systemctl is-enabled firewalld.service



第四条:防火墙 添加/删除/查看 服务命令

1、查看已添加的服务

 [root@localhost ~]# firewall-cmd --list-services


查看

2、 添加服务

[root@localhost ~]#  firewall-cmd --add-service=http (添加http服务,等同于开放80端口)


添加服务

3、删除服务

[root@localhost ~]# firewall-cmd --remove-service=http 

删除服务

 第五条:防火墙 添加/删除/查看开放的防火墙

1、查看开启了哪些端口

  [root@localhost ~]# firewall-cmd --zone=public --list-ports (防火墙放行服务时,自动放行的默认服务端口,如22)


查看开放的端口

 2、添加一个端口到防火墙

 [root@localhost ~]# firewall-cmd --zone=public --add-port=80/tcp --permanent  (permanent是永久生效的意思,部署的话,重启机器之后,添加的端口会自动删除)


添加

 3、删除一个防火墙端口

[root@localhost ~]# firewall-cmd --zone=public --remove-port=80/tcp --permanent 


删除

第六条:第四、五条命令执行后,需要输入 重载/更新防火墙 命令

[root@localhost ~]# firewall-cmd --reload

更新反馈值:success(成功),添加或删除的规则就会立刻生效


重载


网云互联(www.94ip.net/www.94ip.com)是一家从事服务器安全防护、入侵检测、服务器代维等为一体的公司,免费服务器安全检测,并有24小时在线运维工程师为您服务。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • CentOS6.5查看防火墙的状态: [zh@localhost ~]$service iptable statu...
    b17b782f6d63阅读 2,084评论 0 0
  • CentOS6.5查看防火墙的状态: [zh@localhost ~]$service iptable statu...
    克鲁德李阅读 894评论 0 0
  • 启动防火墙:systemctl start firewalld.service 关闭防火墙:systemctl s...
    不排版阅读 2,555评论 0 0
  • CentOS各个版本中的命令有所不同,使用起来比较麻烦,感觉有点乱糟糟的,在此总结一下防火墙在不同CentOS中的...
    GHope阅读 580评论 0 9
  • centos7默认使用的是firewall作为防火墙,这里改为iptables防火墙步骤。 firewall-cm...
    montaChan阅读 333评论 0 0