From d0887f32345f34ebc2828751edf299be5f643ea7 Mon Sep 17 00:00:00 2001 From: ediazrod Date: Thu, 26 Feb 2015 18:48:31 +0100 Subject: [PATCH 01/99] This is a especific configuration for shorewall ipset proto6 Use ipset proto6 in shorewall. You must follow the rules to enable ipset in you blacklist if you have a lot of spam (my case) is better use ipset rather than shorewall command line (is my firewall) stop fail2ban with shorewall on one list of 1000 Ips takes 5 min with ipset in shorewall 10 sec. --- config/action.d/shorewall-ipset-proto6.conf | 84 +++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 config/action.d/shorewall-ipset-proto6.conf diff --git a/config/action.d/shorewall-ipset-proto6.conf b/config/action.d/shorewall-ipset-proto6.conf new file mode 100644 index 00000000..b18fda6d --- /dev/null +++ b/config/action.d/shorewall-ipset-proto6.conf @@ -0,0 +1,84 @@ +# Fail2Ban configuration file +# +# Author: Eduardo Diaz +# +# This is for ipset protocol 6 (and hopefully later) (ipset v6.14). +# for shorewall +# +# Use this setting in jail.conf to modify the name and the max time in every jain +# action = shorewall-ipset-proto6[name=SSH, bantime=10000] +# +# This requires the program ipset which is normally in package called ipset. +# +# IPset was a feature introduced in the linux kernel 2.6.39 and 3.0.0 kernels. +# +# The default Shorewall configuration is with "BLACKLISTNEWONLY=Yes" (see +# file /etc/shorewall/shorewall.conf). This means that when Fail2ban adds a +# new shorewall rule to ban an IP address, that rule will affect only new +# connections. So if the attempter goes on trying using the same connection +# he could even log in. In order to get the same behavior of the iptable +# action (so that the ban is immediate) the /etc/shorewall/shorewall.conf +# file should me modified with "BLACKLISTNEWONLY=No". +# +# A lot of this depends of the shorewall version at least have the 4.5.5 Version +# +# Enable to shorewall use a blacklist using iptables creating a file /etc/shorewall/blrules +# and adding "DROP net:+f2b-ssh all" one for every jail +# details in shorewall documentation blacklist. +# to enable restore you ipset You must set SAVE_IPSETS=Yes in shorewall.conf +# Is importan to read this documentation from shorewall http://shorewall.net/ipsets.html +# +# To force create the ipset in the case that somebody delete the ipset create a file +# /etc/shorewall/initdone and add one line for every ipset (this files are in Perl) +# take care of add 1; at the end of the file +# the example is: +# system("/usr/sbin/ipset -quiet -exist create f2b-ssh hash:ip timeout 600 "); +# 1; +# +# To destroy the ipset in shorewall you must add to the file /etc/shorewall/stopped +# # One line of every ipset +# system("/usr/sbin/ipset -quiet destroy f2b-ssh "); +# 1; # This must go to the end of the file if not shorewall complilation fails +# +# + + +[Definition] + +# Option: actionstart +# Notes.: command executed once at the start of Fail2Ban. +# Values: CMD +# +actionstart = if ! ipset -quiet -name list f2b- >/dev/null; + then ipset -quiet -exist create f2b- hash:ip timeout ; + fi + +# Option: actionstop +# Notes.: command executed once at the end of Fail2Ban +# Values: CMD +# +actionstop = ipset flush f2b- + +# 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 = ipset add f2b- timeout -exist + +# 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 = ipset del f2b- -exist + +[Init] + +# Option: bantime +# Notes: specifies the bantime in seconds (handled internally rather than by fail2ban) +# Values: [ NUM ] Default: 600 +# +bantime = 600 From e26a1ad6b6a1cbdbb6e28e62af61da2ec5bd73bb Mon Sep 17 00:00:00 2001 From: ediazrod Date: Mon, 23 Mar 2015 00:55:06 +0100 Subject: [PATCH 02/99] Update shorewall-ipset-proto6.conf --- config/action.d/shorewall-ipset-proto6.conf | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/config/action.d/shorewall-ipset-proto6.conf b/config/action.d/shorewall-ipset-proto6.conf index b18fda6d..48308ec1 100644 --- a/config/action.d/shorewall-ipset-proto6.conf +++ b/config/action.d/shorewall-ipset-proto6.conf @@ -22,10 +22,9 @@ # # A lot of this depends of the shorewall version at least have the 4.5.5 Version # -# Enable to shorewall use a blacklist using iptables creating a file /etc/shorewall/blrules -# and adding "DROP net:+f2b-ssh all" one for every jail -# details in shorewall documentation blacklist. -# to enable restore you ipset You must set SAVE_IPSETS=Yes in shorewall.conf +# Enable shorewall to use a blacklist using iptables creating a file /etc/shorewall/blrules +# and adding "DROP net:+f2b-ssh all" one for every jail details in shorewall documentation blacklist. +# To enable restore you ipset You must set SAVE_IPSETS=Yes in shorewall.conf # Is importan to read this documentation from shorewall http://shorewall.net/ipsets.html # # To force create the ipset in the case that somebody delete the ipset create a file From 5fdd1d1ded22d15b13dc83fd5cbb1a0c02eeccbc Mon Sep 17 00:00:00 2001 From: ediazrod Date: Mon, 23 Mar 2015 00:56:37 +0100 Subject: [PATCH 03/99] Update shorewall-ipset-proto6.conf --- config/action.d/shorewall-ipset-proto6.conf | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/config/action.d/shorewall-ipset-proto6.conf b/config/action.d/shorewall-ipset-proto6.conf index 48308ec1..7fbc21bb 100644 --- a/config/action.d/shorewall-ipset-proto6.conf +++ b/config/action.d/shorewall-ipset-proto6.conf @@ -20,7 +20,8 @@ # action (so that the ban is immediate) the /etc/shorewall/shorewall.conf # file should me modified with "BLACKLISTNEWONLY=No". # -# A lot of this depends of the shorewall version at least have the 4.5.5 Version +# The use in IPset in shorewall depends of the version you must have at least 4.5.5< version +# of shorewall # # Enable shorewall to use a blacklist using iptables creating a file /etc/shorewall/blrules # and adding "DROP net:+f2b-ssh all" one for every jail details in shorewall documentation blacklist. @@ -37,7 +38,7 @@ # To destroy the ipset in shorewall you must add to the file /etc/shorewall/stopped # # One line of every ipset # system("/usr/sbin/ipset -quiet destroy f2b-ssh "); -# 1; # This must go to the end of the file if not shorewall complilation fails +# 1; # This must go to the end of the file if not shorewall compilation fails # # From 0720c831b7a752b5939a3b09b5f957057da55c89 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20T=C3=B3th?= Date: Thu, 26 Mar 2015 03:02:02 +0100 Subject: [PATCH 04/99] Fix of LC_TIME usage, it should be LC_ALL --- config/action.d/sendmail-common.conf | 10 +++++----- config/action.d/sendmail-geoip-lines.conf | 2 +- config/action.d/sendmail-whois-ipjailmatches.conf | 2 +- config/action.d/sendmail-whois-ipmatches.conf | 2 +- config/action.d/sendmail-whois-lines.conf | 2 +- config/action.d/sendmail-whois-matches.conf | 2 +- config/action.d/sendmail-whois.conf | 2 +- config/action.d/sendmail.conf | 2 +- config/action.d/xarf-login-attack.conf | 10 +++++----- 9 files changed, 17 insertions(+), 17 deletions(-) diff --git a/config/action.d/sendmail-common.conf b/config/action.d/sendmail-common.conf index af0212bd..1475dedb 100644 --- a/config/action.d/sendmail-common.conf +++ b/config/action.d/sendmail-common.conf @@ -15,7 +15,7 @@ after = sendmail-common.local # Values: CMD # actionstart = printf %%b "Subject: [Fail2Ban] : started on `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n @@ -28,7 +28,7 @@ actionstart = printf %%b "Subject: [Fail2Ban] : started on `uname -n` # Values: CMD # actionstop = printf %%b "Subject: [Fail2Ban] : stopped on `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n @@ -40,7 +40,7 @@ actionstop = printf %%b "Subject: [Fail2Ban] : stopped on `uname -n` # Notes.: command executed once before each actionban command # Values: CMD # -actioncheck = +actioncheck = # Option: actionban # Notes.: command executed when banning an IP. Take care that the @@ -48,7 +48,7 @@ actioncheck = # Tags: See jail.conf(5) man page # Values: CMD # -actionban = +actionban = # Option: actionunban # Notes.: command executed when unbanning an IP. Take care that the @@ -56,7 +56,7 @@ actionban = # Tags: See jail.conf(5) man page # Values: CMD # -actionunban = +actionunban = [Init] diff --git a/config/action.d/sendmail-geoip-lines.conf b/config/action.d/sendmail-geoip-lines.conf index 4225a3eb..3a0c931e 100644 --- a/config/action.d/sendmail-geoip-lines.conf +++ b/config/action.d/sendmail-geoip-lines.conf @@ -20,7 +20,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/sendmail-whois-ipjailmatches.conf b/config/action.d/sendmail-whois-ipjailmatches.conf index 9c32f41b..3e97ca32 100644 --- a/config/action.d/sendmail-whois-ipjailmatches.conf +++ b/config/action.d/sendmail-whois-ipjailmatches.conf @@ -17,7 +17,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/sendmail-whois-ipmatches.conf b/config/action.d/sendmail-whois-ipmatches.conf index 8c07454c..beafb48f 100644 --- a/config/action.d/sendmail-whois-ipmatches.conf +++ b/config/action.d/sendmail-whois-ipmatches.conf @@ -17,7 +17,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/sendmail-whois-lines.conf b/config/action.d/sendmail-whois-lines.conf index 135632ce..abbd60bc 100644 --- a/config/action.d/sendmail-whois-lines.conf +++ b/config/action.d/sendmail-whois-lines.conf @@ -17,7 +17,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/sendmail-whois-matches.conf b/config/action.d/sendmail-whois-matches.conf index 64bac3ef..f2a13745 100644 --- a/config/action.d/sendmail-whois-matches.conf +++ b/config/action.d/sendmail-whois-matches.conf @@ -17,7 +17,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/sendmail-whois.conf b/config/action.d/sendmail-whois.conf index 9403a388..31026ce4 100644 --- a/config/action.d/sendmail-whois.conf +++ b/config/action.d/sendmail-whois.conf @@ -17,7 +17,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/sendmail.conf b/config/action.d/sendmail.conf index 4b088dc8..5f5670c3 100644 --- a/config/action.d/sendmail.conf +++ b/config/action.d/sendmail.conf @@ -17,7 +17,7 @@ before = sendmail-common.conf # Values: CMD # actionban = printf %%b "Subject: [Fail2Ban] : banned from `uname -n` - Date: `LC_TIME=C date +"%%a, %%d %%h %%Y %%T %%z"` + Date: `LC_ALL=C date +"%%a, %%d %%h %%Y %%T %%z"` From: <> To: \n Hi,\n diff --git a/config/action.d/xarf-login-attack.conf b/config/action.d/xarf-login-attack.conf index 19b3167f..3ab73817 100644 --- a/config/action.d/xarf-login-attack.conf +++ b/config/action.d/xarf-login-attack.conf @@ -1,7 +1,7 @@ # Fail2Ban action for sending xarf Login-Attack messages to IP owner # -# IMPORTANT: -# +# IMPORTANT: +# # Emailing a IP owner of abuse is a serious complain. Make sure that it is # serious. Fail2ban developers and network owners recommend you only use this # action for: @@ -46,7 +46,7 @@ actionban = oifs=${IFS}; IFS=.;SEP_IP=( ); set -- ${SEP_IP}; ADDRESSES=$(di REPORTID=