Suricata IDS: Unterschied zwischen den Versionen

Aus Xinux Wiki
Zur Navigation springen Zur Suche springen
Zeile 45: Zeile 45:
 
*apt install suricata
 
*apt install suricata
  
=Suricata minimale Konfiguration=
+
=Suricata Konfiguration=
  
 
* '''vim /etc/suricata/suricata.yaml'''
 
* '''vim /etc/suricata/suricata.yaml'''
 
%YAML 1.1
 
---
 
# Variablen für die Adressgruppen festlegen
 
vars:
 
  address-groups:
 
    LAN: "[172.17.113.0/24]"
 
    DMZ: "[10.88.113.0/24]"
 
    SERVER: "[172.16.113.0/24]"
 
    INT: "[$LAN,$DMZ,$SERVER]"
 
    HOME_NET: "$INT"
 
    EXTERNAL_NET: "!$INT"
 
 
# Standard-Log-Verzeichnis
 
default-log-dir: /var/log/suricata/
 
 
# Statistiken aktivieren
 
stats:
 
  enabled: yes
 
  interval: 8
 
 
# Ausgaben konfigurieren
 
outputs:
 
  - fast:
 
      enabled: yes
 
      filename: fast.log
 
      append: yes
 
  - alert-debug:
 
      enabled: yes
 
      filename: alert-debug.log
 
      append: yes
 
  - stats:
 
      enabled: yes
 
      filename: stats.log
 
      append: yes
 
      totals: yes
 
      threads: no
 
 
# Logging-Einstellungen
 
logging:
 
  default-log-level: notice
 
  outputs:
 
  - console:
 
      enabled: yes
 
  - file:
 
      enabled: yes
 
      level: info
 
      filename: suricata.log
 
 
# Netzwerkschnittstellen konfigurieren
 
af-packet:
 
  - interface: enp0s3
 
    threads: auto
 
    cluster-id: 97
 
    cluster-type: cluster_flow
 
    defrag: yes
 
  - interface: enp0s8
 
    threads: auto
 
    cluster-id: 98
 
    cluster-type: cluster_flow
 
    defrag: yes
 
  - interface: enp0s9
 
    threads: auto
 
    cluster-id: 99
 
    cluster-type: cluster_flow
 
    defrag: yes
 
  - interface: enp0s10
 
    threads: auto
 
    cluster-id: 100
 
    cluster-type: cluster_flow
 
    defrag: yes
 
 
 
# PID-Datei
 
pid-file: /var/run/suricata.pid
 
 
# Coredump-Einstellungen
 
coredump:
 
  max-dump: unlimited
 
 
# Host-Modus
 
host-mode: auto
 
 
# Unix-Befehlseingabe konfigurieren
 
unix-command:
 
  enabled: yes
 
  filename: /var/run/suricata-command.socket
 
 
# Engine-Analyse-Einstellungen
 
engine-analysis:
 
  rules-fast-pattern: yes
 
  rules: yes
 
 
# Defragmentierungseinstellungen
 
defrag:
 
  memcap: 32mb
 
  hash-size: 65536
 
  trackers: 65535
 
  max-frags: 65535
 
  prealloc: yes
 
  timeout: 60
 
 
# Standardregelverzeichnis
 
default-rule-path: /etc/suricata/rules
 
 
# Regel-Dateien
 
rule-files:
 
  - local.rules
 
 
# Klassifikationsdatei
 
classification-file: /etc/suricata/classification.config
 
 
# Referenzkonfigurationsdatei
 
reference-config-file: /etc/suricata/reference.config
 
 
==Local Rules==
 
 
* ''flow:to_server'' bei ICMP ist wichtig, damit ICMP '''nicht''' als [https://forum.suricata.io/t/i-can-only-see-the-first-alert-of-a-rule/901 IP-only] verstanden wird
 
* '''vim /etc/suricata/rules/local.rules'''
 
 
alert icmp any any -> any any (msg:"ICMP Test"; flow:to_server; sid:1;)
 
alert tcp any any -> any any (flags: S; msg: "SYN packet"; sid:2;)
 
 
* https://suricata.readthedocs.io/en/suricata-6.0.0/rules/
 
 
==Suricata starten==
 
* Der Systemd Service ist leider verbuggt
 
* manchmal muss die PID File manuell gelöscht werden bevor es starten kann
 
* '''rm /var/run/suricata.pid'''
 
* Stattdessen diesen Befehl verwenden
 
* '''suricata -D --af-packet -c /etc/suricata/suricata.yaml'''
 
 
== Suricata stoppen ==
 
 
* Suricata kann über einen UNIX Socket gesteuert werden
 
* Ein Python-Interface dafür bietet '''suricatasc'''
 
* '''suricatasc -c shutdown'''
 
* '''suricatasc -c reload-rules'''
 
 
==check==
 
*tail -f /var/log/suricata/fast.log
 

Version vom 5. Mai 2026, 16:54 Uhr

Debian Template

Vorbereitungen

  • VirtualBox Server-Vorlage klonen

Netzkonfiguration DNS-Server (DMZ)

Parameter Wert Erläuterung
1. Netzwerk (NIC) SERVER Interne
IP 10.2XX.1.4 Statische IP
CIDR 24 Classless Inter-Domain Routing Präfixlänge
GW 10.2XX.1.1 GATEWAY
NS 10.88.2XX.21 Resolver
FQDN suricata-ids.it2XX.int Fully Qualified Domain Name
SHORT suricata-ids Short Name
DOM it2XX.int Domain Name
2. Netzwerk (NIC) DMZ Intern Promisc
Anpassen des Templates

oder

Mit Skript
  • debian-setup.sh -f suricata-ids.it2XX.int -a 10.2XX.1.4/24 -g 10.2XX.1.1 -n 10.88.2XX.21

Rebooten und einloggen

  • systemctl reboot

Anpassen des SNIFF Interfaces

cat<<HERE >> /etc/network/interfaces
 auto enp0s8
  iface enp0s8 inet manual
  post-up ip link set enp0s8 promisc on
HERE

Installation

  • apt install suricata

Suricata Konfiguration

  • vim /etc/suricata/suricata.yaml