Answer the question
In order to leave comments, you need to log in
How to force fail2ban to execute bash script during ban?
I have jail.local, after three unsuccessful attempts to enter the phpmyadmin web interface, access to the server is blocked:
[phpmyadmin]
enabled = true
maxretry = 3
port = http,https
filter = phpmyadmin
logpath = /var/log/apache2/phpmyadmin/access.log
action = iptables-multiport[name=phpmyadmin, port="http,https", protocol=tcp]
#!/bin/bash
while getopts t: option
do
case $option in
;;
t)
TEXT=${OPTARG}
;;
esac
done
POST_DATA="{\""text"\":"\"$TEXT"\"}";
URL="http://localhost/fail";
wget -O- --header="Content-Type: application/json" --post-data $POST_DATA --no-check-certificate $URL;
[INCLUDES]
before = iptables-multiport.conf
[Definition]
actionban = /etc/fail2ban/scripts/do-req.sh -t ban_detected
[Init]
action = iptables-multiport-exec[name=phpmyadmin, port="http,https", protocol=tcp]
Answer the question
In order to leave comments, you need to log in
actionban = /bin/sh -c /etc/fail2ban/scripts/do-req.sh -t ban_detected
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question