I want to create a fail2ban action which routes the traffic to another IP on ban action, and removes the route on unban action.
File: iptables-route.conf in /etc/fail2ban/action.d/
# Fail2Ban configuration file
#
#
[INCLUDES]
before = iptables-common.conf
[Definition]
# Option: actionstart
# Notes.: command executed once at the start of Fail2Ban.
# Values: CMD
#
actionstart = <iptables> -N f2b-<name>
<iptables> -A f2b-<name> -j <returntype>
<iptables> -I <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>
<iptables> -A FORWARD -i ens3 -p tcp -m state --state NEW --dport 80 -j ACCEPT
<iptables> -A FORWARD -i ens3 -p tcp -m state --state NEW --dport 443 -j ACCEPT
# Option: actionstop
# Notes.: command executed once at the end of Fail2Ban
# Values: CMD
#
actionstop = <iptables> -D <chain> -p <protocol> -m multiport --dports <port> -j f2b-<name>
<actionflush>
<iptables> -X f2b-<name>
<iptables> -D FORWARD -i ens3 -p tcp -m state --state NEW --dport 80 -j ACCEPT
<iptables> -D FORWARD -i ens3 -p tcp -m state --state NEW --dport 443 -j ACCEPT
# Option: actioncheck
# Notes.: command executed once before each actionban command
# Values: CMD
#
actioncheck = <iptables> -n -L <chain> | grep -q 'f2b-<name>[ \t]'
# Option: actionban
# Notes.: command executed when banning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: See jail.conf(5) man page
# Values: CMD
#
actionban = <iptables> -I f2b-<name> 1 PREROUTING -s <ip> -j DNAT --to-destination 188.68.45.124
# Option: actionunban
# Notes.: command executed when unbanning an IP. Take care that the
# command is executed with Fail2Ban user rights.
# Tags: See jail.conf(5) man page
# Values: CMD
#
actionunban = <iptables> -D f2b-<name> -s <ip> -j DNAT --to-destination 188.68.45.124
[Init]
File apache-route.local in /etc/fail2ban/jail.d/:
[apache-route]
enabled = true
filter = apache-probe
port = http,https
banaction = iptables-route.conf
maxretry = 3
findtime = 1500
bantime = 600
logpath = /var/www/*/userdata/logs/*-access.log
I can't even get to test it, because it gives me the following error:
fail2ban-client restart
Found no accessible config files for 'action.d/iptables-route.conf' under /etc/fail2ban
Unable to read action 'iptables-route.conf'
Errors in jail 'apache-route'. Skipping...
I try to get it working, but i have no clue why it gives me that error