Just another IT site ※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。At Your Own Risk!! TURN BACK WHILE YOU CAN
PR

fail2banのメール通知で action = %(action_m)s を実装する(Rocky Linux release 9.5 epelインストール版)

※IT系の記事は当方環境での実施内容となるため実施する場合は自己責任でお願いいたします。スクリプトはAI生成のものも多いのでコピー&ペーストの際は文字コードに注意ください!

Rocky Linux release 9.5 epelインストールで実施。

jail.confをjail.localにまるっとコピーしていた場合は以下のように「action_m」を追加

banaction_allports = iptables-allports

# The simplest action to take: ban only
action_ = %(banaction)s[port="%(port)s", protocol="%(protocol)s", chain="%(chain
)s"]

# ban & send an e-mail to the destemail.
action_m = %(action_)s
           %(mta)s[sender="%(sender)s", dest="%(destemail)s", protocol="%(protoc
ol)s", chain="%(chain)s"]

# ban & send an e-mail with whois report to the destemail.
action_mw = %(action_)s
            %(mta)s-whois[sender="%(sender)s", dest="%(destemail)s", protocol="%
(protocol)s", chain="%(chain)s"]

action_mを使いたいセクションに記載

[recidive]
enabled = true
・
・
・
action = %(action_m)s

以下のようなものが送信されるようになります。

Hi,

The IP XXX.XXX.XXX.XXX has just been banned by Fail2Ban after
5 attempts against recidive.

Regards,

Fail2Ban

 

 

タイトルとURLをコピーしました