Question

How to install and configure Suricata on ubuntu 22.04

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


Submit an answer


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!

Sign In or Sign Up to Answer

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.

alexdo
Site Moderator
Site Moderator badge
December 29, 2024

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

KFSys
Site Moderator
Site Moderator badge
December 27, 2024

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

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Become a contributor for community

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

DigitalOcean Documentation

Full documentation for every DigitalOcean product.

Resources for startups and SMBs

The Wave has everything you need to know about building a business, from raising funding to marketing your product.

Get our newsletter

Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.

New accounts only. By submitting your email you agree to our Privacy Policy

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.