fail2ban hat keine Auswirkung

Serverdienste ohne eigene Kategorie
cos
Posts: 29
Joined: 2007-04-20 19:56
 

fail2ban hat keine Auswirkung

Post by cos »

Hallo zusammen,

ich habe festgestellt, dass das fail2ban keine Auswirkung auf iptables hat.
Soll bedeuten, obwohl fail2ban gestartet ist und die entsprechenden Kategorien unter /etc/fail2ban/jail.conf bearbeitet wurden, werden keine IP Adressen per iptables gebannt. Und das ging aber schon mal vor ca. 3 Wochen.

Mein Sytem: Debian Jessie

/etc/fail2ban/jail.conf

Code: Select all

[postfix]

enabled  = true
port     = 25,587
filter   = postfix
logpath  = /var/log/mail.log
maxretry = 2
bantime = 31536000

[couriersmtp]

enabled = true
port     = 25,587
filter   = couriersmtp
logpath  = /var/log/mail.log
maxretry = 2
bantime = 31536000

[courierauth]

enabled  = true
port     = 25,submission,143,993,110,995
filter   = courierlogin
logpath  = /var/log/mail.log
maxretry = 2
bantime = 604800

[sasl]

enabled  = true
port     = smtp,ssmtp,submission,imap2,imap3,imaps,pop3,pop3s
filter   = postfix-sasl
# You might consider monitoring /var/log/mail.warn instead if you are
# running postfix since it would provide the same log lines at the
# "warn" level but overall at the smaller filesize.
logpath  = /var/log/mail.log
maxretry = 2
bantime = 31536000
Beispiel: Mehrfach E-Mails kamen per root@localhost

Code: Select all

Postfix SMTP server: errors from 168-215-58-40.static.twtelecom.net[168.215.58.40]:62478

Transcript of session follows.

  Out: 220 mail.domain.de ESMTP Postfix (Debian/GNU)
  In:  EHLO User
  Out: 250-mail.domain.de
  Out: 250-PIPELINING
  Out: 250-SIZE
  Out: 250-ETRN
  Out: 250-STARTTLS
  Out: 250-ENHANCEDSTATUSCODES
  Out: 250-8BITMIME
  Out: 250 DSN
  In:  RSET
  Out: 250 2.0.0 Ok
  In:  AUTH LOGIN
  Out: 503 5.5.1 Error: authentication not enabled
  In:  QUIT
  Out: 221 2.0.0 Bye

 For other details, see the local mail logfile
Auszug aus der /var/log/mail.log zu diesem Zeitpunkt:

Code: Select all

May 17 10:05:27 myhost postfix/smtpd[26051]: warning: dict_nis_init: NIS domain name not set - NIS lookups disabled
 May 17 10:05:27 myhost postfix/smtpd[26051]: connect from 168-215-58-40.static.twtelecom.net[168.215.58.40]:62478
 May 17 10:05:28 myhost postfix/smtpd[26051]: disconnect from 168-215-58-40.static.twtelecom.net[168.215.58.40]:62478
Auszug aus /var/log/auth.log (Und das ist auffällig)

Code: Select all

May 17 10:05:27 myhost postfix/smtpd[26051]: sql_select option missing
 May 17 10:05:27 myhost postfix/smtpd[26051]: auxpropfunc error no mechanism available
 May 17 10:05:27 myhost postfix/smtpd[26051]: _sasl_plugin_load failed on sasl_auxprop_plug_init for plugin: sql
Ich habe keine Authentifizierung per SQL wo drinstehen, zumindest glaube ich das. Postfix lässt per saslauth über Pam authentifizieren.

also ich weiß jetzt nicht mehr wo ich ansetzen soll. Per Google habe ich die verschiedensten Lösungsansätze verfolgt. Bin aber zu keinem Ergebnis gekommen.
Ansätze in etwa so: https://serversupportforum.de/forum/vir ... nicht.html

Hat noch jemand eine Idee? Vermutlich liegt es an den Einträgen zu authd.log.

Viele Grüße
cos
Last edited by cos on 2017-05-18 07:23, edited 2 times in total.
cos
Posts: 29
Joined: 2007-04-20 19:56
 

