Mailserver absichern (Ubuntu 18.04)

Aus Tutorials
Zur Navigation springen Zur Suche springen

To Do

https://infosec-handbook.eu/as-wss/

Fail2Ban

Allgemein

Verhindert unter anderem Wörterbuchangriffe durch temporäre Anpassung von Firewall-Regeln.

Installation

Siehe Fail2Ban

Konfiguration

/etc/fail2ban/jail.d/mailserver.conf

Nachdem Fail2Ban installiert wurde, muss noch eine Konfigurationsdatei für alle Mailservices angelegt werden:

sudo vi /etc/fail2ban/jail.d/mailserver.conf

und mit folgendem Inhalt befüllt werden:

[postfix]
enabled = true
port = smtp,submission
filter = postfix
logpath = /var/log/mail.log

[sasl]
enabled = true
port = smtp,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

/etc/fail2ban/filter.d/postfix-sasl.conf

Diese Datei sollte normalerweise bei den vordefinierten Konfigurationen dabei sein, was hier jedoch nicht der Fall war. Daher die Datei

sudo vi /etc/fail2ban/filter.d/postfix-sasl.conf

anlegen und mit folgenden Filterregeln befüllen:

# Fail2Ban filter for postfix authentication failures
#

[INCLUDES]

before = common.conf

[Definition]

_daemon = (?:postfix/smtpd|postfix/submission/smtpd)

failregex = ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$
             ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL (?:Login|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$
             ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL (?:LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:
             ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL (?:Login|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:
             ^%(__prefix_line)swarning: (.*?)does not resolve to address <HOST>: Name or service not known$
             ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL (?:login|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed(: [ A-Za-z0-9+/]*={0,2})?\s*$
             ^%(__prefix_line)swarning: [-._\w]+\[<HOST>\]: SASL (?:login|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:

ignoreregex =

Links

https://wiki.dovecot.org/HowTo/Fail2Ban

https://forum.howtoforge.de/threads/fail2ban-postfix-sasl-conf.9731/


Zurück zu Mailserver einrichten