运行在Ubuntu14.04服务器上。
因此,我已经将fail2ban正确地配置为处理SSH登录尝试的/var/log/auth.log。
在3次失败的尝试中,我在fail2ban日志中看到了这一点:
2014-11-19 15:22:56,822 fail2ban.actions: WARNING [ssh] Ban BANNED_IP_ADDYiptables -L显示了这条链:
Chain fail2ban-ssh (1 references)
target prot opt source destination
REJECT all -- BANNED_IP_ADDY anywhere reject-with icmp-port-unreachable
RETURN all -- anywhere anywhere然而,从那个IP,我仍然可以通过SSH登录,没有任何问题。
同样的故事也适用于我所有的fail2ban监狱。例如,我可以看到fail2ban正确地检测到日志并声称它禁止IP。IP在iptables链中结束,但IP实际上并没有被拒绝。
在这些情况下,我有一种感觉,因为SSH不在标准端口上。它在另一个港口。
因此,如果我强制ssh监狱规则使用新端口:
[ssh]
enabled = true
port = 32323
filter = sshd
logpath = /var/log/auth.log
maxretry = 5然后我看到了这个错误:
2014-11-19 15:30:06,775 fail2ban.actions.action: ERROR iptables -D INPUT -p tcp -m multiport --dports 32323 -j fail2ban-ssh
iptables -F fail2ban-ssh
iptables -X fail2ban-ssh returned 400
2014-11-19 15:30:06,778 fail2ban.actions.action: ERROR iptables -N fail2ban-ssh
iptables -A fail2ban-ssh -j RETURN
iptables -I INPUT -p tcp -m multiport --dports 32323 -j fail2ban-ssh returned 400
2014-11-19 15:30:06,779 fail2ban.actions.action: ERROR iptables -n -L INPUT | grep -q 'fail2ban-ssh[ \t]' returned 100
2014-11-19 15:30:06,780 fail2ban.actions.action: CRITICAL Unable to restore environment如果我把它当作
port = ssh然后,它正确地进入iptable,但是链不能工作于REJECT流量(如上面提到的)。
如果我改变了:
banaction = iptables-multiport至:
banaction = iptables-allports然后它看起来就起作用了。这种变化的影响是什么?
看来,由于SSH导致fail2ban禁止IP,而这个allports禁止该IP的每个端口。故意被禁止,因为重复的ssh登录失败。其他任何服务都被禁止了。
发布于 2022-12-05 20:27:44
我只是遇到了同样的问题,这就是解决办法。使用banaction =禁用的默认ssh端口是22。我想你和我一样改变了默认的ssh端口。
只需将正确的端口指向sshd配置即可。
[sshd]
enabled = true
banaction = iptables-multiport
port = ###
....发布于 2019-10-18 19:28:02
INPUT -p tcp -m multiport --dports 22 -j fail2ban-sshhttps://serverfault.com/questions/645628
复制相似问题