firewalld的基本使用

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

推荐阅读更多精彩内容