Problem mit fail2ban

JanJ

New Member
Hallo,

ich habe fail2ban so konfiguriert, dass der SMTP & SMTPS Port überwacht werden und wenn Spamdyke was blockt, die entsprechende IP nach 10 Versuchen für 3 Stunden bei einer findtime von 600 gesperrt wird.

Wenn ich fail2ban dann starte, klappt das auch gut und die IPs werden geblockt, irgendwann läuft fail2ban dann ins Limit von numiptables. Dann werden halt keine IPs mehr geblockt.

Die jenigen, die dann nach 3 Stunden wieder rausfliegen sollen, fliegen auch raus, aber es werden, dann trotz entsprechender Spamdykeblockaden, keine neuen IPs mehr geblockt.

Irgendwann ist dann bei iptables -L nix mehr drin, es kommt aber auch nichts wieder hinzu. Erst nach einem Neustart von fail2ban geht es wieder, bis sich irgendwann die Schleife wiederholt so wie oben beschrieben.

Any ideas?!

Grüße,

Jan
 
Ist das ein Vserver oder ein Rootserver?
Du könntest bei einem Rootserver für das jeweilige iptables Modul die Anzahl der Einträge erhöhen, allerdings würde sich dadurch irgendwann auch die CPU Leistung erhöhen (Siehe Diskusion um Honeypot hier im Security Forum).

Ansonsten: Andere Lösung einfallen lassen oder weniger IPs blocken lassen. :)
 
Ne, ist ein VServer.

Das eigentliche Problem ist ja nicht, dass ich nicht noch mehr IPs blocken kann, sondern, dass selbst nach genug unbans nicht wieder neu gebant wird und irgendwann effektiv gar nichts mehr gebant ist.

Sprich es läuft ins numiptent Limit, bant nicht mehr neu. Dann wird irgendwann eine IP ungebant, dann noch eine und noch eine. Dann hab ich laut numiptent auch wieder weniger als das Limit, aber es wird nicht neu gebant, obwohl genug IPs die Voraussetzungen für einen ban erfüllen.
 
Last edited by a moderator:
Hat keiner eine Idee ?

Heute nacht war es wieder soweit, jede Menge unbans, aber keine neuen bans mehr, trotz eindeutiger Kandidaten ...
 
Ich könnte mir nur vorstellen, dass der unbann noch an einer zweiten Stelle rausgenommen werden muss, oder dass irgendein counter nicht zurück gesetzt wird.
 
Hi,

also per iptables -L wird nix mehr angezeigt, wenn alle unbans durch sind. Es könnte also wieder neu gebant werden. Passiert aber halt nicht.

Ob irgendwelche counter resettet werden müssten noch oder sonst was laufen muss, ist für mich nach Lektüre der fail2ban Anleitung nicht ersichtlich.

Ein restart von fail2ban hilft jedenfalls, danach geht alles wieder wie es soll.

Danke für die Tipps,

Jan
 
Hmm das neustarten des Fail2ban löscht eigentlich nur alle iptables Regeln und legt sie neu an. Also muss da doch irgendwo der Hacken sein.

Wenn der iptables "speicher" voll ist und nichts neues mehr gebannt wird: Poste dann mal die Ausgabe von:
Code:
cat /proc/user_beancounters
 
Richtig, es wird einfach alles an iptables Regeln gelöscht und ggf. wieder neuangelegt.

Es geht aber weiterhin :-) nicht um die Situation, wenn iptables nichts mehr annimmt, weil numiptent am Limit ist, sondern um die Situation, wenn eben alle IPs wieder per unban aus den iptables Regeln weg sind, das Limit bei weitem nicht erreicht, aber neue böse IPs eben nicht gebannt werden.

Die Ausgabe ist mäßig spannend, wie ich finde, ich kann jedenfalls nichts auffälliges in einer solchen Situation erkennen:

Code:
Version: 2.5
       uid  resource                     held              maxheld              barrier                limit              failcnt
 55276002:  kmemsize                  5534788              5787746             24330240             26763264                    0
            lockedpages                     0                    0                  384                  384                    0
            privvmpages                 44011                52980               131072               144179                    0
            shmpages                      741                  741                65536                65536                    0
            dummy                           0                    0  9223372036854775807  9223372036854775807                    0
            numproc                        49                   52                  198                  198                    0
            physpages                   10341                10520                    0  9223372036854775807                    0
            vmguarpages                     0                    0                98304  9223372036854775807                    0
            oomguarpages                21051                21230                98304  9223372036854775807                    0
            numtcpsock                     20                   22                  384                  384                    0
            numflock                        6                    6                  300                  330                    0
            numpty                          1                    1                   30                   30                    0
            numsiginfo                      0                    1                  768                  768                    0
            tcpsndbuf                  421648               439120              5043032              7203882                    0
            tcprcvbuf                  327680               344064              5043032              7203882                    1
            othersockbuf                17776                23712               998400              1981440                    0
            dgramrcvbuf                     0                    0               998400               998400                    0
            numothersock                   16                   20                  384                  384                    0
            dcachesize                      0                    0              3282435              3610679                    0
            numfile                      2241                 2321                 6336                 6336                    0
            dummy                           0                    0                    0                    0                    0
            dummy                           0                    0                    0                    0                    0
            dummy                           0                    0                    0                    0                    0
            numiptent                      22                   22                   96                   96                  310
 
