我的自定义fail2ban监狱无法加载,即使fail2ban-regex表明它应该可以工作?

我的自定义fail2ban监狱无法加载,即使fail2ban-regex表明它应该可以工作?

我在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

相关内容