美文网首页
suricata.yaml说明

suricata.yaml说明

作者: 梁帆 | 来源:发表于2021-07-28 15:55 被阅读0次

suricata使用yaml作为配置格式。以下根据官方文档来对suricata.yaml作一些参数说明和解释。

先打开suricata.yaml。

max-pending-packets

文件1042行有:

max-pending-packets

这个参数表示suricata能够同时处理的最大的数据包数量。这个数字最小为1,最大要取决于内存(RAM)的大小。数据包越多,内存消耗也就越大;反之内存消耗越小。当用户有很多的CPU核心时,还把这个数字设置得很小,会造成空间的浪费。典型的例子就是:使用一个核心(core)去处理3个数据包。

runmode

文件1044行有:

runmode

该选项设置了suricata的运行模式,使用命令--list-runmodes在你的命令行,即可查看所有的运行模式。以下是一部分截图:

suricata --list-runmodes

在介绍运行方式(Runmodes)之前首先了解一下suricata的基本组成。Suricata是由所谓的线程(threads)、线程模块 (thread-modules)和队列(queues)组成。Suricata是一个多线程的程序,因此在同一时刻会有多个线程在工作。线程模块是依据 功能来划分的,比如一个模块用于解析数据包,另一个模块用于检测数据包等。每个数据包可能会有多个不同的线程进行处理,队列就是用于将数据包从一个线程传 递到另一个线程。与此同时,一个线程可以拥有多个线程模块,但是在某一时刻只有一个模块在运行。

Suricata的运行方式就是上面介绍的线程(threads)、线程模块(thread-modules)和队列(queues)三种元素的不 同组合方式。上图中的RunMode Type并不是配置文件中的runmodes选项,而是后面的Custom Mode也就是自定义模式才可以在此处设置。比如默认的Runmodes是autofp,在线实时检测流量的模式中其结构如下,单线程模块获取数据包和解码,多线程模块检测,单模块输出:

而在pfring模式下的autofp则有所不同,可以看到它有多个模块获取及解码数据包,通过流绑定队列分配到多个检测模块中进行检测,这应该是pfring模式获取数据包效率更高的原因:

default-packet-size

文件1058行有:

default-packet-size

上面提到的max-pending-packets的选项是设置数据包数量的。这些要处理的数据包都放到了内存中,因此我们需要对每个数据包的大小进行限制。default-packet-size就是限制数据包大小的。设置的默认值是1514,这也是TCP数据包的最大长度(当数据超过这个长度时就会使用报文重组技术)。

user and group

996行有:

run-as

表示用于设置启动suricata的用户及其分组。

pid-file

1005行有:

pid-file

当suricata以daemon mode执行时,需要一个文件来记录suricata的进程ID。

官方文档上还有关于这一条的一个Note:

官方文档的note

action-order

1088行有:

action-order

所有签名都有不同的properties,其中我们要重视的是action property。这决定了当签名匹配的时候会发生什么。以下有四种类型的action。

1、Pass

If a signature matches and contains pass, Suricata stops scanning the packet and skips to the end of all rules (only for the current packet).

pass指的是处理的数据包匹配当前规则时直接跳过后面的所有规则,也就是说不匹配后面的规则。

2、Drop

This only concerns the IPS/inline mode. If the program finds a signature that matches, containing drop, it stops immediately. The packet will not be sent any further. Drawback: The receiver does not receive a message of what is going on, resulting in a time-out (certainly with TCP). Suricata generates an alert for this packet.

drop只能工作在IPS模式下,当数据包匹配到drop的签名时则会被丢弃并且产生一个警告。

3、Reject

This is an active rejection of the packet. Both receiver and sender receive a reject packet. There are two types of reject packets that will be automatically selected. If the offending packet concerns TCP, it will be a Reset-packet. For all other protocols it will be an ICMP-error packet. Suricata also generates an alert. When in Inline/IPS mode, theoffending packet will also be dropped like with the ‘drop’ action.

reject会给数据包的发送和接收端都发生一个拒绝的数据包,如果原本的协议是TCP,则发生reset数据包,否则发送ICMP错误的数据包,同时产生一个警告。在IPS模式下也会丢弃匹配到的数据包。

4、Alert

If a signature matches and contains alert, the packet will be treated like any other non-threatening packet, except for this one an alert will be generated by Suricata. Only the system administrator can notice this alert.

alert则对发送和接收者都没有影响,只会生成一个警告。

Suricata按照规则的出现顺序依次加载,但是处理的顺序则根据配置文件中设置的action重要程度来排列。默认的顺序如下,表示当一个数据包匹配多条规则时,优先处理的是pass的规则,其次是drop,然后是reject,最后是alert。

配置顺序

Splitting configuration in multiple files

相关文章

  • suricata.yaml说明

    suricata使用yaml作为配置格式。以下根据官方文档来对suricata.yaml作一些参数说明和解释。 先...

  • Suricata配置文件suricata.yaml说明

    转自:https://www.cnblogs.com/UnGeek/p/5796934.html 本系列文章是Su...

  • suricata 配置3(Global-Thresholds)

    续接上文suricata 配置2(suricata.yaml) https://www.jianshu.com/p...

  • suricata 配置1(suricata.yaml)

    1. suricata.yaml Suricata使用Yaml格式进行配置。源代码中包含的Suricata.yam...

  • [Suricata]结果写入kafka

    目前是公司正在搞得项目, 所以只说思路, 具体代码就不贴了 修改配置中的写出类型 suricata.yaml配置中...

  • Suricata文档——第七章性能3

    7.5 高性能配置 如果有足够的内存,请考虑suricata.yaml中的以下选项,以尽可能减轻CPU的工作量:...

  • 说明~说明~

    咳咳 之前在斗觅的大号说这个号不用了 but! 这个号可以把我无聊的心思给大破,啊呸!打破! 打破! 打破! 打破...

  • 说明

    作者看了石头门之后突发奇想写的书,如果有特别雷同的部分,请QQ告诉我,我会后期修改

  • 说明

    截止到现在我的存稿就发完了,之后大概会在简书和起点同步更新。我尽量保证周更,但是最近比较忙估计会欠几更,等月底忙完...

  • 说明

    原本计划写的连载小说,不在简书上更新了,换了平台。貌似我写的不对简书口味

网友评论

      本文标题:suricata.yaml说明

      本文链接:https://www.haomeiwen.com/subject/slnqsltx.html