用活Firewalld防火墙之direct
原文地址:http://www.excelib.com/article/294/show
学生在前面已经给大家介绍过了Firewalld中direct的作用,使用他可以直接使用iptables、ip6tables
中的规则进行配置,下面学生就给大家介绍direct的具体用法。
direct结构
我们还是先从配置文件入手,direct的配置文件为/etc/firewalld/direct.xml文件,结构如下
- <?xml version="1.0" encoding="utf-8"?>
- <direct>
- [ <chain ipv="ipv4|ipv6" table="table" chain="chain"/> ]
- [ <rule ipv="ipv4|ipv6" table="table" chain="chain" priority="priority"> args </rule> ]
- [ <passthrough ipv="ipv4|ipv6"> args </passthrough> ]
- </direct>
大家可以看到这里的direct一共有三种节点:chain、rule和passthrough,他们都是可选的,而且都可以出现多次。
属性
ipv:这个属性非常简单,表示ip的版本
table:chain和rule节点中的table属性就是iptables/ip6tables中的table
chain:chain中的chain属性用于指定一个自定义链的名字,注意,不可与已有链重名;rule中的chain属性既可以是内建的(也就是iptables/ip6tables中的五条链),也可以是在direct中自定义的chain
priority:优先级,用于设置不同rule的优先级,就像iptables中规则的前后顺序,数字越小优先级越高
args:rule和passthrough中的args就是iptables/ip6tables中的一条具体的规则,不过他们可以使用我们自定义的chain。
使用
因为direct的使用跟iptables/
非常相似,换句话说,想用好direct需要有ip6tables
iptables/
的基础,而ip6tables
iptables/
并不是我们这套教程的重点,所以这里学生就不给大家详细讲解了。ip6tables
direct中自定义chain跟iptables/
中使用-N新建chain类似,创建完之后就可以在规则中使用-j或者-g来使用了。ip6tables
Firewalld中跟direct相关的命令如下
- firewall-cmd [--permanent] --direct --get-all-chains
- firewall-cmd [--permanent] --direct --get-chains { ipv4 | ipv6 | eb } table
- firewall-cmd [--permanent] --direct --add-chain { ipv4 | ipv6 | eb } table chain
- firewall-cmd [--permanent] --direct --remove-chain { ipv4 | ipv6 | eb } table chain
- firewall-cmd [--permanent] --direct --query-chain { ipv4 | ipv6 | eb } table chain
- firewall-cmd [--permanent] --direct --get-all-rules
- firewall-cmd [--permanent] --direct --get-rules { ipv4 | ipv6 | eb } table chain
- firewall-cmd [--permanent] --direct --add-rule { ipv4 | ipv6 | eb } table chain priority args
- firewall-cmd [--permanent] --direct --remove-rule { ipv4 | ipv6 | eb } table chain priority args
- firewall-cmd [--permanent] --direct --remove-rules { ipv4 | ipv6 | eb } table chain
- firewall-cmd [--permanent] --direct --query-rule { ipv4 | ipv6 | eb } table chain priority args
- firewall-cmd --direct --passthrough { ipv4 | ipv6 | eb } args
- firewall-cmd --permanent --direct --get-all-passthroughs
- firewall-cmd --permanent --direct --get-passthroughs { ipv4 | ipv6 | eb }
- firewall-cmd --permanent --direct --add-passthrough { ipv4 | ipv6 | eb } args
- firewall-cmd --permanent --direct --remove-passthrough { ipv4 | ipv6 | eb } args
- firewall-cmd --permanent --direct --query-passthrough { ipv4 | ipv6 | eb } args
下面我们来看个文档(firewalld.direct(5))中提供的例子
- <?xml version="1.0" encoding="utf-8"?>
- <direct>
- <chain ipv="ipv4" table="raw" chain="blacklist"/>
- <rule ipv="ipv4" table="raw" chain="PREROUTING" priority="">-s 192.168.1.0/ -j blacklist</rule>
- <rule ipv="ipv4" table="raw" chain="PREROUTING" priority="">-s 192.168.5.0/ -j blacklist</rule>
- <rule ipv="ipv4" table="raw" chain="blacklist" priority="">-m limit --limit /min -j LOG --log-prefix "blacklisted: "</rule>
- <rule ipv="ipv4" table="raw" chain="blacklist" priority="">-j DROP</rule>
- </direct>
在这个例子中首先自定义了一个叫blacklist的链,然后将所有来自192.168.1.0/24和192.168.5.0/24的数据包都指向了这个链,最后定义了这个链的规则:首先进行记录,然后drop,记录的方法是使用“blacklisted: ”前缀并且限制1分钟记录一次。
当然,使用相似的方法大家也可以写出来上一节学生给大家留下的那个问题:对ping请求进行限制。
用活Firewalld防火墙之direct的更多相关文章
- 用活firewalld防火墙之service
原文地址:http://www.excelib.com/article/291/show 前面学生已经给大家介绍了在firewalld中service的概念以及在zone中怎么使用service,但是 ...
- centos7 firewall-cmd 用活firewalld防火墙中的zone
原文:http://www.excelib.com/article/290/show/ firewalld中zone的含义学生前面已经给大家介绍过了,说白了一个zone就是一套规则集.可是什么时候该用 ...
- 用活firewalld防火墙中的zone
原文地址:http://www.excelib.com/article/290/show firewalld中zone的含义学生前面已经给大家介绍过了,说白了一个zone就是一套规则集.可是什么时候该 ...
- CentOS7、REHL7的firewalld防火墙使用简单说明
title: CentOS7.REHL7的firewalld防火墙使用简单说明 categories: Linux tags: - Linux timezone: Asia/Shanghai date ...
- Firewalld防火墙与ICMP攻击
原文地址:http://www.excelib.com/article/293/show 提到ICMP大家应该都很熟悉,可能有人会说:不就是ping吗?但是说到ICMP攻击以及相关防御措施可能就有的人 ...
- 11.Firewalld防火墙
Firewalld防火墙 目录 Firewalld防火墙 Firewalld概述 Firewalld Firewalld和iptables的关系 netfilter Firewalld/iptable ...
- 第8章 Iptables与Firewalld防火墙
章节简述: 红帽RHEL7系统已经用firewalld服务替代了iptables服务,新的防火墙管理命令firewall-cmd与图形化工具firewall-config. 本章节基于数十个防火墙需求 ...
- CentOS7使用firewalld防火墙配置端口
安装启用firewalld防火墙 CentOS7默认的防火墙是firewalld 如果没有firewalld防火墙,可以执行yum install firewalld 命令进行安装 firewalld ...
- Linux firewalld 防火墙
Linux firewalld 防火墙 简介 RHEL 7 系统中集成了多款防火墙管理工具,其中 firewalld(Dynamic Firewall Manager of Linux system ...
随机推荐
- 【hdu1005】Number Sequence
题目描述 一个数列的定义如下: f(1) = 1, f(2) = 1, f(n) = (A * f(n - 1) + B * f(n - 2)) mod 7. 给出A和B,你要求出f(n). 输入 输 ...
- Windows消息队列(优先队列,结构体中放比较函数)
Windows消息队列 消息队列是Windows系统的基础.对于每个进程,系统维护一个消息队列.如果在进程中有特定事件发生,如点击鼠标.文字改变等,系统将把这个消息加到队列当中.同时,如果队列不是空的 ...
- Javascript-- jQuery动画篇(2)
动画效果 前面的 hide/show,slide in/out 其实也具有动画效果,本篇介绍使用 animate()实现自定义动画效果. 基本语法如下: $(selector).animate({pa ...
- Android组件化开发实践
转载请注明出处:http://blog.csdn.net/crazy1235/article/details/76533115 http://mdsa.51cto.com/art/201707/544 ...
- EasyPusher RTSP推流/EasyRTMP RTMP推流Android安卓摄像头视频偏暗的问题解决方案
本文转自EasyDarwin团队成员JOHN的博客:http://blog.csdn.net/jyt0551/article/details/75730226 在我们测试EasyPusher/Easy ...
- EasyRMS录播管理服务器项目实战:windows上开机自启动NodeJS服务
本文转自EasyDarwin开源团队成员Penggy的博客:http://www.jianshu.com/p/ef840505ae06 近期在EasyDarwin开源团队开发一款基于EasyDarwi ...
- phpstorm、webstorm配置less编译器
1. node.js 安装包 https://nodejs.org/en/download/ 1) 安装js解析器node.js.直接下一步就ok了. 2) 将npm压缩包解压,找到里面的les ...
- [IC]Lithograph(1)光刻技术分析与展望
文章主体转载自: 1.zol摩尔定律全靠它 CPU光刻技术分析与展望 2.wiki:Extreme ultraviolet lithography 3.ITRS 2012 1. 光刻技术组成和关键点 ...
- 【Git】无法从远程分支pull
随着工作量的增多,接触的新项目,新同事越来越多,发现自己不会的东西好多.有这么一句话:“你所知道的知识就像是一个圆,你会的越多,圆越大,但你接触的未知世界也越大,也就越加觉得自己无知”.原话记不全了, ...
- MySQL性能指标计算方式
-- 生成报告文件到/tmp目录中 tee /tmp/mysql_performance_stat.txt -- 统计性能指标前先开启下列参数,该参数使用IS数据库来存放数据库信息,由于使用PS库存放 ...