前言

centos-stream-9的配置跳转blog:centos-stream9arm基础配置

简介

Suricata是一个免费、开源、成熟、快速且强大的网络威胁检测引擎。可以被用作IDS引擎(只能检测不能阻断)、IPS(可以检测也可以阻断)、网络安全监控、离线pcap处理工具。 Suricata 使用强大而广泛的规则和签名语言检查网络流量,并具有强大的 Lua 脚本支持以检测复杂威胁。

环境配置

CentOS: CentOS-Stream-9, ARM, Parallels虚拟机

CentOS操作用户:在root用户下进行suricata 部署

CentOS源:阿里源

依赖安装

安装依赖

dnf makecache
dnf clean all
dnf install epel-release -y
dnf update -y
dnf install diffutils file-devel gcc jansson-devel make nss-devel libyaml-devel libcap-ng-devel libpcap-devel pcre-devel python3 python3-pyyaml rust-toolset zlib-devel curl wget tar lua lua-devel lz4-devel -y

报错

Unable to find a match: file-devel、 jansson-devel、libyaml-devel、lua-devel


添加CRB仓库

vim /etc/yum.repos.d/centos.repo

最后一行加入

[crb]
name = =CentOS-$releasever - CRB - mirrors.aliyun.com
#failovermethod=priority
baseurl=https://mirrors.aliyun.com/centos-stream/$stream/CRB/$basearch/os/
     http://mirrors.aliyuncs.com/centos-stream/$stream/CRB/$basearch/os/
     http://mirrors.cloud.aliyuncs.com/centos-stream/$stream/CRB/$basearch/os/
gpgcheck=1
gpgkey=https://mirrors.aliyun.com/centos/RPM-GPG-KEY-CentOS-Official
dnf makecache
yum makecache

用crb下载

dnf --enablerepo=crb install <包名> -y

可以通过https://pkgs.org/来查看要下载的包,是属于哪个仓库源的

 dnf --enablerepo=crb install file-devel jansson-devel libyaml-devel lua-devel -y

安装suricata

dnf install suricata

安装成功

systemctl start suricata
systemctl enable suricata

修改配置、规则

修改配置

vim /etc/suricata/suricata.yaml 

添加IP(本机IP)、网口(需要探测的网卡,enp0s5)、nfq(为了能开启IPS)

更新规则

suricata-update

测试

kali发起flood攻击

截图左边是centos,右边是kali。kali对centos发起攻击

先不开启suricata,用wireshark抓包看一下流量的走向

可以看到收到了很多的icmp包,伪装成了不同的IP。kali多攻击一会,Wireshark直接崩溃了🐶

启用suricata,IDS模式

开启IDS模式,仅能检测攻击,不能拦截

suricata -c /etc/suricata/suricata.yaml -i enp0s5

启用suricata,IPS模式

开启IPS模式,可以检测也可以拦截。

查看Suricata是否支持IPS模式

suricata --build-info

如果输出有: NFQueue support: yes 表示支持IPS模式

-q让Suricata以IPS模式运行,相当于snort的inline模式。不过还需要设置一下iptablesNFQUEUE,让Suricata能访问到相应的数据包,最简单的方法是:

iptables -I INPUT -p tcp -j NFQUEUE
iptables -I OUTPUT -p tcp -j NFQUEUE
suricata -c /etc/suricata/suricata.yaml -q 0

suricata用完之后,再清除这个规则,不然会影响正常通信

iptables -F

参考文章

https://suricata.io/

https://suricata.readthedocs.io/en/latest/

https://suricata.readthedocs.io/en/latest/install.html

https://www.digitalocean.com/community/tutorials/how-to-install-suricata-on-centos-8-stream

https://bynss.com/linux/761151.html

https://suricata.readthedocs.io/en/latest/quickstart.html

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

https://blog.csdn.net/Chaowanq/article/details/121563114

https://maskray.me/blog/2013-07-26-ids-ips-with-suricata

评论