2013-10-30 13:02:59 +00:00
|
|
|
# Fail2Ban filter for selected Postfix SMTP rejections
|
2006-09-06 19:34:03 +00:00
|
|
|
#
|
|
|
|
#
|
|
|
|
|
2013-07-20 14:31:21 +00:00
|
|
|
[INCLUDES]
|
|
|
|
|
|
|
|
# Read common prefixes. If any customizations available -- read them from
|
|
|
|
# common.local
|
|
|
|
before = common.conf
|
|
|
|
|
2006-09-06 19:34:03 +00:00
|
|
|
[Definition]
|
|
|
|
|
2017-07-10 13:38:24 +00:00
|
|
|
_daemon = postfix(-\w+)?/\w+(?:/smtp[ds])?
|
|
|
|
_port = (?::\d+)?
|
2021-05-29 17:48:24 +00:00
|
|
|
_pref = [A-Z]{4}
|
2013-07-20 14:31:21 +00:00
|
|
|
|
2017-07-10 18:49:28 +00:00
|
|
|
prefregex = ^%(__prefix_line)s<mdpr-<mode>> <F-CONTENT>.+</F-CONTENT>$
|
2017-02-21 14:54:59 +00:00
|
|
|
|
2021-06-10 13:06:54 +00:00
|
|
|
# Extended RE for normal mode to match reject by unknown users or undeliverable address, can be set to empty to avoid this:
|
|
|
|
exre-user = |[Uu](?:ser unknown|ndeliverable address)
|
|
|
|
|
2021-05-29 17:48:24 +00:00
|
|
|
mdpr-normal = (?:\w+: (?:milter-)?reject:|(?:improper command pipelining|too many errors) after \S+)
|
2021-06-10 13:06:54 +00:00
|
|
|
mdre-normal=^%(_pref)s from [^[]*\[<HOST>\]%(_port)s: [45][50][04] [45]\.\d\.\d+ (?:(?:<[^>]*>)?: )?(?:(?:Helo command|(?:Sender|Recipient) address) rejected: )?(?:Service unavailable|(?:Client host|Command|Data command) rejected|Relay access denied|(?:Host|Domain) not found|need fully-qualified hostname|match%(exre-user)s)\b
|
2017-10-02 13:41:30 +00:00
|
|
|
^from [^[]*\[<HOST>\]%(_port)s:?
|
2017-07-10 18:49:28 +00:00
|
|
|
|
|
|
|
mdpr-auth = warning:
|
2017-10-02 13:41:30 +00:00
|
|
|
mdre-auth = ^[^[]*\[<HOST>\]%(_port)s: SASL ((?i)LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:(?! Connection lost to authentication server| Invalid authentication mechanism)
|
|
|
|
mdre-auth2= ^[^[]*\[<HOST>\]%(_port)s: SASL ((?i)LOGIN|PLAIN|(?:CRAM|DIGEST)-MD5) authentication failed:(?! Connection lost to authentication server)
|
2017-07-10 18:49:28 +00:00
|
|
|
# todo: check/remove "Invalid authentication mechanism" from ignore list, if gh-1243 will get finished (see gh-1297).
|
|
|
|
|
|
|
|
# Mode "rbl" currently included in mode "normal", but if needed for jail "postfix-rbl" only:
|
|
|
|
mdpr-rbl = %(mdpr-normal)s
|
2021-05-29 17:21:27 +00:00
|
|
|
mdre-rbl = ^%(_pref)s from [^[]*\[<HOST>\]%(_port)s: [45]54 [45]\.7\.1 Service unavailable; Client host \[\S+\] blocked\b
|
2017-07-10 18:49:28 +00:00
|
|
|
|
|
|
|
# Mode "rbl" currently included in mode "normal" (within 1st rule)
|
|
|
|
mdpr-more = %(mdpr-normal)s
|
|
|
|
mdre-more = %(mdre-normal)s
|
|
|
|
|
2020-12-24 03:55:01 +00:00
|
|
|
# Includes some of the log messages described in
|
|
|
|
# <http://www.postfix.org/POSTSCREEN_README.html>.
|
2021-06-10 13:23:24 +00:00
|
|
|
mdpr-ddos = (?:lost connection after(?! DATA) [A-Z]+|disconnect(?= from \S+(?: \S+=\d+)* auth=0/(?:[1-9]|\d\d+))|(?:PREGREET \d+|HANGUP) after \S+|COMMAND (?:TIME|COUNT|LENGTH) LIMIT)
|
2017-10-02 13:41:30 +00:00
|
|
|
mdre-ddos = ^from [^[]*\[<HOST>\]%(_port)s:?
|
2017-07-10 18:49:28 +00:00
|
|
|
|
|
|
|
mdpr-extra = (?:%(mdpr-auth)s|%(mdpr-normal)s)
|
|
|
|
mdre-extra = %(mdre-auth)s
|
|
|
|
%(mdre-normal)s
|
|
|
|
|
|
|
|
mdpr-aggressive = (?:%(mdpr-auth)s|%(mdpr-normal)s|%(mdpr-ddos)s)
|
|
|
|
mdre-aggressive = %(mdre-auth2)s
|
|
|
|
%(mdre-normal)s
|
|
|
|
|
2019-06-07 14:14:02 +00:00
|
|
|
mdpr-errors = too many errors after \S+
|
|
|
|
mdre-errors = ^from [^[]*\[<HOST>\]%(_port)s$
|
2017-07-10 18:49:28 +00:00
|
|
|
|
|
|
|
|
|
|
|
failregex = <mdre-<mode>>
|
|
|
|
|
|
|
|
# Parameter "mode": more (default combines normal and rbl), auth, normal, rbl, ddos, extra or aggressive (combines all)
|
|
|
|
# Usage example (for jail.local):
|
|
|
|
# [postfix]
|
|
|
|
# mode = aggressive
|
2019-06-07 14:14:02 +00:00
|
|
|
#
|
2017-07-10 18:49:28 +00:00
|
|
|
# # or another jail (rewrite filter parameters of jail):
|
|
|
|
# [postfix-rbl]
|
|
|
|
# filter = postfix[mode=rbl]
|
|
|
|
#
|
2019-06-07 14:14:02 +00:00
|
|
|
# # jail to match "too many errors", related postconf `smtpd_hard_error_limit`:
|
|
|
|
# # (normally included in other modes (normal, more, extra, aggressive), but this jail'd allow to ban on the first message)
|
|
|
|
# [postfix-many-errors]
|
|
|
|
# filter = postfix[mode=errors]
|
|
|
|
# maxretry = 1
|
|
|
|
#
|
2017-07-10 18:49:28 +00:00
|
|
|
mode = more
|
2006-11-12 14:52:36 +00:00
|
|
|
|
2006-11-15 18:44:28 +00:00
|
|
|
ignoreregex =
|
2013-05-09 23:15:07 +00:00
|
|
|
|
|
|
|
[Init]
|
|
|
|
|
|
|
|
journalmatch = _SYSTEMD_UNIT=postfix.service
|
2013-11-02 04:59:05 +00:00
|
|
|
|
2013-10-30 13:02:59 +00:00
|
|
|
# Author: Cyril Jaquier
|