]> git.ipfire.org Git - ipfire-2.x.git/commitdiff
suricata: Collect metrics on scanned and bypassed packets
authorMichael Tremer <michael.tremer@ipfire.org>
Tue, 10 Sep 2024 21:45:53 +0000 (23:45 +0200)
committerMichael Tremer <michael.tremer@ipfire.org>
Tue, 24 Sep 2024 08:44:07 +0000 (08:44 +0000)
Signed-off-by: Michael Tremer <michael.tremer@ipfire.org>
config/collectd/collectd.conf
src/initscripts/system/suricata

index 27e1fe984ad9f71c0e86b8b57db5f525ead1d8f0..fd548b6cf18ce5a8ec09c4a69720cc6ce1f33d30 100644 (file)
@@ -52,6 +52,10 @@ include "/etc/collectd.precache"
        Chain filter SPOOFED_MARTIAN DROP_SPOOFED_MARTIAN
        Chain filter HOSTILE_DROP_IN DROP_HOSTILE
        Chain filter HOSTILE_DROP_OUT DROP_HOSTILE
+
+       # IPS
+       Chain mangle IPS BYPASSED
+       Chain mangle IPS SCANNED
 </Plugin>
 
 #<Plugin logfile>
index 2890fa64be1ef73881fc9f48168ab793ce15e2d9..150984d93007b756390396c57982dfd19a4c998e 100644 (file)
@@ -78,7 +78,9 @@ generate_fw_rules() {
        flush_fw_chain
 
        # Don't process packets where the IPS has requested to bypass the stream
-       iptables -w -t mangle -A IPS -m mark --mark "$(( IPS_BYPASS_MARK ))/$(( IPS_BYPASS_MASK ))" -j RETURN
+       iptables -w -t mangle -A IPS \
+               -m comment --comment "BYPASSED" \
+               -m mark --mark "$(( IPS_BYPASS_MARK ))/$(( IPS_BYPASS_MASK ))" -j RETURN
 
        # If suricata decided to bypass a stream, we will store the mark in the connection tracking table
        iptables -w -t mangle -A IPS \
@@ -126,7 +128,7 @@ generate_fw_rules() {
        fi
 
        # Send packets to suricata
-       iptables -w -t mangle -A IPS -j NFQUEUE "${NFQ_OPTIONS[@]}"
+       iptables -w -t mangle -A IPS -m comment --comment "SCANNED" -j NFQUEUE "${NFQ_OPTIONS[@]}"
 
        return 0
 }