Install and Configure Suricata on Ubuntu/Centos/Linux
☰ In this chapter, you will learn
- How to Install Suricata on Linux
- Suricata Configuration
- Important Suricata Commands
Suricata is also a Network Intrusion Detection System, like Snort , which scans and filters the packages in a network system and blocks them immediately if found suspicious.
This tool finds threats in real-time and immediately blocks them if malicious activity is detected.
If you are running a VPS server with any Linux distribution such as Ubuntu, CentOS, or any other distro, you must install and configure Suricata IDS (Intrusion Detection System) to protect your server network.
Some more about Suricata
Suricata is an open-source, popular, and widely used intrusion detection and prevention system that helps improve security on Linux servers. It generates log events, triggers alerts, and drops traffic if it detects suspicious packets traveling inside the network.
After being well-configured, Suricata can convert into an Intrusion Prevention System that automatically blocks suspicious packets, drops traffic, and generates log files. Just configure Suricata and forget it. It will automatically handle the rest and keep protecting your network.
How to Install and Configure Suricata on Ubuntu, CentOS, and other Linux Distribution?
Installation
Ubuntu:
sudo apt update && sudo apt upgrade
sudo apt install -y suricata
CentOS
yum install epel-release yum-plugin-copr
$yum copr enable @oisf/suricata-7.0
$yum install suricata
sudo yum -y install epel-release
$sudo yum -y install suricata
Check Suricata Version.
suricata -V
Configure Suricata
To configure Suricata, open /etc/suricata/suricata.yaml in your desired text editor and Configure it as follows:ip -p -j route show default
Output: [ { "dst": "default", "gateway": "172.17.224.1", "dev": "eth0", "protocol": "kernel", "flags": [ ] } ]
sudo nano /etc/suricata/suricata.yaml
sudo nano /etc/suricata/suricata.yaml
af-packet: - interface: eth0 cluster-id: 99 cluster-type: cluster_flow defrag: yes use-mmap: yes tpacket-v3: yes
sudo suricata-update
sudo systemctl restart suricata
Check Log Files
Make sure Suricata is running and working, check the log files.
sudo tail /var/log/suricata/suricata.log
4/4/2024 -- 10:14:58 -- eve-log output device (regular) initialized: eve.json 4/4/2024 -- 10:14:58 - - stats output device (regular) initialized: stats.log 4/4/2024 -- 10:14:58 - - [ERRCODE: SC_ERR_NO_RULES(42)] - No rule files match the pattern /etc/suricata/rules/suricata.rules 4/4/2024 -- 10:14:58 - - [ERRCODE: SC_ERR_NO_RULES_LOADED(43)] - 1 rule files specified, but no rules were loaded! 4/4/2024 -- 10:14:58 - - Threshold config parsed: 0 rule(s) found 4/4/2024 -- 10:14:58 - - 0 signatures processed. 0 are IP-only rules, 0 are inspecting packet payload, 0 inspect application layer, 0 are decoder event only 4/4/2024 -- 10:14:58 - - Going to use 8 thread(s) 4/4/2024 -- 10:14:58 - - Using unix socket file '/var/run/suricata-command.socket' 4/4/2024 -- 10:14:58 - - all 8 packet processing threads, 4 management threads initialized, engine started. 4/4/2024 -- 10:14:59 - - All AFP capture threads are running.
To see Statistics, execute the following command:
sudo tail -f /var/log/suricata/stats.log
flow.mgr.full_hash_pass | Total | 4 flow.spare | Total | 9213 flow.mgr.rows_maxlen | Total | 1 flow.mgr.flows_checked | Total | 19 flow.mgr.flows_notimeout | Total | 6 flow.mgr.flows_timeout | Total | 13 flow.mgr.flows_evicted | Total | 13 tcp.memuse | Total | 4849664 tcp.reassembly_memuse | Total | 786432 flow.memuse | Total | 7474304
Test Suricata
After configuring the Suricata IDS, it's important to test it to ensure it is working properly.
curl http://testmynids.org/uid/index.html
uid=0(root) gid=0(root) groups=0(root)
grep 2100498 /var/log/suricata/fast.log
For IPv6:For IPv4:10/21/2021-18:35:54.950106 [**] [1:2100498:7] GPL ATTACK_RESPONSE id check returned root [**] [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 2600:9000:2000:4400:0018:30b3:e400:93a1:80 -> 2001:DB8::1:34628
10/21/2021-18:35:57.247239 [**] [1:2100498:7] GPL ATTACK_RESPONSE id check returned root [**] [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} 204.246.178.81:80 -> 203.0.113.1:36364
Some important Suricata commands.
# | Title | Command |
---|---|---|
1 | Check Status |
|
2 | Enable services |
|
3 | Start services |
|
4 | Stop services |
|
5 | Update |
|
6 | Validate |
|
7 | Configuration File |
|
8 | Log File |
|
Summary
In this tutorial, I've explained how to install and configure Suricata on your Ubuntu or CentOS server. Suricata is a powerful intrusion detection tool that protects server networks from various threats. It filters network packets in real-time, blocks suspicious packets when detected, and immediately suspend the source traffic.