Skip to content
subuilds.dev

← logbuild #2 passedd402325

OPNsense Intrusion Detection: Detecting and Simulating Real-World Attacks

Learn how to set up OPNsense IDS/IPS with Suricata to detect suspicious network activity. The guide shows real attack examples and safe ways to simulate them, so you can test your setup.

· 15 min read

Introduction#

When you open a service to the internet, someone will probe it. To probe means to test it for weak points.

OPNsense comes with Suricata, an open-source IDS/IPS. An IDS (Intrusion Detection System) watches network traffic for attacks. An IPS (Intrusion Prevention System) also blocks them. Suricata can:

  • Detect suspicious traffic (port scans, brute force, exploits)
  • Alert you about threats
  • Block malicious (harmful) traffic automatically (IPS mode)

This guide covers the IDS setup, real attack patterns, and safe ways to simulate attacks for testing.

In Simple Words#

The problem
When you open a service to the internet, someone will probe it. Without an IDS, you do not see the port scans, the password guessing, or the exploit attempts.
The root cause
Attackers use automatic tools that scan ports and guess passwords. Until you turn on Suricata, nothing compares your traffic with known attack patterns.
The solution
Turn on Suricata in OPNsense and download rulesets. Start in IDS mode, which only alerts. Test it with safe attacks in an isolated lab and tune the rules. Then turn on IPS mode, which blocks.
Think of it like this
IDS is a camera at your door. It records who tries the lock and tells you. IPS is a guard at the same door, who stops that person. Watch with the camera first, so the guard does not stop your friends by mistake.

Prerequisites#

  • OPNsense firewall (version 23.x or newer)
  • Basic networking knowledge
  • A test environment (homelab recommended)
  • Admin access to OPNsense

Part 1: Understanding IDS vs IPS#

IDS (Intrusion Detection System)#

  • Passive: it watches traffic and never blocks
  • Alerts only: it logs suspicious activity
  • No risk of blocking legitimate (good) traffic
  • Best for: learning attack patterns, the first setup

IPS (Intrusion Prevention System)#

  • Active: it drops malicious packets in real time
  • Can give false positives: it may block legitimate traffic. A false positive is an alert on traffic that is not an attack
  • Needs tuning before you use it in production
  • Best for: production environments after IDS tuning

Part 2: Enabling Suricata IDS in OPNsense#

Step 1: Install and Enable Suricata#

  1. Go to Services → Intrusion Detection → Administration
  2. Check Enabled
  3. Leave IPS mode unchecked at first (IDS only)
  4. Choose the interfaces to monitor:
    • WAN - Incoming internet traffic
    • LAN - Internal traffic (optional)
  5. Set Pattern matcher to Hyperscan (the fastest; it needs a compatible CPU)
  6. Click Apply

Step 2: Download Rulesets#

A ruleset is a list of patterns that describe known attacks. OPNsense supports several threat intelligence rulesets.

  1. Go to Services → Intrusion Detection → Administration → Download
  2. Enable rulesets:
Ruleset Description Recommended
ET open/emerging-* Emerging Threats Open Rules Yes (free)
abuse.ch/SSL Blacklist Known malicious SSL certificates Yes (free)
abuse.ch/URLhaus Malicious URL detection Yes (free)
Snort VRT Snort’s official rules Optional (requires registration)
  1. Click Download & Update Rules
  2. Wait until the download finishes (it can take several minutes)

Step 3: Configure Rule Categories#

  1. Go to Services → Intrusion Detection → Administration → Rules
  2. Enable the categories you need:

High Priority (Enable These):

  • emerging-attack_response - Detect successful attacks
  • emerging-exploit - Known exploit attempts
  • emerging-malware - Malware communication
  • emerging-scan - Port scanning activity
  • emerging-web_server - Web application attacks
  • emerging-dos - Denial of service attempts

Medium Priority:

  • emerging-policy - Policy violations
  • emerging-trojan - Trojan activity
  • emerging-worm - Worms that spread
  1. Click Apply after you enable the categories

Step 4: Start the Service#

  1. Go to Services → Intrusion Detection → Administration
  2. Click Apply to save settings
  3. Check that the service is running in Services → Intrusion Detection → Service

Part 3: Real-World Attack Patterns#

Learn what attacks look like. Then you can understand the alerts and tune the rules.

Attack Type 1: Port Scanning#

