Suricata+PF_RING安装详解

1. 前言

  1. Suricata的安装包可以从 github上克隆安装,可以从Suricata官网进行下载。本文的测试以github上的版本为例。
  2. 本文的测试平台为 CentOS release 6.7 (Final),不同Linux平台类似。
  3. 由于实际需求,本文中的Suricata编译将加入PF_RING零拷贝工具。

2. Suricata Build Info 详解

[root@monster suricata]# suricata --build-info
This is Suricata version 3.0.1 RELEASE
Features: PCAP_SET_BUFF LIBPCAP_VERSION_MAJOR=1 PF_RING AF_PACKET HAVE_PACKET_FANOUT HAVE_HTP_URI_NORMALIZE_HOOK HAVE_NSS TLS 
SIMD support: SSE_4_2 SSE_4_1 SSE_3 
Atomic intrisics: 1 2 4 8 16 byte(s)
64-bits, Little-endian architecture
GCC version 4.4.7 20120313 (Red Hat 4.4.7-16), C version 199901
compiled with _FORTIFY_SOURCE=0
L1 cache line size (CLS)=64
thread local storage method: __thread
compiled with LibHTP v0.5.19, linked against LibHTP v0.5.19

Suricata Configuration:
  AF_PACKET support:                       yes
  PF_RING support:                         yes //PF_RING支持
  NFQueue support:                         no
  NFLOG support:                           no
  IPFW support:                            no
  Netmap support:                          no
  DAG enabled:                             no
  Napatech enabled:                        no

  Unix socket enabled:                     no
  Detection enabled:                       yes

  libnss support:                          yes
  libnspr support:                         yes
  libjansson support:                      no
  hiredis support:                         no
  Prelude support:                         no
  PCRE jit:                                no
  LUA support:                             no
  libluajit:                               no
  libgeoip:                                no
  Non-bundled htp:                         no
  Old barnyard2 support:                   no
  CUDA enabled:                            no
  Hyperscan support:                       no

  Suricatasc install:                      yes

  Unit tests enabled:                      no
  Debug output enabled:                    no
  Debug validation enabled:                no
  Profiling enabled:                       no
  Profiling locks enabled:                 no
  Coccinelle / spatch:                     no

Generic build parameters:
  Installation prefix:                     /usr
  Configuration directory:                 /etc/suricata/
  Log directory:                           /var/log/suricata/

  --prefix                                 /usr
  --sysconfdir                             /etc
  --localstatedir                          /var

  Host:                                    x86_64-unknown-linux-gnu
  Compiler:                                gcc (exec name) / gcc (real)
  GCC Protect enabled:                     no
  GCC march native enabled:                yes
  GCC Profile enabled:                     no
  Position Independent Executable enabled: no
  CFLAGS                                   -g -O2 -march=native
  PCAP_CFLAGS                               -I/usr/local/include
  SECCFLAGS                                

2. 安装依赖项

$ sudo yum install wget libpcap-devel libnet-devel pcre-devel gcc-c++ automake autoconf libtool make libyaml-devel zlib-devel file-devel jansson-devel nss-devel

安装过程中,若出现类似 No package *** available.,则自行wget相应安装包进行安装。
例如:笔者缺少libnet-devel和jansson-devel ,可以到sourceforge或github进行查找安装。

3. 检查配置(configure)

git clone  https://github.com/inliniac/suricata.git
cd suricata
sh autogen.sh
./configure --sysconfdir=/etc --localstatedir=/var 

若需加入PF_RING支持,则添加

--enable-pfring --with-libpfring-includes=/usr/local/pfring/include --with-libpfring-libraries=/usr/local/pfring/lib

类似地,要加入PCRE-jit支持,则添加

--enable-pcre-jit --with-libpcre-includes=/usr/local/include 
--with-libpcre-libraries=/usr/local/lib

综上笔者使用的编译命令:

./configure --sysconfdir=/etc --localstatedir=/var --enable-pfring --with-libpfring-includes=/usr/local/pfring/include --with-libpfring-libraries=/usr/local/pfring/lib

3. 编译及安装

make
sudo make install
sudo ldconfig

4. 配置及规则集安装

  1. Suricata源代码随带默认的配置文件,使用命令sudo make install-conf,可进行安装。

  2. 正如你所知,要是没有IDS规则集,Suricata毫无用处。颇为方便的是,Makefile随带IDS规则安装选项。想安装IDS规则,运行下面这个命令即可。
    sudo make install-rules
    上述规则安装命令会从EmergingThreats.net(https://www.bro.org)安装可用的社区规则集的最新快照,并将它们存储在/etc/suricata/rules下。

    Suricata+PF_RING安装详解_第1张图片

5. 测试

5.1 离线检测

suricata -c /etc/suricata/suricata.yaml -r 0.pcap -l .

Suricata+PF_RING安装详解_第2张图片

5.2 在线检测

6. 参考资料

  1. http://netsecurity.51cto.com/art/201509/490966.htm

你可能感兴趣的:(网络安全)