不多说,直接上干货!

  

  见官网

https://suricata.readthedocs.io/en/latest/setting-up-ipsinline-for-linux.html


11. Setting up IPS/inline for Linux

In this guide will be explained how to work with Suricata in layer3 inline mode and how to set iptables for that purpose.

First start with compiling Suricata with NFQ support. For instructions see Ubuntu Installation. For more information about NFQ and iptables, see NFQ.

To check if you have NFQ enabled in your Suricata, enter the following command:

suricata --build-info

and examine if you have NFQ between the features.

To run suricata with the NFQ mode, you have to make use of the -q option. This option tells Suricata which of the queue numbers it should use.

sudo suricata -c /etc/suricata/suricata.yaml -q 0

11.1. Iptables configuration

First of all it is important to know which traffic you would like to send to Suricata. Traffic that passes your computer or traffic that is generated by your computer.

 

If Suricata is running on a gateway and is meant to protect the computers behind that gateway you are dealing with the first scenario: forward_ing . If Suricata has to protect the computer it is running on, you are dealing with the second scenario: host (see drawing 2). These two ways of using Suricata can also be combined.

The easiest rule in case of the gateway-scenario to send traffic to Suricata is:

sudo iptables -I FORWARD -j NFQUEUE

In this case, all forwarded traffic goes to Suricata.

In case of the host situation, these are the two most simple iptable rules;

sudo iptables -I INPUT -j NFQUEUE
sudo iptables -I OUTPUT -j NFQUEUE

It is possible to set a queue number. If you do not, the queue number will be 0 by default.

Imagine you want Suricata to check for example just TCP-traffic, or all incoming traffic on port 80, or all traffic on destination-port 80, you can do so like this:

sudo iptables -I INPUT -p tcp  -j NFQUEUE
sudo iptables -I OUTPUT -p tcp -j NFQUEUE

In this case, Suricata checks just TCP traffic.

sudo iptables -I INPUT -p tcp --sport 80  -j NFQUEUE
sudo iptables -I OUTPUT -p tcp --dport 80 -j NFQUEUE

In this example, Suricata checks all input and output on port 80.

 

To see if you have set your iptables rules correct make sure Suricata is running and enter:

sudo iptables -vnL

In the example you can see if packets are being logged.

This description of the use of iptables is the way to use it with IPv4. To use it with IPv6 all previous mentioned commands have to start with ‘ip6tables’. It is also possible to let Suricata check both kinds of traffic.

There is also a way to use iptables with multiple networks (and interface cards). Example:

sudo iptables -I FORWARD -i eth0 -o eth1 -j NFQUEUE
sudo iptables -I FORWARD -i eth1 -o eth0 -j NFQUEUE

The options -i (input) -o (output) can be combined with all previous mentioned options

If you would stop Suricata and use internet, the traffic will not come through. To make internet work correctly, you have to erase all iptable rules.

To erase all iptable rules, enter:

sudo iptables -F

Setting up IPS/inline for Linux in Suricata的更多相关文章

  1. The Guideline of Setting Up Samba Server on linux(Ubuntu)

    The Guideline of Setting Up Samba Server on linux(Ubuntu) From terminate command window, install the ...

  2. Suricata, to 10Gbps and beyond(X86架构)

    Introduction Since the beginning of July 2012, OISF team is able to access to a server where one int ...

  3. Kali linux 2016.2(Rolling)中的payloads模块详解

    不多说,直接上干货! 前期博客 Kali linux 2016.2(Rolling)中的Exploits模块详解 payloads模块,也就是shellcode,就是在漏洞利用成功后所要做的事情.在M ...

  4. Linux 驱动开发

    linux驱动开发总结(一) 基础性总结 1, linux驱动一般分为3大类: * 字符设备 * 块设备 * 网络设备 2, 开发环境构建: * 交叉工具链构建 * NFS和tftp服务器安装 3, ...

  5. 使用.NetCore在Linux上写TCP listen 重启后无法绑定地址

    拥抱.net core的过程中, 将公司的一套java项目改成了.net core 2.0版的. 里面的tcp服务被我用msdn的SocketAsyncEventArgs方式重写了, 然而在测试的过程 ...

  6. linux记录-docker配置mysql

    docker部署mysql 1.拉取镜像 docker pull mysql 2.docker  rm   containerID  删除镜像iD 3.创建镜像 docker run --name=m ...

  7. linux从head.s到start_kernelstart_kernel之---内核重定位后分析

    参考: https://biscuitos.github.io/blog/ARM-BOOT/ zImage 重定位之后实践 zImage 重定位之后,ARM 将 pc 指针指向了重定位 zImage ...

  8. Linux设备驱动中的阻塞和非阻塞I/O <转载>

    Green 博客园 首页 新随笔 联系 订阅 管理 Linux设备驱动中的阻塞和非阻塞I/O   [基本概念] 1.阻塞 阻塞操作是指在执行设备操作时,托不能获得资源,则挂起进程直到满足操作所需的条件 ...

  9. pytbull 手册

    - Official documentation for pytbull v2.1 - Table of content Description Architecture Remote mode Lo ...

随机推荐

  1. queue_action

    http://www.learn4master.com/programming-language/python/python-queue-for-multithreading

  2. Duplicate Observed Data

    在翻看<重构-改善既有代码的设计>这本经典的书,书中就介绍了一个重构方法--Duplicate Observed Data 复制被监视数据的重构方法,使用这种方法能够使界面和对数据的操作隔 ...

  3. MySQL 权限生效

    用GRANT.REVOKE或SET PASSWORD对授权表施行的修改会立即被服务器注意到. 如果你手工地修改授权表(使用INSERT.UPDATE等等),你应该执行一个FLUSH PRIVILEGE ...

  4. ios常用到的第三方库

    在iOS开发中不可避免的会用到一些第三方类库,它们提供了很多实用的功能,使我们的开发变得更有效率:同时,也可以从它们的源代码中学习到很多有用的东西. Reachability 检测网络连接 用来检查网 ...

  5. Uboot中start.S源码的指令级的详尽解析【转】

    本文转载自:http://www.crifan.com/files/doc/docbook/uboot_starts_analysis/release/html/uboot_starts_analys ...

  6. Kappa:比Lambda更好更灵活的实时处理架构

    为了进一步探讨这种批处理和实时处理有效整合在同一系统的架构,我们将在今天的文章中分析Lambda三层结构模型的适用场景,同时暴露出Lambda架构一个最明显的问题:它需要维护两套分别跑在批处理和实时计 ...

  7. Tomcat 系统架构与设计模式之一

    Tomcat 系统架构与设计模式,第 1 部分: 工作原理 来自:http://www.ibm.com/developerworks/cn/java/j-lo-tomcat1/index.html 这 ...

  8. [Selenium] 搭建 Android WebDriver 环境

    1.安装 Android SDK 到如下网址下载 Android SDK http://developer.android.com/sdk/index.html 2.创建 Android 虚拟设备 解 ...

  9. 字符串转UTF-8码(%开头)

    var str = '中'; var code = encodeURI(str); console.log(code); // => %E4%B8%AD

  10. 你真的懂redis吗?

    Redis在互联网技术存储方面使用如此广泛,几乎所有的后端技术面试官都要在Redis的使用和原理方面对小伙伴们进行各种刁难.作为一名在互联网技术行业打击过成百上千名[请允许我夸张一下]的资深技术面试官 ...