如何在 AlmaLinux 8 上安装 Suricata

Linux命令3年前 (2021)发布 AI观察员
131 0 0

Suricata 是一个免费、开源、成熟、快速且强大的网络威胁检测引擎。它可以用作入侵检测 (IDS) 引擎、内联入侵防御系统 (IPS)、网络安全监控 (NSM) 以及离线 pcap 处理工具。Suricata 使用强大而广泛的规则和签名语言检查网络流量,并具有强大的 Lua 脚本支持来检测复杂的威胁。如何在 AlmaLinux 8 上安装 Suricata

AlmaLinux 8安装 Suricata

步骤 1. 首先,让我们先确保您的系统是最新的。

sudo dnf update
sudo dnf install epel-release
sudo dnf config-manager --set-enabled PowerTools
sudo dnf install diffutils gcc jansson-devel make nss-devel pcre-devel python3 python3-pyyaml rust-toolset zlib-devel curl wget tar lua lz4-devel

步骤 2. 在 AlmaLinux 8 上安装 Suricata。

现在我们从官方页面下载最新的稳定版Suricata源代码:

wget https://www.openinfosecfoundation.org/download/suricata-6.0.3.tar.gz
tar xzf suricata-6.0.3.tar.gz

然后,使用以下命令编译并安装 Suricata:

cd suricata-6.0.3
./configure --sysconfdir=/etc --localstatedir=/var --prefix=/usr/ --enable-lua --enable-geopip 
make
make install-full

验证 Suricata 安装:

suricata -V

步骤 3. 配置 Suricata。

安装后,配置文件位于. 但是,对于我们的基本设置,我们将只关注 Suricata 正在侦听的网络接口以及连接到该接口的 IP 地址:/etc/suricata/suricata.yaml

nano /etc/suricata/suricata.yaml

添加以下几行:

vars:
  # more specific is better for alert accuracy and performance
  address-groups:
    #HOME_NET: "[192.168.0.0/16,10.0.0.0/8,172.16.0.0/12]"
    HOME_NET: "[192.168.77.21]"
    #HOME_NET: "[192.168.0.0/16]"
    #HOME_NET: "[10.0.0.0/8]"
    #HOME_NET: "[172.16.0.0/12]"
    #HOME_NET: "any"

    EXTERNAL_NET: "!$HOME_NET"
    #EXTERNAL_NET: "any"
...

接下来,将接口名称设置为 af-packet:

# Linux high speed capture support
af-packet:
  - interface: enp0s3
...........

定义要使用的 Suricata 规则文件。我们在这个演示中使用默认的 ET 规则:

...
default-rule-path: /var/lib/suricata/rules

rule-files:
  - suricata.rules
...

之后,通过禁用接口大型接收卸载 (LRO)/通用接收卸载 (GRO) 来禁用 Suricata 数据包卸载:

sudo ethtool -K <interface> gro off lro off

输出:

tx-checksum-ip-generic: ongeneric-segmentation-offload: ongeneric-receive-offload: offlarge-receive-offload: off [fixed]

如果启用,请通过运行以下命令禁用:

ethtool -K <interface> gro off lro off

第 4 步。运行 Suricata。

Suricata 可以由systemd服务管理。但在初始化之前,首先指定 Suricata 正在侦听的接口,如下所示:

nano /etc/sysconfig/suricata

添加以下几行:

# Add options to be passed to the daemon
#OPTIONS="-i eth0 --user suricata "
OPTIONS="-i enp0s3 --user suricata "

保存并退出文件,启动并启用 Suricata 以在引导时运行:

sudo systemctl enable --now suricata

要检查 Suricata 是否正在运行,请检查 Suricata 日志:

sudo tail /var/log/suricata/suricata.log

第 5 步。测试 Suricata 规则。

在这个演示中,我们使用默认的 ET Suricata 规则。如果您创建了自己的自定义规则,请务必测试 Suricata 规则是否存在语法错误:

sudo suricata -c /etc/suricata/suricata.yaml -T -v

输出:

26/7/2021 -- 16:46:11 - - Running suricata under test mode
26/7/2021 -- 16:46:11 - - This is Suricata version 5.0.3 RELEASE running in SYSTEM mode
26/7/2021 -- 16:46:11 - - CPUs/cores online: 1
26/7/2021 -- 16:46:11 - - fast output device (regular) initialized: fast.log
26/7/2021 -- 16:46:11 - - eve-log output device (regular) initialized: eve.json
26/7/2021 -- 16:46:11 - - stats output device (regular) initialized: stats.log
26/7/2021 -- 16:46:13 - - 1 rule files processed. 20676 rules successfully loaded, 0 rules failed
26/7/2021 -- 16:46:13 - - Threshold config parsed: 0 rule(s) found
26/7/2021 -- 16:46:13 - - 20679 signatures processed. 1138 are IP-only rules, 3987 are inspecting packet payload, 15324 inspect application layer, 103 are decoder event only26/7/2021 -- 16:46:28 - - Configuration provided was successfully loaded. Exiting.26/7/2021 -- 16:46:28 - - cleaning up signature grouping structure complete

感谢您使用本教程在您的 AlmaLinux 8 系统上安装 Suricata。如需更多帮助或有用信息,我们建议您查看Suricata 官方网站

© 版权声明

相关文章

天猫U特购  京东优惠购        京东优惠    天猫优惠