Sorry mein Handy hatte heute morgen nur die Hälfte dargestellt...merke: Der Opera Mini kann nicht in Code Tags scrollen :)

"numiptent" ist jedenfalls schon das ein oder andere Mal an seine Grenzen gestoßen. Ist das jetzt die Ausgabe in dem Moment wie du nichts weiter mehr bannen kannst?
 
:cool:

Ich betone nochmal, dass das Problem NICHT ist, dass fail2ban keinen neuen IPs mehr bannt, wenn numiptent am Limit ist. Das ist klar, das geht nicht.

Das Problem ist weiterhin, dass fail2ban in unregelmäßigen Abständen zwar die unbans richtig vornimmt, numiptent dann nicht mehr am Limit ist, sowie wie oben gepostet, es neue IPs gibt, die die Voraussetzungen eines bans erfüllen, aber fail2ban eben nicht bannt, sondern erst nach einem Neustart.

Sprich, fail2ban müsste bannen, könnte bannen, tut es aber nicht.
 
Okay :)

fail2ban.conf ohne Kommentare:
Code:
# Fail2Ban configuration file
#
# Author: Cyril Jaquier
#
# $Revision: 629 $
#

[Definition]

loglevel = 3
logtarget = /var/log/fail2ban.log
socket = /var/run/fail2ban/fail2ban.sock

jail.conf nur mit aktiven Jails:
Code:
# Fail2Ban configuration file.
#
# This file was composed for Debian systems from the original one
#  provided now under /usr/share/doc/fail2ban/examples/jail.conf
#  for additional examples.
#
# To avoid merges during upgrades DO NOT MODIFY THIS FILE
# and rather provide your changes in /etc/fail2ban/jail.local
#
# Author: Yaroslav O. Halchenko <debian@onerussian.com>
#
# $Revision: 281 $
#

# The DEFAULT allows a global definition of the options. They can be override
# in each jail afterwards.

[DEFAULT]

# "ignoreip" can be an IP address, a CIDR mask or a DNS host
ignoreip = 127.0.0.1
#bantime  = 600
bantime = 21600
maxretry = 5

# "backend" specifies the backend used to get files modification. Available
# options are "gamin", "polling" and "auto".
# yoh: For some reason Debian shipped python-gamin didn't work as expected
#      This issue left ToDo, so polling is default backend for now
backend = polling

#
# Destination email address used solely for the interpolations in
# jail.{conf,local} configuration files.
destemail = root@localhost

#
# ACTIONS
#

# Default banning action (e.g. iptables, iptables-new,
# iptables-multiport, shorewall, etc) It is used to define 
# action_* variables. Can be overriden globally or per 
# section within jail.local file
banaction = iptables-multiport

# email action. Since 0.8.1 upstream fail2ban uses sendmail
# MTA for the mailing. Change mta configuration parameter to mail
# if you want to revert to conventional 'mail'.
mta = sendmail

# Default protocol
protocol = tcp

#
# Action shortcuts. To be used to define action parameter

# The simplest action to take: ban only
action_ = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s]

# ban & send an e-mail with whois report to the destemail.
action_mw = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s]
              %(mta)s-whois[name=%(__name__)s, dest="%(destemail)s", protocol="%(protocol)s]

# ban & send an e-mail with whois report and relevant log lines
# to the destemail.
action_mwl = %(banaction)s[name=%(__name__)s, port="%(port)s", protocol="%(protocol)s]
               %(mta)s-whois-lines[name=%(__name__)s, dest="%(destemail)s", logpath=%(logpath)s]
 
# Choose default action.  To change, just override value of 'action' with the
# interpolation to the chosen action shortcut (e.g.  action_mw, action_mwl, etc) in jail.local
# globally (section [DEFAULT]) or per specific section 
action = %(action_)s

#
# JAILS
#


[ssh]

enabled = true
port	= ssh
filter	= sshd
logpath  = /var/log/auth.log
maxretry = 6

[spamdyke]

enabled  = true
port	 = smtp,ssmtp
filter   = spamdyke
logpath  = /var/log/mail.info
maxretry = 8

spamdyke.conf als Filterdatei komplett:
Code:
# Fail2Ban configuration file
#
# Author: Jan
#
# $Revision: 1 $
#

[Definition]

# Option: failregex
# Notes.: regex to match the password failures messages in the logfile. The
#          host must be matched by a group named "host". The tag "<HOST>" can
#          be used for standard IP/hostname matching and is only an alias for
#          (?:::f{4,6}:)?(?P<host>\S+)
# Values: TEXT
#
failregex = DENIED_RDNS_MISSING from: .* to: .* origin_ip: <HOST>
	    DENIED_IP_IN_CC_RDNS from: .* to: .* origin_ip: <HOST>
	    DENIED_RDNS_RESOLVE from: .* to: .* origin_ip: <HOST>
	    DENIED_RBL_MATCH from: .* to: .* origin_ip: <HOST>
	    DENIED_OTHER from: .* to: .* origin_ip: <HOST>
	    DENIED_SENDER_NO_MX from: .* to: .* origin_ip: <HOST>
	    DENIED_GRAYLISTED from: .* to: .* origin_ip: <HOST>
	    
	    
# Option:  ignoreregex
# Notes.:  regex to ignore. If this regex matches, the line is ignored.
# Values:  TEXT
#
ignoreregex =
 
Back
Top