美文网首页
firewalld的基本使用

firewalld的基本使用

作者: 那个初衷 | 来源:发表于2017-08-22 13:17 被阅读0次

1.基本使用

  • 启动
[root@centos]# systemctl start firewalld
  • 停止
[root@centos]#  systemctl stop firewalld
  • 启用
[root@centos]# systemctl enable firewalld
  • 禁用
[root@centos]# systemctl disable firewalld
  • 查看状态
[root@centos]# systemctl status firewalld 

2. systemctl是CentOS7的服务管理工具中主要的工具,它融合之前service和chkconfig的功能于一体。

  • 启动一个服务:
[root@centos]# systemctl start firewalld.service
  • 关闭一个服务:
[root@centos]# systemctl stop firewalld.service
  • 重启一个服务:
[root@centos]# systemctl restart firewalld.service
  • 显示一个服务的状态:
[root@centos]# systemctl status firewalld.service
  • 在开机时启用一个服务:
[root@centos]# systemctl enable firewalld.service
  • 在开机时禁用一个服务:
[root@centos]# systemctl disable firewalld.service
  • 查看服务是否开机启动:
[root@centos]# systemctl is-enabled firewalld.service
  • 查看已启动的服务列表:
[root@centos]# systemctl list-unit-files|grep enabled
  • 查看启动失败的服务列表:
[root@centos]# systemctl --failed

3. 配置firewalld-cmd

  • 查看版本:
[root@centos]# firewall-cmd --version
  • 查看帮助:
[root@centos]# firewall-cmd --help
  • 显示状态:
[root@centos]# firewall-cmd --state
  • 查看所有打开的端口:
[root@centos]# firewall-cmd --zone=public --list-ports
  • 更新防火墙规则:
[root@centos]# firewall-cmd --reload
  • 查看区域信息:
[root@centos]# firewall-cmd --get-active-zones
  • 查看指定接口所属区域:
[root@centos]# firewall-cmd --get-zone-of-interface=eth0
  • 拒绝所有包:
[root@centos]# firewall-cmd --panic-on
  • 取消拒绝状态:
[root@centos]# firewall-cmd --panic-off
  • 查看是否拒绝:
[root@centos]# firewall-cmd --query-panic

那怎么开启一个端口呢

  • 添加
# --permanent永久生效,没有此参数重启后失效
[root@centos]# firewall-cmd --zone=public --add-port=80/tcp --permanent    
  • 重新载入
[root@centos]# firewall-cmd --reload
  • 查看
[root@centos]# firewall-cmd --zone= public --query-port=80/tcp
  • 删除
[root@centos]# firewall-cmd --zone= public --remove-port=80/tcp --permanent

相关文章

网友评论

      本文标题:firewalld的基本使用

      本文链接:https://www.haomeiwen.com/subject/rafldxtx.html