Attackers look for open ports and running services.

Real-world example:

text
# Attacker runs nmap to discover services
nmap -sS -sV -p 1-65535 target.example.com

What OPNsense sees:

  • Fast connection attempts on many ports
  • SYN packets with no completed handshake
  • One source IP, in a short time

Suricata alerts:

text
[**] ET SCAN Potential SSH Scan [**]
[**] ET SCAN Suspicious inbound to Oracle SQL port 1521 [**]
[**] ET SCAN Potential VNC Scan 5900-5920 [**]

Attack Type 2: SSH Brute Force#

An automatic tool guesses usernames and passwords for SSH. This is called brute force.

Real-world example:

text
# Attacker uses hydra to brute force SSH
hydra -l root -P passwords.txt ssh://target.example.com

What OPNsense sees:

  • Many failed SSH login attempts
  • The same source IP, with many connections in a short time
  • Common usernames (root, admin, ubuntu)

Suricata alerts:

text
[**] ET SCAN Potential SSH Scan OUTBOUND [**]
[**] ET POLICY SSH session in progress on non-standard port [**]

Attack Type 3: Web Application Attacks#

SQL injection, XSS, path traversal, and command injection. In all of them, the attacker hides commands or paths in a web request.

Real-world examples:

SQL Injection:

text
GET /login?user=admin'%20OR%201=1-- HTTP/1.1

Path Traversal:

text
GET /api/files?path=../../../../etc/passwd HTTP/1.1

Command Injection:

text
POST /api/ping HTTP/1.1
host=; cat /etc/passwd

Suricata alerts:

text
[**] ET WEB_SERVER SQL Injection Attempt [**]
[**] ET WEB_SERVER Possible Path Traversal Attempt [**]
[**] ET WEB_SERVER cmd.exe In URI - Possible Command Execution [**]

Attack Type 4: Malware Communication (C2)#

Infected hosts contact servers that the attacker controls. These servers are called C2 (command and control).

What OPNsense sees:

  • Outbound connections to IPs or domains that are known to be bad
  • Unusual DNS queries (domains generated by a DGA, a domain generation algorithm)
  • Beaconing patterns (connections at regular intervals)

Suricata alerts:

text
[**] ET MALWARE Known Malicious User-Agent [**]
[**] ET CNC Feodo Tracker Reported CnC Server [**]
[**] ET POLICY DNS Query to DynDNS Domain [**]

Attack Type 5: Denial of Service (DoS)#

The attacker sends so much traffic that a service can no longer answer.

Types:

  • SYN Flood: a very large number of TCP SYN packets that never complete the handshake
  • UDP Flood: a very large number of UDP packets
  • HTTP Flood: so many HTTP requests that the web server has no resources left

Suricata alerts:

text
[**] ET DOS Possible SYN Flood [**]
[**] ET DOS UDP Amplification Attack Inbound [**]

Part 4: Simulating Attacks Safely#

Setting Up a Safe Test Environment#

Recommended Architecture:

  1. The test lab is an isolated network. An attacker VM (Kali or Parrot) and a target server (Ubuntu) connect through OPNsense, which runs Suricata.
  2. The attacker scans the target with nmap. The scan passes through OPNsense and reaches the target.
  3. Suricata runs in IDS mode. It sees the scan and writes an alert such as ET SCAN, but it does not block.
  4. You read the alerts for one or two weeks. You suppress the false positives and tune the rules.
  5. Then you turn on IPS mode. Suricata now drops the attack packets before they reach the target.
5 / 5

Test Environment Setup#

Option 1: Proxmox/VMware Lab

  1. Create an isolated virtual network (no internet access)
  2. Set up an OPNsense VM as the router and firewall
  3. Set up a target VM (Ubuntu Server with services)
  4. Set up an attacker VM (Kali Linux)

Option 2: Docker-based Lab

bash
# Create isolated network
docker network create --subnet=172.20.0.0/16 ids-test-net

# Run vulnerable target (intentionally vulnerable)
docker run -d --name target \
  --network ids-test-net \
  --ip 172.20.0.10 \
  vulnerables/web-dvwa

# Run attacker tools
docker run -it --name attacker \
  --network ids-test-net \
  --ip 172.20.0.100 \
  kalilinux/kali-rolling

Simulation 1: Port Scan Detection#

On Attacker Machine (Kali):

bash
# Install nmap if not present
apt update && apt install -y nmap

# Basic TCP SYN scan
nmap -sS 10.10.10.50

# Service version detection
nmap -sV -p 22,80,443 10.10.10.50

# Aggressive scan (more detectable)
nmap -A -T4 10.10.10.50

Expected OPNsense Alerts:

  1. Go to Services → Intrusion Detection → Alerts
  2. Look for:
    • ET SCAN alerts
    • GPL SCAN nmap alerts
    • Several source IPs, if you scan from different hosts

Verify Detection:

bash
# On OPNsense (via SSH)
grep -i "scan" /var/log/suricata/eve.json | tail -20

Simulation 2: SSH Brute Force Detection#

On Target Machine (make sure SSH is enabled):

bash
# Install OpenSSH if not present
apt install openssh-server
systemctl start sshd

On Attacker Machine:

bash
# Install hydra
apt install -y hydra

# Create small password list for testing
cat > /tmp/passwords.txt << 'EOF'
password
123456
admin
root
toor
letmein
EOF

# Run controlled brute force (limited attempts)
hydra -l root -P /tmp/passwords.txt \
  -t 4 -w 5 \
  ssh://10.10.10.50

Expected OPNsense Alerts:

  • ET SCAN Potential SSH Scan
  • ET POLICY Possible SSH brute force attempt

Simulation 3: Web Application Attack Detection#

On Target Machine (run a simple web server):

bash
# Quick Python web server
mkdir -p /var/www/test
echo "<?php echo 'Hello'; ?>" > /var/www/test/index.php
cd /var/www/test && python3 -m http.server 80

On Attacker Machine:

bash
# SQL Injection attempt
curl "http://10.10.10.50/login?user=admin'%20OR%201=1--"

# Path traversal attempt
curl "http://10.10.10.50/files?path=../../../../etc/passwd"

# XSS attempt
curl "http://10.10.10.50/search?q=<script>alert('xss')</script>"

# Using Nikto web scanner
apt install -y nikto
nikto -h http://10.10.10.50

Expected OPNsense Alerts:

  • ET WEB_SERVER SQL Injection Attempt
  • ET WEB_SERVER Possible Path Traversal
  • ET WEB_SPECIFIC_APPS various alerts

Simulation 4: Malicious Traffic Detection#

Test with indicators that are known to be bad (safe test domains):

bash
# Test DNS query to known test domain
# EICAR is the standard antivirus test file
nslookup eicar.com

# Attempt to download EICAR test file
# This is a safe, non-malicious test file recognized by security tools
curl -O https://secure.eicar.org/eicar.com.txt

Expected OPNsense Alerts:

  • Test malware signature alerts
  • Possible ET MALWARE or ET POLICY alerts

Simulation 5: DoS Pattern Detection#

On Attacker Machine:

bash
# Install hping3
apt install -y hping3

# SYN flood simulation (LOW RATE - for testing only)
# -S: SYN flag, -p: port, -i: interval (u100 = 100 microseconds)
hping3 -S -p 80 -i u1000 --count 100 10.10.10.50

# UDP flood simulation (LOW RATE)
hping3 --udp -p 53 -i u1000 --count 100 10.10.10.50

Expected OPNsense Alerts:

  • ET DOS alerts
  • GPL DOS alerts
  • High packet rate warnings

Part 5: Analyzing and Responding to Alerts#

Viewing Alerts in OPNsense#

  1. Real-time Alerts: Services → Intrusion Detection → Alerts
  2. Alert Details: timestamp, source and destination IP, alert message, SID (the ID of the rule), severity

Understanding Alert Severity#

Severity Meaning Action
1 (High) Active attack or compromise Immediate investigation
2 (Medium) Suspicious activity Investigate within hours
3 (Low) Informational or policy violation Review during maintenance

Alert Triage Workflow#

Triage means you sort the alerts by how urgent they are. For each new alert, ask these four questions in order:

  1. A new alert arrives. Ask four questions, in this order.
  2. Where does it come from? An internal source IP can mean a compromised host. An external one is an attack attempt.
  3. Which service is the target? A critical service is high priority. A service that does not exist is low priority noise.
  4. Is it a known false positive? If yes, add it to the suppress list. If no, investigate further.
  5. Did the attack work? Check the target’s logs and the service. If yes, start incident response. If it was blocked or failed, keep watching.
5 / 5

Creating Custom Rules#

Add your own rules for threats that are specific to your environment.

  1. Go to Services → Intrusion Detection → Administration → User defined
  2. Add a custom rule:
text
# Block specific malicious IP
drop ip 192.168.1.100 any -> any any (msg:"Blocked malicious IP"; sid:9000001; rev:1;)

# Alert on access to sensitive internal path
alert http any any -> $HOME_NET any (msg:"Access to admin panel"; content:"/admin"; http_uri; sid:9000002; rev:1;)

# Alert on specific user-agent (known bad bot)
alert http any any -> $HOME_NET any (msg:"Known bad crawler"; content:"BadBot"; http_user_agent; sid:9000003; rev:1;)

Suppressing False Positives#

When legitimate traffic triggers alerts, tell Suricata to stop alerting for that case:

  1. Go to Services → Intrusion Detection → Administration → User defined
  2. Add a suppression rule:
text
# Suppress by signature ID
suppress gen_id 1, sig_id 2100498

# Suppress by source IP
suppress gen_id 1, sig_id 2100498, track by_src, ip 192.168.1.100

# Suppress by destination IP
suppress gen_id 1, sig_id 2100498, track by_dst, ip 10.0.0.50

Part 6: Enabling IPS (Active Blocking)#

Do this after you have tuned the IDS and know your traffic patterns:

Step 1: Review Alert History#

  1. Check that there were no critical false positives in the past 1-2 weeks
  2. Write down the rules that need suppression
  3. Check that legitimate services are not flagged

Step 2: Enable IPS Mode#

  1. Go to Services → Intrusion Detection → Administration
  2. Check IPS mode
  3. Set Default action to Alert at first
  4. Click Apply

Step 3: Gradually Enable Blocking#

  1. Go to the Rules tab
  2. Set the categories you trust most to Drop:
    • emerging-exploit
    • emerging-malware
    • emerging-attack_response
  3. Keep the rules you trust less on Alert:
    • emerging-scan
    • emerging-policy

Step 4: Monitor for Issues#

After you enable IPS:

  • Watch for legitimate traffic that gets blocked
  • Check application logs for connection failures
  • Review IPS drop logs regularly

Part 7: Integration with Monitoring#

Sending Alerts to Syslog#

  1. Go to Services → Intrusion Detection → Administration
  2. Enable Send alerts to system log
  3. Set the syslog destination in System → Settings → Logging / targets

Integration with Grafana/Prometheus#

If you have Grafana monitoring (see Monitoring Proxmox with Grafana Stack):

Export Suricata stats to Prometheus:

  1. Install suricata-exporter on OPNsense or a separate host
  2. Set up scraping in Prometheus
  3. Build a Grafana dashboard for IDS metrics

Key metrics to track:

  • Total alerts per hour
  • Alerts by severity
  • Top source IPs
  • Most triggered rules

Email Notifications#

  1. Go to System → Settings → Notifications
  2. Enter the SMTP settings
  3. Go to Services → Intrusion Detection → Administration
  4. Enable email alerts for high-severity events

Part 8: Best Practices#

Regular Maintenance#

Task Frequency
Update rulesets Weekly (automated)
Review alerts Daily
Tune false positives As needed
Review blocked traffic (IPS) Daily
Full security audit Monthly

Performance Considerations#

  • CPU: Suricata uses a lot of CPU. Watch the CPU usage
  • Memory: give it enough RAM to process the rules
  • Interfaces: only monitor what you need
  • Rules: disable rules for services you don’t run

What NOT to Do#

  1. Don’t enable IPS right away — learn your traffic first
  2. Don’t ignore alerts — alerts that nobody reads are useless
  3. Don’t block everything — false positives break things
  4. Don’t skip updates — threats change all the time
  5. Don’t test on production — use isolated environments

Conclusion#

OPNsense with Suricata gives a homelab or a small business the kind of intrusion detection that large companies use.

  1. Start with IDS to learn traffic patterns
  2. Use quality rulesets (Emerging Threats recommended)
  3. Test safely in isolated environments
  4. Tune rules to reduce false positives
  5. Move to IPS once you trust your rules
  6. Keep monitoring — detection is useless if nobody responds

IDS/IPS is one layer. Combine it with firewall rules, system hardening, patching, and security awareness.

References#