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

firewalld跟iptables比起来至少有两大好处:

1、firewalld可以动态修改单条规则,而不需要像iptables那样,在修改了规则后必须得全部刷新才可以生效;
2、firewalld在使用上要比iptables人性化很多,即使不明白“五张表五条链”而且对TCP/IP协议也不理解也可以实现大部分功能。

firewalld跟iptables比起来,不好的地方是每个服务都需要去设置才能放行,因为默认是拒绝。而iptables里默认是每个服务是允许,需要拒绝的才去限制。

1.firewalld对指定IP开放指定端口的配置

1.打开firewalld防火墙

systemctl start firewalld.service

2.添加防火墙规则(对指定ip开放指定端口)

() memcached 端口设置。允许主机21.20.3.33访问11211端口

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="21.20.3.33" port protocol="tcp" port="" accept"

() redis端口设置。允许主机21.20.3.33访问6379端口

firewall-cmd --permanent --add-rich-rule="rule family="ipv4" source address="21.20.3.33" port protocol="tcp" port="" accept"

3.添加防火墙策略

在firewalld服务中配置一条富规则,使其拒绝192.168.10.0/24网段的所有用户访问本机的ssh服务(22端口):

firewall-cmd --permanent --zone=public --add-rich-rule="rule family="ipv4" source address="192.168.10.0/" service name="ssh" reject"
//显示
success firewall-cmd --reload
//显示
success

4.更新防火墙规则

firewall-cmd --reload

5.查看配置结果,验证配置

firewall-cmd --list-all

6.删除规则

firewall-cmd --permanent --remove-rich-rule="rule family="ipv4" source address="21.20.3.33" port protocol="tcp" port="" accept"

firewall-cmd --list-all

常用查看信息命令:

查看版本:$ firewall-cmd --version
查看帮助:$ firewall-cmd --help 查看设置:
显示状态:$ firewall-cmd --state
查看区域信息: $ firewall-cmd --get-active-zones
查看指定接口所属区域:$ firewall-cmd --get-zone-of-interface=eth0
拒绝所有包:# firewall-cmd --panic-on
取消拒绝状态:# firewall-cmd --panic-off
查看是否拒绝:$ firewall-cmd --query-panic

  

CentOS7 firewalld防火墙规则的更多相关文章

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

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

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

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

  3. Linux之firewalld防火墙规则

    一, 什么是防火墙规则? 允许哪些服务端口被放行,怎么放行,及哪些服务端口被阻拦,如何阻拦的一组网络安全规则.支持ipv4和ipv6,且分为直接规则和富规则两种. 二, 如何管理firewalld 1 ...

  4. 关于Centos7 firewalld防火墙开放端口后仍不能访问ftp和nginx的问题解决

    我在阿里轻量应用服务器搭建ftp服务器这篇博客中把防火墙换为iptables,因为当时无论我怎么设置firewalld,就是无法访问ftp服务器,今天在翻看其他博客的时候,突然发现firewalld有 ...

  5. CentOS7 firewalld防火墙配置

    [root@ecs ~]# firewall-cmd --version       //查看版本0.3.9 [root@ecs ~]# firewall-cmd --state        //查 ...

  6. CentOS7 防火墙规则 (firewalld)

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

  7. CentOS7、REHL7的firewalld防火墙使用简单说明

    title: CentOS7.REHL7的firewalld防火墙使用简单说明 categories: Linux tags: - Linux timezone: Asia/Shanghai date ...

  8. CentOS7.3防火墙firewalld简单配置

    今天安装了centos7.3, 想用iptables的save功能保存规则的时候发现跟rhel不一样了,  后来度娘说centos用的是firewalld而不是iptables了, 平时工作都是用re ...

  9. centos7的防火墙(firewalld)

    Centos7中默认将原来的防火墙iptables升级为了firewalld,firewalld跟iptables比起来至少有两大好处: 1.firewalld可以动态修改单条规则,而不需要像ipta ...

随机推荐

  1. 16-numpy笔记-莫烦pandas-4

    代码 import pandas as pd import numpy as np dates = pd.date_range('20130101', periods=6) df=pd.DataFra ...

  2. 【转载】深度解读 java 线程池设计思想及源码实现

    总览 开篇来一些废话.下图是 java 线程池几个相关类的继承结构: 先简单说说这个继承结构,Executor 位于最顶层,也是最简单的,就一个 execute(Runnable runnable) ...

  3. LeetCode24-Swap_Pairs

    swapPairs public ListNode swapPairs(ListNode head) { if(head==null ||head.next==null) return head; L ...

  4. LeetCode 654. Maximum Binary Tree最大二叉树 (C++)

    题目: Given an integer array with no duplicates. A maximum tree building on this array is defined as f ...

  5. VIJOS-P1232 核电站问题

    VIJOS-P1232 核电站问题 JDOJ 1373 https://neooj.com/oldoj/problem.php?id=1373 题目描述         一个核电站有N个放核物质的坑, ...

  6. Git的回滚

    Git常用命令: git add .   #进行提交 git commit -m v2 #v2版本 cat index.html #查看文件内容已经变化 git log #获取到提交信息 git re ...

  7. c++性能测试工具:计算时间复杂度

    有时候除了测量算法的具体性能指数,我们也会希望测试出算法的时间复杂度,以便我们对待测试的算法的性能有一个更加直观的了解. 测量时间复杂度 google benchmark已经为我们提供了类似的功能,而 ...

  8. 【转】PyQt弹出式对话框的常用方法及标准按钮类型

    pyQt之弹出式对话框(QMessageBox)的常用方法及标准按钮类型 一.控件说明 QMessageBox是一种通用的弹出式对话框,用于显示消息,允许用户通过单击不同的标准按钮对消息进行反馈,且每 ...

  9. java知识体系(自我学习中)

    java自我学习知识体系

  10. vue组件、自定义指令、路由

    1.vue组件 组件(Component)是 Vue.js 最强大的功能之一.组件可以扩展 HTML 元素,封装可重用的代码.组件系统让我们可以用独立可复用的小组件来构建大型应用,几乎任意类型的应用的 ...