]>
git.ipfire.org Git - ipfire-2.x.git/blob - src/initscripts/system/suricata
2 ########################################################################
3 # Begin $rc_base/init.d/suricata
5 # Description : Suricata Initscript
7 # Author : Stefan Schantl <stefan.schantl@ipfire.org>
13 ########################################################################
18 PATH
=/usr
/local
/sbin
:/usr
/local
/bin
:/bin
:/usr
/bin
:/sbin
:/usr
/sbin
; export PATH
20 eval $
(/usr
/local
/bin
/readhash
/var
/ipfire
/suricata
/settings
)
22 # Name of the firewall chain.
25 # Optional options for the Netfilter queue.
26 NFQ_OPTS
="--queue-bypass "
28 # Array containing the 4 possible network zones.
29 network_zones
=( red green blue orange
)
31 # Mark and Mask options.
35 # PID file of suricata.
36 PID_FILE
="/var/run/suricata.pid"
40 # Get amount of CPU cores.
44 [ "$line" ] && [ -z "${line%processor*}" ] && NFQUEUES
+="-q $CPUCOUNT " && ((CPUCOUNT
++))
47 # Check if the IDS should be started.
48 if [ "$ENABLE_IDS" == "on" ]; then
49 # Loop through the array of network zones.
50 for zone
in "${network_zones[@]}"; do
51 # Convert zone into upper case.
54 # Check if the IDS is enabled for this network zone.
55 if [ "$ENABLE_IDS_$$zone_upper" == "on" ]; then
56 # Generate name of the network interface.
63 # Check if there are multiple cpu cores available.
64 if [ "$CPUCOUNT" > 0 ]; then
65 # Balance beetween all queues.
66 NFQ_OPTIONS
+="--queue-balance 0:"
67 NFQ_OPTIONS
+=$
(($CPUCOUNT-1))
69 # Send all packets to queue 0.
70 NFQ_OPTIONS
+="--queue-num 0"
73 # Create firewall rules to queue the traffic and pass to
75 iptables
-I "$FW_CHAIN" -i "$network_device" -m mark
! --mark "$MARK"/"$MASK" -j NFQUEUE
"$NFQ_OPTIONS"
76 iptables
-I "$FW_CHAIN" -o "$network_device" -m mark
! --mark "$MARK"/"$MASK" -j NFQUEUE
"$NFQ_OPTIONS"
81 boot_mesg
"Starting Intrusion Detection System..."
82 /usr
/bin
/suricata
-c /etc
/suricata
/suricata.yaml
-D $NFQUEUES
85 # Allow reading the pidfile.
91 boot_mesg
"Stopping Intrusion Detection System..."
92 killproc
-p $PID_FILE /var
/run
94 # Flush firewall chain.
97 # Remove suricata control socket.
98 rm /var
/run
/suricata
/* >/dev
/null
2>/dev
/null
100 # Don't report returncode of rm if suricata was not started
105 statusproc
/usr
/bin
/suricata
113 # Send SIGUSR2 to the suricata process to perform a reload
115 kill -USR2 $
(pidof suricata
)
119 echo "Usage: $0 {start|stop|restart|reload|status}"
124 chmod 644 /var
/log
/suricata
/* 2>/dev
/null
126 # End $rc_base/init.d/suricata