Topic: How to permanently ban spamming IPs
==== REQUIRED BASIC INFO OF YOUR IREDMAIL SERVER ====
- iRedMail version (check /etc/iredmail-release): 1.5.1
- Deployed with iRedMail Easy or the downloadable installer? Downloadable installer
- Linux/BSD distribution name and version: Debian 11
- Store mail accounts in which backend (LDAP/MySQL/PGSQL): MariaDB
- Web server (Apache or Nginx): Nginx
- Manage mail accounts with iRedAdmin-Pro? No
- [IMPORTANT] Related original log or error message is required if you're experiencing an issue.
====
I would like to implement a method for permanently banning connections from IP addresses that persistently try to deliver spam. I have a method that works but would appreciate suggestions for something more elegant.
What I'm currently doing, for each IP to be banned, is to insert a firewall rule at an appropriate position:
nft add rule inet filter input position 12 ip saddr x.x.x.x/32 drop
then, to make the ban persistent across reboots, edit /etc/nftables.conf to insert, early in the input chain:
ip saddr x.x.x.x drop
Is there a better way, perhaps using fail2ban?
----
Spider Email Archiver: On-Premises, lightweight email archiving software developed by iRedMail team. Supports Amazon S3 compatible storage and custom branding.