Mail::...ail2Ban(3pm)
β¨ Mail::MtPolicyd::Plugin::Fail2Ban β¨
okay bestie, so this is a page from the User Contributed Perl Documentation for the perl manual section 3pm β yes the title up top is literally Mail::...ail2Ban(3pm), the terminal just truncates it because it's dramatic like that π
anyway. Sit down, grab a strawberry π, we're talking about the mtpolicyd plugin that gets fail2ban to block an address.
π NAME π
Mail::MtPolicyd::Plugin::Fail2Ban β it's the mtpolicyd plugin that blocks an address with fail2ban. that's the whole vibe. no cap.
πΈ VERSION πΈ
version 2.05
π¦ DESCRIPTION π¦
So this plugin lets you block an ip using iptable by way of the fail2ban daemon. iconic behavior honestly π₯
If you wanna know more about fail2ban, go read:
http://www.fail2ban.org/
Here's the tea: this plugin doesn't do anything sneaky or indirect. It talks directly to the daemon through the unix domain socket and runs a banip command:
set <JAIL> banip <IP>
periodt. that's the move π
π PARAMETERS π
socket(default:/var/run/fail2ban/fail2ban.sock) β the path to the fail2ban unix socket.
okay so listen β make sure mtpolicyd is actually allowed to write to this socket! if it can't, nothing works and you'll be sad π
jail(default:postfix) β which jail the ip should get banned in. pick your fighter π
π EXAMPLE π
Say you wanna execute a ban on all client-ips that send a mail with a score of >=15. Look at this beauty:
<Plugin ScoreBan>
module = "ScoreAction"
threshold = 15
<Plugin ban-ip>
module = "Fail2Ban"
socket = "/var/run/fail2ban/fail2ban.sock"
jail = "postfix"
</Plugin>
</Plugin>
ate. no notes. π
π§ FAIL2BAN CONFIGURATION π§
For mtpolicyd to be able to access fail2ban, you have to make sure fail2ban can write to the fail2ban unix socket. Yeah, that's the sentence. Run these:
chgrp mtpolicyd /var/run/fail2ban/fail2ban.sock
chmod g+rwx /var/run/fail2ban/fail2ban.sock
You may wanna add this to the fail2ban startup script, so you don't have to keep doing it like a little gremlin π
You may also wanna use the predefined postfix jail. To activate it, create /etc/fail2ban/jail.local and enable the postfix fail by setting enabled=true:
[postfix]
enabled = true
and boom, that's the setup. slay β¨
β AUTHOR β
Markus Benning <ich@markusbenning.de>
π COPYRIGHT AND LICENSE π
This software is Copyright (c) 2014 by Markus Benning <ich@markusbenning.de>.
This is free software, licensed under:
The GNU General Public License, Version 2, June 1991
and that's the whole page bestie!! ππ«Ά this gorgeous little manpage is perl v5.38.2, dated 2024-05-26, and it lives in the Mail::...ail2Ban(3pm) slot in your terminal. go forth and ban some ips, iykyk πΈπ¦π
π¦ where this page comes from
- debian trixie: mtpolicyd 2.05-1.2 Β· GPL-2.0-only
- ubuntu questing: mtpolicyd 2.05-1.2
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms