监狱错误&不会开始

我已经创build了一个监狱和行动,试图捕捉“DDoS攻击”,但是,每当我重新启动Fail2Ban,日志文件显示这个监狱的错误。 监狱和filter看起来相当直接,并在几个博客转载,但我用于比较的一个在这里 。

这是监狱:

[http-get-dos] enabled = true filter = http-get-dos action = iptables[name=Http-Get-Dos, port="http,https"] logpath = %(apache_access_log)s maxretry = 300 findtime = 300 bantime = 300 

这是filter:

 # Fail2Ban configuration file # [Definition] # Option: failregex # Note: This regex will match any GET entry in your logs # You should set up in the jail.conf file, the maxretry and findtime carefully failregex = ^<HOST> -.*"(GET|POST).* # Option: ignoreregex # Notes.: regex to ignore. If this regex matches, the line is ignored. # Values: TEXT # 

这一切看起来很简单,但由于某种原因,如果我启用这个监狱后重新启动服务,我在Fail2ban日志中看到以下错误:

 2017-11-04 12:48:13,296 fail2ban.jail [1460]: INFO Creating new jail 'http-get-dos' 2017-11-04 12:48:13,298 fail2ban.jail [1460]: INFO Jail 'http-get-dos' uses poller 2017-11-04 12:48:13,300 fail2ban.filter [1460]: INFO Set jail log file encoding to UTF-8 2017-11-04 12:48:13,300 fail2ban.jail [1460]: INFO Initiated 'polling' backend 2017-11-04 12:48:13,303 fail2ban.actions [1460]: INFO Set banTime = 300 2017-11-04 12:48:13,304 fail2ban.filter [1460]: INFO Set findtime = 300 2017-11-04 12:48:13,306 fail2ban.filter [1460]: INFO Added logfile = /var/log/apache2/access.log 2017-11-04 12:48:13,308 fail2ban.filter [1460]: INFO Added logfile = /var/log/apache2/other_vhosts_access.log 2017-11-04 12:48:13,309 fail2ban.filter [1460]: INFO Set jail log file encoding to UTF-8 2017-11-04 12:48:13,310 fail2ban.filter [1460]: INFO Set maxRetry = 300 2017-11-04 12:48:14,411 fail2ban.action [1460]: ERROR iptables -w -N f2b-Http-Get-Dos iptables -w -A f2b-Http-Get-Dos -j RETURN iptables -w -I INPUT -p tcp --dport http,https -j f2b-Http-Get-Dos -- stdout: b'' 2017-11-04 12:48:14,441 fail2ban.action [1460]: ERROR iptables -w -N f2b-Http-Get-Dos iptables -w -A f2b-Http-Get-Dos -j RETURN iptables -w -I INPUT -p tcp --dport http,https -j f2b-Http-Get-Dos -- stderr: b"iptables v1.6.0: invalid port/service `http,https' specified\nTry `iptables -h' or 'iptables --help' for more information.\n" 2017-11-04 12:48:14,458 fail2ban.action [1460]: ERROR iptables -w -N f2b-Http-Get-Dos iptables -w -A f2b-Http-Get-Dos -j RETURN iptables -w -I INPUT -p tcp --dport http,https -j f2b-Http-Get-Dos -- returned 2 2017-11-04 12:48:14,463 fail2ban.actions [1460]: ERROR Failed to start jail 'http-get-dos' action 'iptables': Error starting action 2017-11-04 12:48:20,150 fail2ban.jail [1460]: INFO Jail 'http-get-dos' started 

看来,监狱的行动部分是造成了一个问题,但我不明白为什么。 该行动与其他监狱使用的行为相似。

任何想法如何解决这个让监狱正常运行?

我没有足够的评价,所以我会在这里作为答复。

看起来这条线:

action = iptables[name=Http-Get-Dos, port="http,https"]

将variables传递给iptables,并且由于port="http,https"您将在单个iptables规则中指定两个目标端口。 我找不到任何具体的文件,但它看起来不正确,我认为这是问题的原因。

我认为应该有针对HTTP和HTTPS的单独操作。

编辑:我发现在谷歌使用端口=“http,https”一些条目,他们指定iptables多端口,而不是iptables。 iptables-multiport动作似乎用--match multiport ( 在这里描述)运行iptables,允许你一次指定多个端口(参见这个服务器故障问题 )。 所以我认为另一种解决scheme是使用iptables-multiport操作。