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>


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