fall2ban-regexが機能する必要があると言っても、私のカスタムfall2ban刑務所はロードされません。

fall2ban-regexが機能する必要があると言っても、私のカスタムfall2ban刑務所はロードされません。

私のサービスにログインするために、カスタム刑務所とフィルタをFail2banに書きました。ログファイルが見つかり/var/log/motion/motion.log、ログインに失敗すると、次の行が生成されます。

[0:ml1] [ALR] [STR] [Nov 02 11:42:59] handle_basic_auth: motion-stream - failed auth attempt from <ip>

私の刑務所は/etc/fail2ban/jail.local次のとおりです

[motion-auth]

enabled = true
port     = 8008
filter = motion-auth.conf
logpath  = /var/log/motion/motion.log
banaction = %(banaction_allports)s
maxretry = 3
findtime = 10800
bantime = 259200

私の名前付きフィルタは次/etc/fail2ban/filter.dのとおりですmotion-auth.conf

[Definition]
failregex = \[0:ml1\] \[ALR\] \[STR\] \[.*\] handle_basic_auth: motion-stream - failed auth attempt from <HOST>

これを実行すると、fail2ban-regex /var/log/motion/motion.log /etc/fail2ban/filter.d/motion-auth.confフィルタが実際に期待どおりに実行されていることを確認します。

Running tests
=============

Use   failregex filter file : motion-auth, basedir: /etc/fail2ban
Use         log file : /var/log/motion/motion.log
Use         encoding : UTF-8


Results
=======

Failregex: 186 total
|-  #) [# of hits] regular expression
|   1) [186] \[0:ml1\] \[ALR\] \[STR\] \[.*\] handle_basic_auth: motion-stream - failed auth attempt from <HOST>
`-

Ignoreregex: 0 total

Date template hits:
|- [# of hits] date format
|  [2640] (?:DAY )?MON Day %k:Minute:Second(?:\.Microseconds)?(?: ExYear)?
`-

Lines: 2929 lines, 0 ignored, 186 matched, 2743 missed
[processed in 1.06 sec]

ただし、新しいフィルタを追加するためにFail2banを再ロード/再起動しようとすると、次のメッセージが表示されます。

Found no accessible config files for 'filter.d/motion-auth.conf' under /etc/fail2ban
 Unable to read the filter 'motion-auth.conf'
 Errors in jail 'motion-auth'. Skipping...
OK

私が間違っていることを知っている人はいますか?

ベストアンサー1

jam.confでは、フィルタ行はファイル名ではなく名前と一緒に使用する必要があります。このように:

[motion-auth]
...
filter = motion-auth

おすすめ記事