centOS 7开放防火墙端口

淡淡的烟草味﹌ 2022-06-02 07:05 369阅读 0赞

目录

  • 目录

    • centOS7 firewalld的基本使用
    • systemctl服务管理工具
    • 配置firewalld-cmd
    • 添加删除查看开放端口

在centos7中防火墙iptables升级为为firewalld了

centOS7 firewalld的基本使用

  1. 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disable firewalld 禁用: systemctl stop firewalld

systemctl服务管理工具

  1. 启动一个服务:systemctl start firewalld.service
  2. 关闭一个服务:systemctl stop firewalld.service
  3. 重启一个服务:systemctl restart firewalld.service
  4. 显示一个服务的状态:systemctl status firewalld.service
  5. 在开机时启用一个服务:systemctl enable firewalld.service
  6. 在开机时禁用一个服务:systemctl disable firewalld.service
  7. 查看服务是否开机启动:systemctl is-enabled firewalld.service
  8. 查看已启动的服务列表:systemctl list-unit-files|grep enabled
  9. 查看启动失败的服务列表:systemctl --failed

配置firewalld-cmd

  1. 查看版本: firewall-cmd --version
  2. 查看帮助: firewall-cmd --help
  3. 显示状态: firewall-cmd --state
  4. 查看所有打开的端口: firewall-cmd --zone=public --list-ports
  5. 更新防火墙规则: firewall-cmd --reload
  6. 查看区域信息: firewall-cmd --get-active-zones
  7. 查看指定接口所属区域: firewall-cmd --get-zone-of-interface=eth0
  8. 拒绝所有包:firewall-cmd --panic-on
  9. 取消拒绝状态: firewall-cmd --panic-off
  10. 查看是否拒绝: firewall-cmd --query-panic

添加、删除、查看开放端口

添加

  1. firewall-cmd --zone=public --add-port=80/tcp --permanent (--permanent永久生效,没有此参数重启后失效)
  2. 重新载入
  3. firewall-cmd --reload
  4. 查看
  5. firewall-cmd --zone= public --query-port=80/tcp
  6. 删除
  7. firewall-cmd --zone= public --remove-port=80/tcp --permanent

转自

添加端口最终保存的文件地址
/etc/firewalld/zones/public.xml
参考自

发表评论

表情:
评论列表 (有 0 条评论,369人围观)

还没有评论,来说两句吧...

相关阅读

    相关 centos 开放防火墙端口

    在使用 linux 系统时,经常需要连接某些端口;而这些端口又经常被防火墙阻拦,导致连接超时 本文介绍如何开放这些端口,以提供连接   输入如下命令编辑防火墙配置文件