我正在尝试将 fail2ban 与 MYSQL 5.7.19 一起使用
error.log 显示如下条目:
2017-10-03T19:17:45.014850Z 127207 [Note] Access denied for user 'trafic'@'localhost' (using password: YES)
2017-10-03T19:17:46.222136Z 127209 [Note] Access denied for user 'user'@'localhost' (using password: YES)
2017-10-03T19:17:47.440388Z 127211 [Note] Access denied for user 'user'@'localhost' (using password: YES)
2017-10-03T19:17:48.625799Z 127213 [Note] Access denied for user 'wordpress'@'localhost' (using password: YES)
2017-10-03T19:17:49.849088Z 127219 [Note] Access denied for user 'root'@'localhost' (using password: YES)
error.log 中既没有捕获任何 IP,也没有显示为警告,而是记录为[note]
我已经设置log-warnings =2了mysqld.cnf
谢谢。
更新:我从 mysql error.log 这些日志来自同一个 ip 超过 20 次。
2017-10-04T14:35:45.932144Z 218879 [Note] Access denied for user 'root'@'123.129.218.64' (using password: YES)
2017-10-04T14:35:46.551180Z 218881 [Note] Access denied for user 'root'@'123.129.218.64' (using password: YES)
2017-10-04T14:35:47.169756Z 218882 [Note] Access denied for user 'root'@'123.129.218.64' (using password: YES)
我的fail2ban过滤器代码是这样的:
[Definition]
_daemon = mysqld
failregex = ^%(__prefix_line)s(\d{6} \s?\d{1,2}:\d{2}:\d{2} )?\[Warning\] Access denied for user '\w+'@'<HOST>' (to database '[^']*'|\(using password: (YES|N$
ignoreregex =
和 jail.conf 看起来像这样:
[mysql]
enabled = true
port = 3306
filter = mysqld-auth
logpath = /var/log/mysql/error.log
maxretry = 3
但fail2ban 没有接受失败的尝试。
我还在浏览器中使用 PhpMyadmin 多次尝试错误的用户。所以它会自动添加localhost到用户,即使我正在远程尝试。
所以问题是我可以在 PhpMyadmin 中尝试无数次尝试失败而不会被禁止。