firewalld的基本使用

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

服务

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

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

配置firewalld-cmd

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

那怎么开启一个端口呢

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

端口转发,需要设置伪装IP

  • firewall-cmd --query-masquerade # 检查是否允许伪装IP
  • firewall-cmd --add-masquerade   # 允许防火墙伪装IP
  • firewall-cmd --remove-masquerade# 禁止防火墙伪装IP
  • firewall-cmd --add-forward-port=port=80:proto=tcp:toport=8080   # 将80端口的流量转发至8080
  • firewall-cmd --add-forward-port=proto=80:proto=tcp:toaddr=192.168.1.0.1 # 将80端口的流量转发至192.168.0.1
  • firewall-cmd --add-forward-port=port=80:proto=tcp:toaddr=192.168.0.1:toport=8080 # 将80端口的流量转发至192.168.0.1的8080端口

双网卡操作

  • firewall-cmd --permanent --zone=public --remove-interface=eth0 #将eth0从public域移除
  • firewall-cmd --permanent --zone=dmz --add-interface=eth1#将eth1添加进public域,会在zones下生成dmz.xml
  • firewall-cmd --get-active-zones #查看活动的域
  • firewall-cmd --get-zone-of-interface=eth0 #查看接口的域

阿里云实例

  • firewall-cmd --permanent --zone=public --remove-interface=eth0
  • firewall-cmd --permanent --zone=public --remove-interface=eth1
  • firewall-cmd --permanent --zone=public --add-interface=eth1
  • firewall-cmd --permanent --zone=internal --remove-interface=eth0
  • firewall-cmd --permanent --zone=internal --remove-interface=eth1
  • firewall-cmd --permanent --zone=internal --add-interface=eth0
  • firewall-cmd --reload
  • systemctl restart firewalld
  • firewall-cmd --get-active-zones
  • firewall-cmd --get-zone-of-interface=eth0
  • firewall-cmd --reload

centos7 firewalld基本使用的更多相关文章

  1. CentOS7 firewalld防火墙 启动 关闭 禁用 添加删除规则等 常用命令

    CentOS7 firewalld防火墙 常用命令1.firewalld的基本使用启动: systemctl start firewalld关闭: systemctl stop firewalld查看 ...

  2. centos7 firewalld

    1.firewalld简介 firewalld是centos7的一大特性,最大的好处有两个: 1.支持动态更新,不用重启服务: 2.加入了防火墙的"zone"概念   firewa ...

  3. CentOS7 firewalld 打开关闭端口

    1. firewalld的基本使用 启动: systemctl start firewalld 关闭: systemctl stop firewalld 查看状态: systemctl status ...

  4. Centos7 firewalld 基本使用

    Centos7 的防火墙 firewalld比较常见 简单介绍使用 详细介绍链接推荐:   https://blog.csdn.net/buster_zr/article/details/806049 ...

  5. centos7 Firewalld操作集合

    =============================================== 2019/4/15_第1次修改                       ccb_warlock == ...

  6. centos7 firewalld使用

    转 http://blog.csdn.net/jamesge2010/article/details/52449678 1.firewalld的基本使用 启动: systemctl start fir ...

  7. CentOS7 firewalld防火墙规则

    在CentOS7里有几种防火墙共存:firewalld.iptables.ebtables,默认是使用firewalld来管理netfilter子系统,不过底层调用的命令仍然是iptables等. f ...

  8. CentOS7,Firewalld防火墙使用方法

    查看防火墙状态 systemctl status firewalld.service 启动firewall systemctl stop firewalld.service 停止firewall sy ...

  9. centos7 firewalld 开放端口

    开通80端口 firewall-cmd --zone=public --add-port=80/tcp --permanent --zone #作用域 --add-port=80/tcp #添加端口, ...

随机推荐

  1. qt 调用zlib压缩与解压缩功能

    Zlib是一种免费且通用的压缩库,由于Zlib压缩效果比LZW好,而且解压缩速度快,更重要的是商业软件中使用Zlib不需要缴纳版权费,所以很多游戏都使用Zlib压缩资源文件. Zlib是由Jean-l ...

  2. WebSphere禁用SSLv3和RC4算法教程

    WebSphere经常会报“SSL 3.0 POODLE攻击信息泄露”和"SSL/TLS 受诫礼(BAR-MITZVAH)攻击"两个漏洞,前者建议禁用SSL算法后者建议禁用RC4算 ...

  3. e2e 测试(1)

    距离上一随笔,已经有一个月没有没写.到今天,刚刚好好,是学习e2e测试的一个月.今天有点时间可以总结一下这个月来的收获. 1.搭建e2e的测试环境 我是使用 Vue 构建项目,所以我也是通过Vue-c ...

  4. jQuery封装 写的的确不错 转载

    扩展jQuery插件和方法的作用是非常强大的,它可以节省大量开发时间.这篇文章将概述jQuery插件开发的基本知识,最佳做法和常见的陷阱. 入门 编写一个jQuery插件开始于给jQuery.fn加入 ...

  5. maven多模块项目找不到Class错误

    接手了一个maven管理的多模块项目,又是javaconfig,又是spring data jpa,还算是比较新比较正规的模块化结构吧..然后我往其中的一个模块中新添加了一个jpa的entity,然后 ...

  6. python+ajaxFileUpload 无刷新上传文件

    需要准备文件 http://pan.baidu.com/s/1bp4N3nL   qqi0 html <script src="{% static 'js/jquery.js' %}& ...

  7. 模块化&os&sys

    syspath python 使用import模块调用的优先级是根据sys.path路径来的,此变量中位置在列表中的先后顺序来调用,如果先找到对应的模块,则先调用此模块. import sys pri ...

  8. [HDU1890]RoboticSort

    Problem 每次找到最小值,然后把它和它前面的数翻转,然后找第二小数······ 然后输出这些数的下标. Solution 用splay维护,每次找到最小值,然后翻转前面区间. Notice 细节 ...

  9. Iterator,迭代器模式,C++描述

    body, table{font-family: 微软雅黑; font-size: 13.5pt} table{border-collapse: collapse; border: solid gra ...

  10. urllib python3 请求、登录、下载网页

    urllib.request 发送request和获取request的结果 urllib.error包含了urllib.request产生的异常 urllib.parse用来解析和处理Url urll ...