Fail2Ban 测试

Bth*_*Bth 2 fail2ban apache-2.2

运行以下测试脚本以查看 Fail2ban 是否正常工作:

fail2ban-regex /var/log/apache*/*access.log /etc/fail2ban/filter.d/apache-auth.conf
Run Code Online (Sandbox Code Playgroud)

我得到这个回应:

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

Use ignoreregex line : /etc/fail2ban/filter.d/apache-badbots                                                                                
No section headers in /var/log/apache2/other_vhosts_access.log  
Run Code Online (Sandbox Code Playgroud)

它没有运行我的日志的测试扫描。我已经使用类似的语法测试了我的 SSH fail2ban 设置并且它的测试很好。不知道我做错了什么。

use*_*517 5

我认为您遇到的问题是由于外壳扩展的方式

/var/log/apache*/*access.log
Run Code Online (Sandbox Code Playgroud)

我想你/etc/fail2ban/filter.d/apache-auth.conf也是这么想的。

尝试在该参数周围加上单引号

fail2ban-regex '/var/log/apache*/*access.log' /etc/fail2ban/filter.d/apache-auth.conf
Run Code Online (Sandbox Code Playgroud)

这会将它传递给fail2ban-regex.


进一步研究 - 它看起来不像fail2ban-regex通配符:

fail2ban-regex '/var/log/apache*/*access.log' /etc/fail2ban/filter.d/apache-auth.conf
...
Use regex file : /etc/fail2ban/filter.d/apache-auth.conf
Use single line: /var/log/apache*/*access.log
Run Code Online (Sandbox Code Playgroud)

请注意,它认为我们正在传递一行,然后尝试

fail2ban-regex /var/log/apache2/access.log /etc/fail2ban/filter.d/apache-auth.conf    
...
Use regex file : /etc/fail2ban/filter.d/apache-auth.conf
Use log file   : /var/log/apache2/access.log
Run Code Online (Sandbox Code Playgroud)

请注意,它看到我们传递了一个日志文件。

  • @Bth - 如果此 A 解决了您的问题,您可以将其标记为已接受的 A,以便每个人都知道这是解决方案。 (4认同)