Re: fail2ban hat keine Auswirkung

Post by cos »

Hallo Gemeinde,

ggf. habe ich das Problem gelöst.
Bisher ist die Lösung wegen dem Auszug aus /var/log/auth.log folgende:
apt-get remove libsasl2-modules-sql
Gefunden auf https://www.howtoforge.com/community/th ... ble.13034/.
Ich hatte heute iptables manuell angepasst und die doofen IP Adressen ge-drop't.
Nach der Änderung von sasl und ein Neustart von saslauthd sowie postfix sind keine merkwürdigen Einträge mehr in der /var/log/auth.log oder /var/log/mail.log ersichtlich.

Blöderweise bekomme ich immer noch Mails von root@localhost wegen falschen Login per smtp.
Allerdings alle ca. 20 Minuten. Da werde ich mal die /etc/fail2ban/jail.conf anpassen unter:
# A host is banned if it has generated "maxretry" during the last "findtime"
# seconds.
findtime = 600
maxretry = 2
Ändern zu:
findtime = 1800 # 30'
Mal schauen ob das passt.
Die nächste Baustelle ist postfix's Postscreen. Da bräuchte ich auch mal Meinungen zu. ;)

Viele Grüße
cos
cos
Posts: 29
Joined: 2007-04-20 19:56
 

Re: fail2ban hat keine Auswirkung

Post by cos »

Moin zusamman,

scheinbar ist es doch nicht gelöst.

Fail2Ban scheint zu laufen. Habe jetzt für Apache & ftp gebannte Einträge:
2017-05-18 01:40:45,919 fail2ban.actions[31483]: WARNING [apache-noscript] Ban 107.178.195.219
2017-05-18 01:43:50,409 fail2ban.actions[31483]: WARNING [proftpd] Ban 121.12.125.108
2017-05-18 03:13:40,081 fail2ban.actions[31483]: WARNING [apache-noscript] Ban 176.14.99.57
Irgendwie bekomme ich die IPs nicht geblockt welche sich falsch/ nicht authentifizieren.
Beispiel für die letzte Nacht:
Postfix SMTP server: errors from 168-215-58-40.static.twtelecom.net[168.215.58.40]:56437

Transcript of session follows.

Out: 220 mail.domain.de ESMTP Postfix (Debian/GNU)
In: EHLO User
Out: 250-mail.domain.de
Out: 250-PIPELINING
Out: 250-SIZE
Out: 250-ETRN
Out: 250-STARTTLS
Out: 250-ENHANCEDSTATUSCODES
Out: 250-8BITMIME
Out: 250 DSN
In: RSET
Out: 250 2.0.0 Ok
In: AUTH LOGIN
Out: 503 5.5.1 Error: authentication not enabled
In: QUIT
Out: 221 2.0.0 Bye

For other details, see the local mail logfile
Hat jemand einen Tipp für mich, wie ich diese Kollegen verbannen kann?

VG
cos
User avatar
rudelgurke
Posts: 410
Joined: 2008-03-12 05:36
 

Re: fail2ban hat keine Auswirkung

Post by rudelgurke »

Ahm - die Dinge erstmal auseinander nehmen. Erstmal hoffe ich Postfix Konfiguration passt.

Soweit ersichtlich erzählt Onkel Glaskugel dass Postfix auf Port 25 keine AUTH anbieten soll, dafür auf Port 587 - richtig ? Der Auth Mechanismus ist dann Postfix -> Cyrus SASL -> PAM.

Dann kommt von außen die böse Schwiegermutter vorbei und versucht ein AUTH auf Port 25, was fehlschlägt, da keine AUTH angeboten wird.
Das Ganze steht dann so im Log und da soll, nach Möglichkeit, Ruhe einziehen.

Falls dem so ist, vielleicht einen Blick in die Filter Konfiguration werfen, dass fail2ban - wovon ich eigentlich wenig halte aber naja - auch auf die entsprechende Zeile im Log einen "Match" hat.
Wenn, wie im verlinkten Post, nur auf "LOGIN FAILED" geprüft wird, im Log aber nur "authentication not enabled" steht wird nie ein Match kommen.