Skip to content

bug report: fail2ban only works when I add the IP manually on CentOS 7 #3574

@cottonthread

Description

@cottonthread

📝 Preliminary Checks

  • I tried searching for an existing issue and followed the debugging docs advice, but still need assistance.

👀 What Happened?

When I use fail2ban manually the system takes effect but when it comes from the mail system itself, it generates an error in adding the IP to the list, so it is not possible to block IPs automatically.

I have tried changing the fail2ban-jail.cf file, so that instead of running nftables it uses iptables as explained here, but I think I'm doing it wrong because the error is getting worse. (https://docker-mailserver.github.io/docker-mailserver/latest/config/debugging/)

Could it be that I am still running an old operating system like CentOS 7 with firewall-cmd as firewall?

👟 Reproduction Steps

"docker exec -it mail setup fail2ban ban IP" works, but when I do a test for example with "telnet IP 25" and generate several login errors, fail2ban detects this attempt but fails to block the IP.

🐋 DMS Version

v12.1.0

💻 Operating System and Architecture

CentOS 7

⚙️ Container configuration files

ports:
    -   "25:25"
    -   "110:110"
    -   "143:143"
    -   "587:587"
    -   "993:993"
    -   "995:995"
    -   "465:465"
    volumes:
    - $HOME/mailserver/mail/:/var/mail/
    - $HOME/mailserver/mail-state/:/var/mail-state/
    - $HOME/mailserver/logs/:/var/log/mail/
    - $HOME/mailserver/config/:/tmp/docker-mailserver/
    environment:
    -   "TZ=Europe/Madrid"
    -   "OVERRIDE_HOSTNAME=****"
    -   "DMS_DEBUG=1"
    -   "LOG_LEVEL=info"
    -   "SUPERVISOR_LOGLEVEL=info"
    -   "ONE_DIR=1"
    -   "POSTMASTER_ADDRESS=****"
    -   "PERMIT_DOCKER=connected-networks"
    -   "TLS_LEVEL="
    -   "SPOOF_PROTECTION="
    -   "ENABLE_SRS=0"
    -   "ENABLE_POP3=1"
    -   "ENABLE_CLAMAV=0"
    -   "ENABLE_FAIL2BAN=1"
    -   "ENABLE_MANAGESIEVE="
    -   "POSTSCREEN_ACTION=enforce"
    -   "SMTP_ONLY="
    -   "SSL_TYPE=manual"
    -   "SSL_CERT_PATH=/tmp/ssl/DNSCerts/live/****/fullchain.pem"
    -   "SSL_KEY_PATH=/tmp/ssl/DNSCerts/live/****/privkey.pem"
    -   "VIRUSMAILS_DELETE_DELAY="
    -   "ENABLE_POSTFIX_VIRTUAL_TRANSPORT="
    -   "POSTFIX_DAGENT="
    -   "POSTFIX_MAILBOX_SIZE_LIMIT=5368706371"
    -   "POSTFIX_MESSAGE_SIZE_LIMIT=26214400"
    -   "PFLOGSUMM_TRIGGER=daily_cron"
    -   "PFLOGSUMM_RECIPIENT=****"
    -   "PFLOGSUMM_SENDER="
    -   "LOGWATCH_INTERVAL=weekly"
    -   "LOGWATCH_RECIPIENT="
    -   "REPORT_RECIPIENT=0"
    -   "REPORT_SENDER="
    -   "REPORT_INTERVAL=weekly"
    -   "POSTFIX_INET_PROTOCOLS=ipv4"
    -   "ENABLE_SPAMASSASSIN=1"
    -   "SPAMASSASSIN_SPAM_TO_INBOX=1"
    -   "MOVE_SPAM_TO_JUNK=1"
    -   "SA_TAG=2.0"
    -   "SA_TAG2=6.31"
    -   "SA_KILL=6.31"
    -   "SA_SPAM_SUBJECT=***SPAM*****"
    -   "ENABLE_FETCHMAIL=0"
    -   "FETCHMAIL_POLL=300"
    -   "ENABLE_POSTGREY=0"
    -   "POSTGREY_DELAY=300"
    -   "POSTGREY_MAX_AGE=35"
    -   "POSTGREY_TEXT=Delayed by postgrey"
    -   "POSTGREY_AUTO_WHITELIST_CLIENTS=5"
    -   "SASL_PASSWD="
    -   "SRS_SENDER_CLASSES=envelope_sender"
    -   "SRS_EXCLUDE_DOMAINS="
    -   "SRS_SECRET="
    -   "DEFAULT_RELAY_HOST="
    -   "RELAY_HOST="
    -   "RELAY_PORT="
    -   "RELAY_USER="
    -   "RELAY_PASSWORD="
    -   "ENABLE_QUOTAS=1"

📜 Relevant log output

2023-10-09 01:15:26,064 fail2ban.actions        [788]: NOTICE  [dovecot] Restore Ban *IP*
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- exec: nft add table inet f2b-table
nft -- add chain inet f2b-table f2b-chain \{ type filter hook input priority -1 \; \}
nft add set inet f2b-table addr-set-dovecot \{ type ipv4_addr\; flags interval\; \}
for proto in $(echo 'tcp' | sed 's/,/ /g'); do
nft add rule inet f2b-table f2b-chain $proto dport \{ $(echo 'pop3,pop3s,imap,imaps,submission,465,sieve' | sed s/:/-/g) \} ip saddr @addr-set-dovecot drop
done
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- stderr: 'Error: Could not process rule: Numerical result out of range'
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- stderr: 'add set inet f2b-table addr-set-dovecot { type ipv4_addr; flags interval; }'
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- stderr: '^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^'
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- stderr: 'Error: No such file or directory'
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- stderr: 'add rule inet f2b-table f2b-chain tcp dport { pop3,pop3s,imap,imaps,submission,465,sieve } ip saddr @addr-set-dovecot drop'
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- stderr: '                                                                                                    ^^^^^^^^^^^^^^^^^'
2023-10-09 01:15:26,077 fail2ban.utils          [788]: ERROR   7f545417b5a0 -- returned 1
2023-10-09 01:15:26,077 fail2ban.actions        [788]: ERROR   Failed to execute ban jail 'dovecot' action 'nftables-multiport' info 'ActionInfo({'ip': '*IP*', 'family': 'inet4', 'fid': <function Actions.ActionInfo.<lambda> at 0x7f5455826f70>, 'raw-ticket': <function Actions.ActionInfo.<lambda> at 0x7f5455825670>})': Error starting action Jail('dovecot')/nftables-multiport: 'Script error'

Improvements to this form?

No response

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions