Fail2ban严重exception – 不会阻止ips

我试图在CentOS7上运行fail2ban(没有SELinux),它使用firewalld。 我的目标是将其设置为禁止Asterisk密码失败。

安装程序是默认的yum install fail2ban

configuration方面我只加了jail.local以下内容:

[DEFAULT] backend = systemd banaction = firewallcmd-ipset destemail = [email protected] sender = [email protected] [asterisk] enabled = true #filter = asterisk #logpath = /var/log/asterisk/messages maxretry = 5 bantime = 86400 

现在,当我重新启动fail2ban服务,我得到这样的fail2ban.log条目:

 2015-04-26 13:35:18,149 fail2ban.server [2820]: INFO Changed logging target to /var/log/fail2ban.log for Fail2ban v0.9.1 2015-04-26 13:35:18,151 fail2ban.database [2820]: INFO Connected to fail2ban persistent database '/var/lib/fail2ban/fail2ban.sqlite3' 2015-04-26 13:35:18,158 fail2ban.jail [2820]: INFO Creating new jail 'asterisk' 2015-04-26 13:35:18,182 fail2ban.jail [2820]: INFO Jail 'asterisk' uses systemd 2015-04-26 13:35:18,213 fail2ban.jail [2820]: INFO Initiated 'systemd' backend 2015-04-26 13:35:18,220 fail2ban.filter [2820]: INFO Set maxRetry = 5 2015-04-26 13:35:18,222 fail2ban.actions [2820]: INFO Set banTime = 86400 2015-04-26 13:35:18,223 fail2ban.filter [2820]: INFO Set findtime = 600 2015-04-26 13:35:18,309 fail2ban.filtersystemd [2820]: NOTICE Jail started without 'journalmatch' set. Jail regexs will be checked against all journal entries, which is not advised for performance reasons. 2015-04-26 13:35:18,331 fail2ban.jail [2820]: INFO Jail 'asterisk' started 2015-04-26 13:35:18,488 fail2ban [2820]: CRITICAL Unhandled exception in Fail2Ban: Traceback (most recent call last): File "/usr/lib/python2.7/site-packages/fail2ban/server/jailthread.py", line 64, in run_with_except_hook run(*args, **kwargs) File "/usr/lib/python2.7/site-packages/fail2ban/server/filtersystemd.py", line 244, in run *self.formatJournalEntry(logentry)) File "/usr/lib/python2.7/site-packages/fail2ban/server/filtersystemd.py", line 172, in formatJournalEntry 'SYSLOG_PID', logentry['_PID'])) KeyError: '_PID' 2015-04-26 13:35:19,211 fail2ban.actions [2820]: NOTICE [asterisk] Ban 212.129.1.26 2015-04-26 13:35:19,534 fail2ban.actions [2820]: NOTICE [asterisk] Ban 212.83.187.182 

我不明白什么是缺less的。 这2个“禁止”在日志中的行动实际上并没有发生(我仍然看到在Asterisk日志中的这些IP的尝试)

我想你在这里走错了路。 Asterisk正在从简单的安全事件日志(转向平面文件),转而通过AMI转向安全事件。 考虑基于AMI事件的阻塞,而不是在安全日志上。 有许多免费的替代fail2ban(例如,看http://www.voip-info.org/wiki/view/Asterisk+security )。

更重要的是,随着Asterisk从SIP更改为PJSIP,日志消息已经改变(并且仍在改变),所以你将经常不断更新你的正则expression式条目,否则安全事件可能会滑过你的fail2ban设置。 这是一个鼹鼠的方法…

在你的asteriskconfiguration块中,你有filterlogpath选项。 这可能是为什么该应用程序抱怨。 validationpath,并忽略这两个块。