Skip to content

Instantly share code, notes, and snippets.

@williamzujkowski
Created November 3, 2025 19:43
Show Gist options
  • Select an option

  • Save williamzujkowski/ac871dd21758d0f1f44986c4ee6e21e7 to your computer and use it in GitHub Desktop.

Select an option

Save williamzujkowski/ac871dd21758d0f1f44986c4ee6e21e7 to your computer and use it in GitHub Desktop.
Suricata IDS/IPS Installation and Initial Configuration - Ubuntu 24.04 homelab setup with rule management
#!/bin/bash
# Suricata IDS/IPS Installation and Initial Configuration
# For Ubuntu 24.04 - Homelab Network Traffic Analysis Setup
# ============================================================================
# Installation
# ============================================================================
# Install on Ubuntu 24.04
sudo add-apt-repository ppa:oisf/suricata-stable
sudo apt update
sudo apt install suricata jq
# Verify installation
suricata --build-info
# Enable Suricata service
sudo systemctl enable suricata
sudo systemctl start suricata
# ============================================================================
# Initial Configuration - /etc/suricata/suricata.yaml
# ============================================================================
cat << 'YAML_CONFIG' | sudo tee -a /etc/suricata/suricata.yaml
# Network interfaces
af-packet:
- interface: ens19f1 # Mirror interface
cluster-id: 99
cluster-type: cluster_flow
defrag: yes
use-mmap: yes
tpacket-v3: yes
ring-size: 200000
# Home network configuration
vars:
address-groups:
HOME_NET: "[10.0.0.0/8,192.168.0.0/16,172.16.0.0/12]"
EXTERNAL_NET: "!$HOME_NET"
DNS_SERVERS: "[10.0.1.1,1.1.1.1,8.8.8.8]"
HTTP_SERVERS: "$HOME_NET"
SMTP_SERVERS: "$HOME_NET"
SQL_SERVERS: "$HOME_NET"
port-groups:
HTTP_PORTS: "80,443,8080,8443"
SHELLCODE_PORTS: "!80"
SSH_PORTS: 22
# Performance tuning
threading:
set-cpu-affinity: yes
cpu-affinity:
- management-cpu-set:
cpu: [ 0 ]
- receive-cpu-set:
cpu: [ 1,2,3,4 ]
- worker-cpu-set:
cpu: [ 5,6,7,8 ]
# Enable EVE JSON output
outputs:
- eve-log:
enabled: yes
filetype: regular
filename: eve.json
types:
- alert
- http
- dns
- tls
- files
- ssh
- flow
YAML_CONFIG
# ============================================================================
# Rule Management with Suricata-Update
# ============================================================================
# Configure rule sources
sudo suricata-update update-sources
# Enable Emerging Threats Open rules
sudo suricata-update enable-source et/open
# Enable additional sources
sudo suricata-update enable-source tgreen/hunting
sudo suricata-update enable-source sslbl/ssl-fp-blacklist
sudo suricata-update enable-source oisf/trafficid
# Update rules
sudo suricata-update
# Schedule automatic updates
cat << 'EOF' | sudo tee /etc/cron.daily/suricata-update
#!/bin/bash
/usr/bin/suricata-update
/bin/systemctl reload suricata
EOF
sudo chmod +x /etc/cron.daily/suricata-update
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment