Geavanceerd
Zoeken inInstallatiegidsen
Zo zoek je
  • Plak een foutmelding tussen aanhalingstekens, bijv. "permission denied", om de oplossingstabel te vinden.
  • Kies een gebied en een deel van de gids (installeren, eerste instellingen, dagelijks gebruik, beveiliging, oplossingen) om direct naar de juiste stap te gaan.
  • "twee woorden" vindt precies die zin.
  • Gewone woorden vinden namen, teksten en voorbeelden.
  • ↑ ↓ bewegen · Enter openen · Esc sluiten · / zoeken
Probeer:

Gids 71Suricata · Security

Install and set up Suricata (network IDS/IPS)

Suricata reads network traffic and finds attacks and suspicious activity — exploit attempts, malware callbacks, scans, policy violations — with tens of thousands of signatures. It also writes rich logs (DNS, HTTP, TLS, flows) that are gold for incident response. It runs as an IDS (watch and alert) or IPS (inline, block). This guide installs Suricata on RHEL and Ubuntu, sets the interface and home network, loads the ET Open rules with suricata-update, tests an alert, adds a local rule, and sends the JSON logs to your SIEM.

  • 11 Lessen
  • 12 Commando's

Dit deel is nog niet vertaald. Je ziet de Engelse tekst.

$ als gewone gebruiker# als root (of met sudo)

71.1

Know it before you install

Suricata captures packets (AF_PACKET on Linux), rebuilds flows and protocols, and matches rules like alert http any any -> $HOME_NET any (msg:"…"; content:"…"; sid:…;). Everything is logged as JSON in EVE (eve.json): alerts, DNS queries, HTTP requests, TLS handshakes, flows.

ItemValue
Packagessuricata (RHEL: EPEL or OISF COPR; Ubuntu: OISF PPA)
Servicesuricata.service
Config/etc/suricata/suricata.yaml; interface options in /etc/sysconfig/suricata (RHEL) or /etc/default/suricata (Ubuntu)
Rules/var/lib/suricata/rules/suricata.rules (made by suricata-update), your own in /etc/suricata/rules/local.rules
Logs/var/log/suricata/eve.json, fast.log, stats.log, suricata.log
Where to runon a host that sees the traffic: a gateway, a SPAN/mirror port or a TAP

71.2

Install on RHEL, Rocky, Alma and Fedora

dnf -y install epel-release
dnf -y install suricata
suricata --build-info | head -3

For the newest stable version use the OISF COPR: dnf copr enable @oisf/suricata-8.0 before the install.

71.3

Install on Ubuntu and Debian

apt-get install -y software-properties-common
add-apt-repository -y ppa:oisf/suricata-stable
apt-get update
apt-get install -y suricata jq

71.4

First configuration: interface, home network, rules

Find the interface that sees the traffic (ip -br link), then set it and your networks:

/etc/suricata/suricata.yaml (parts to change)
vars:
  address-groups:
    HOME_NET: "[10.0.0.0/8,192.168.0.0/16]"
    EXTERNAL_NET: "!$HOME_NET"
 
af-packet:
  - interface: eth0
    cluster-id: 99
    cluster-type: cluster_flow
    defrag: yes
 
default-rule-path: /var/lib/suricata/rules
rule-files:
  - suricata.rules
  - /etc/suricata/rules/local.rules
 
community-id: true
/etc/sysconfig/suricata
OPTIONS="--af-packet=eth0 --user suricata"

(On Ubuntu the same idea is in /etc/default/suricata: IFACE=eth0.)

SettingWhy
HOME_NETYour networks — most rules use it to know inside from outside. Wrong value = missed or wrong alerts.
af-packet interfaceWhere Suricata listens.
rule-filesThe ET Open rules from suricata-update + your own local rules.
community-id: trueA flow ID that is the same in Suricata, Zeek and many SIEMs — easy correlation.

Turn off NIC offloading on the capture interface (offloading changes packets before Suricata sees them), get the rules, test the config, start:

ethtool -K eth0 gro off lro off
suricata-update
suricata-update list-sources
touch /etc/suricata/rules/local.rules
suricata -T -c /etc/suricata/suricata.yaml -v
Notice: suricata: Configuration provided was successfully loaded. Exiting.
systemctl enable --now suricata

