安装:yum install firewalld

1、firewalld的基本使用

启动: systemctl start firewalld
查看状态: systemctl status firewalld 
禁用,禁止开机启动: systemctl disable firewalld
停止运行: systemctl stop firewalld
 

2.配置firewalld-cmd

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

3.信任级别,通过Zone的值指定

drop: 丢弃所有进入的包,而不给出任何响应 
block: 拒绝所有外部发起的连接,允许内部发起的连接 
public: 允许指定的进入连接 
external: 同上,对伪装的进入连接,一般用于路由转发 
dmz: 允许受限制的进入连接 
work: 允许受信任的计算机被限制的进入连接,类似 workgroup 
home: 同上,类似 homegroup 
internal: 同上,范围针对所有互联网用户 
trusted: 信任所有连接

4.firewall开启和关闭端口

以下都是指在public的zone下的操作,不同的Zone只要改变Zone后面的值就可以
添加:
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
 

5.管理服务

以smtp服务为例, 添加到work zone
添加:
firewall-cmd --zone=work --add-service=smtp
查看:
firewall-cmd --zone=work --query-service=smtp
删除:
firewall-cmd --zone=work --remove-service=smtp
 

5.配置 IP 地址伪装

查看:
firewall-cmd --zone=external --query-masquerade
打开:
firewall-cmd --zone=external --add-masquerade
关闭:
firewall-cmd --zone=external --remove-masquerade

6.端口转发

打开端口转发,首先需要打开IP地址伪装
  firewall-cmd --zone=external --add-masquerade
 
转发 tcp 22 端口至 3753:
firewall-cmd --zone=external --add-forward-port=22:porto=tcp:toport=3753
转发端口数据至另一个IP的相同端口:
firewall-cmd --zone=external --add-forward-port=22:porto=tcp:toaddr=192.168.1.112
转发端口数据至另一个IP的 3753 端口:
firewall-cmd --zone=external --add-forward-port=22:porto=tcp::toport=3753:toaddr=192.168.1.112
 

6.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

CentOS7 防火墙(firewall)的操作命令(转)的更多相关文章

  1. CentOS7防火墙firewall相关操作

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld 停止: systemctl disabl ...

  2. centos7防火墙--firewall

    centos7的防火墙变成firewall了 systemctl start firewalld.service#启动firewallsystemctl stop firewalld.service# ...

  3. CentOS7 防火墙Firewall常用命令

    1.firewalld的基本使用 启动: systemctl start firewalld 查看状态: systemctl status firewalld  停止: systemctl disab ...

  4. CentOS7防火墙firewall

    一.Firewall 1. 从CentOS7开始,默认使用firewall来配置防火墙,没有安装iptables(旧版默认安装). 2. firewall的配置文件是以xml的格式,存储在 /usr/ ...

  5. CentOS7 防火墙(firewall)的操作命令

    CentOS7 防火墙(firewall)的操作命令 安装:yum install firewalld 1.firewalld的基本使用 启动: systemctl start firewalld 查 ...

  6. CentOS7下Firewall防火墙配置用法详解

    官方文档地址: https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/7/html/Security_Guide ...

  7. Centos7 使用firewall管理防火墙

    一.Centos7使用firewall的管理防火墙 1.firewalld基本使用 启动:systemctl start firewalld 关闭:systemctl stop firewalld 状 ...

  8. 防火墙 firewall iptables

    firewalld FirewallD 使用服务service 和区域zone来代替 iptables 的规则rule和链chain,默认情况下,有以下的区域zone可用: drop – 丢弃所有传入 ...

  9. Centos7防火墙快速开放端口配置方法

    ▲这篇文章主要为大家详细介绍了Centos7防火墙开放端口的快速方法,感兴趣的小伙伴们可以参考一下! Firewalld服务是红帽RHEL7系统中默认的防火墙管理工具,特点是拥有运行时配置与永久配置选 ...

  10. CentOS7 防火墙设置

    CentOS7 防火墙命令 最近在公司服务器上安装了oracle12c数据库,在用数据库客户端连接的时候,连接不了.最后查找资料的原因是因为oracle的服务端口未开放. 首先还是还是输入以往的开启某 ...

随机推荐

  1. Mongodb 相关链接

    http://www.cnblogs.com/lanceyan/tag/mongodb/

  2. 面向对象原生JavaScript案例炫彩小球

    面向对象其实对于初学者来说还是比较难以理解的,以前看到一个面试题目 面向对象是什么? 面向对象是一种思想,千万别入坑了: 这次给大家带来的是一个鼠标移动产生小球的案例,不是我不想给大家分享如何去认识面 ...

  3. /usr/bin/ld: warning: libavformat.so.57, needed by /home/camera.so, not found (try using -rpath or -rpath-link)

    ffmpeg中,使用libavformt.so.57时,查找不到. 解决方案: 修改ld.so.conf文件,添加路径. sudo gedit /etc/ld.so.conf 在文件末尾添加路径 /u ...

  4. 不能忽视 php warning

    2018-12-5 10:50:22 星期三 遇到一个问题: 前一行是取数组中的某一个值, 后一行是用heredoc输出一串javascript脚本; 因为取数组中值的时候键不存在, 导致后续输出的j ...

  5. WebApi-2 自定义路由与默认路由

    向Web API添加路由 public static void Register(HttpConfiguration config) { //// Web API 配置和服务 //// 将 Web A ...

  6. java - day006 - 构造方法

    构造方法 新建对象是,执行的一个特殊方法 new 类名(); 这个小括号就是构造方法 Java 类中,必须有构造方法,如果自己不定义, 编译器会自动生成默认构造方法 new 关键字是新建对象用的,   ...

  7. Hanlp学习笔记

    一.首先要引入mawen依赖包: <dependency> <groupId>com.hankcs</groupId> <artifactId>hanl ...

  8. Android真机测试,连接到本地服务器的方法

    1. 前言 作为一名Android开发者,不管怎么说,都会经历使用Android真机来测试连接本地服务器这样的事情.这里所说的“本地服务器”大多数时候指的是:搭载有某种服务器软件的PC,例如搭载有To ...

  9. QT安装后再添加或删除组件

    QT安装目录下打开MaintenanerceTool.exe 手动添加​储存库,要定位一个储存有QT在线安装镜像的网址: https://download.qt.io/online/qtsdkrepo ...

  10. jdbc连接数据库以及crud(简单易懂,本人亲测可用 有源代码和数据库)

    今天呢!重新整理了一边jdbc的相关操作:现在来说对于很多框架都使用mybatis和hibernate来操作数据库 ,也有很多使用自己简单封装的ssm或者是其他的一些框架来操作数据库,但是无论使用哪一 ...