Report this

What is the reason for this report?

How to install and configure Suricata on ubuntu 22.04

Posted on December 26, 2024

I wanted to install, configure and test intrusion detection system (IDS) intrusion prevention system (IPS) Suricata on 22.04



This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Heya,

Step 1: Update Your System

Ensure your system is up-to-date:

sudo apt update && sudo apt upgrade -y

tep 2: Install Suricata

  1. Add the Suricata PPA:
sudo add-apt-repository ppa:oisf/suricata-stable
sudo apt update
  1. Install Suricata:
sudo apt install suricata -y
  1. Verify Installation: Check the installed Suricata version:
suricata --version

Step 3: Configure Suricata

  1. Edit the Configuration File: The main configuration file is located at /etc/suricata/suricata.yaml. Open it for editing:
sudo nano /etc/suricata/suricata.yaml

Configure network interfaces (e.g., eth0):

af-packet:
  - interface: eth0
    cluster-id: 99
    cluster-type: cluster_flow
    defrag: yes
  1. Download and Update Rules: Suricata uses rules to detect threats. Download the Emerging Threats ruleset:
sudo suricata-update

After downloading, restart Suricata to apply rules:

sudo systemctl restart suricata

Step 4: Set Suricata in IDS Mode (Monitor Traffic)

Suricata can run in IDS mode by default, capturing traffic without blocking it. To enable IDS:

  • Use tcpdump or af-packet for traffic mirroring, depending on your configuration.

Start Suricata with:

sudo suricata -c /etc/suricata/suricata.yaml -i eth0

Step 5: Enable IPS Mode (Block Traffic)

To enable IPS mode:

  1. Install Required Tools:
sudo apt install iptables-persistent
  1. Modify suricata.yaml: Enable the NFQUEUE section:
nfqueue:
  - id: 0
    bypass: no
  1. Configure iptables: Redirect traffic to Suricata:
sudo iptables -I INPUT -j NFQUEUE --queue-num 0
sudo iptables -I FORWARD -j NFQUEUE --queue-num 0
  1. Restart Suricata:
sudo systemctl restart suricata

Heya, @setupmybusiness

You can also check our tutorial on how to install Suricata on Ubuntu 22.04, the process will be fairly the same:

https://www.digitalocean.com/community/tutorials/how-to-install-suricata-on-ubuntu-20-04

Regards

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Get started for free

Sign up and get $200 in credit for your first 60 days with DigitalOcean.*

*This promotional offer applies to new accounts only.