71.5

Test an alert

A harmless test URL returns text that matches an old rule:

curl -s http://testmynids.org/uid/index.html
uid=0(root) gid=0(root) groups=0(root)
tail -n 1 /var/log/suricata/fast.log
[**] [1:2100498:7] GPL ATTACK_RESPONSE id check returned root [**] [Classification: Potentially Bad Traffic] [Priority: 2] {TCP} …
jq -c 'select(.event_type=="alert") | {ts:.timestamp, sig:.alert.signature, src:.src_ip, dst:.dest_ip}' /var/log/suricata/eve.json | tail -3

71.6

Your own rules and tuning

/etc/suricata/rules/local.rules
alert ssh $EXTERNAL_NET any -> $HOME_NET 22 (msg:"LOCAL SSH from outside to internal host"; flow:to_server,established; threshold:type limit, track by_src, count 1, seconds 600; sid:9000001; rev:1;)
alert dns $HOME_NET any -> any any (msg:"LOCAL DNS query to known bad domain"; dns.query; content:"bad-example.test"; nocase; sid:9000002; rev:1;)

Use SIDs from 9,000,000 upward for your own rules. Turn off noisy rules in a disable.conf (one SID or regex per line) and apply it at every update:

echo "2013504" >> /etc/suricata/disable.conf
suricata-update --disable-conf /etc/suricata/disable.conf
suricatasc -c reload-rules

Commando's in deze les

71.7

Daily use: the commands and the real uses

systemctl status suricata
tail -f /var/log/suricata/fast.log
jq -r 'select(.event_type=="alert") | .alert.signature' /var/log/suricata/eve.json | sort | uniq -c | sort -rn | head
jq -r 'select(.event_type=="dns" and .dns.type=="query") | .dns.rrname' /var/log/suricata/eve.json | sort | uniq -c | sort -rn | head
tail -n 30 /var/log/suricata/stats.log | grep -E 'capture.kernel_(packets|drops)'
suricata-update

Run suricata-update daily (a systemd timer or cron) — new threats get new rules every day.

Real uses at work:

  • Network detection at the internet edge or between zones (IDS); alerts to Wazuh, Elastic or Splunk via eve.json.
  • Incident response: who talked to which domain/IP, when (DNS, TLS and flow logs).
  • Inline blocking (IPS) with NFQUEUE on a Linux gateway — start in IDS mode first.

71.8

Make it safe

Security checklist:

  • Correct HOME_NET; capture on the right interface (or a mirror port).
  • Daily rule updates; tune noise with disable.conf and thresholds, not by turning the IDS off.
  • Ship eve.json to a central SIEM (Fluent Bit, Filebeat, Wazuh agent); rotate local logs.
  • Watch capture.kernel_drops — dropped packets mean missed attacks (more CPU threads, workers mode).
  • IPS mode only after testing; a fail-open plan if Suricata stops.

71.9

Update and remove

dnf -y upgrade suricata
apt-get install --only-upgrade -y suricata
suricata -T -c /etc/suricata/suricata.yaml
systemctl restart suricata
dnf -y remove suricata

71.10

Fix common problems

ProblemCauseFix
No alerts at allWrong interface, no rules loaded, or the host does not see the traffic.suricata.log shows loaded rules; check the interface; test with testmynids.org.
No rule files match the patternsuricata-update not run or wrong default-rule-path.Run suricata-update; path /var/lib/suricata/rules.
Many capture.kernel_dropsNot enough CPU or wrong capture settings.More threads (threads in af-packet), cluster_flow, faster CPU.
Alerts with odd checksum issuesNIC offloading.ethtool -K IFACE gro off lro off.
Too many alertsDefault rule set + wrong HOME_NET.Fix HOME_NET; disable noisy SIDs; thresholds.
suricata -T failsYAML indentation or unknown key.Read the line in the error; YAML uses spaces only.

71.11

Next steps

1Why is the HOME_NET setting so important?

Most rules decide inside vs. outside with it; a wrong value gives missed or false alerts.

2How often should you run suricata-update, and why?

Daily — new threats get new signatures every day.

Alle commando's in dit hoofdstuk