如何通过命令行手动禁用带有Fail2Ban的IP?

时间:2015-03-12 19:10:24

标签: command-line ubuntu-14.04 fail2ban

如何通过命令行手动禁用具有Fail2Ban的攻击者IP?

5 个答案:

答案 0 :(得分:103)

sudo fail2ban-client -vvv set JAIL banip WW.XX.YY.ZZ

使用sudo fail2ban-client status

检查jail在哪里添加IP

答案 1 :(得分:6)

手动禁止IP


fail2ban-client set jail_name banip xx.xx.xx.xx


答案 2 :(得分:4)

$ce-product

绝对可以作为手动解决方案。 只需通过ssh登录并执行。

唯一的问题是我一直在" beatify"消息?

也不确定这是否会禁止ip范围,例如输入&#;; 185.130.5'禁止所有范围从&#;; 49.130.5.0'到255?

答案 3 :(得分:0)

我将ipset与iptables一起使用。 ipset允许您将ip地址添加到可以通过iptables实施的黑名单中。 Here is a full explation和以下示例:

# install it
apt-get install ipset

# create a blacklist
ipset create blacklist hash:ip hashsize 4096

# add the blacklist to your iptables rules
iptables -I INPUT -m set --match-set blacklist src -j DROP
iptables -I FORWARD -m set --match-set blacklist src -j DROP

# check that rule is set in iptables
iptables -L

# now add the offending ip address
ipset add blacklist ip.address

# check that the ip address is in your blacklist
ipset list blacklist

您都准备好了。

答案 4 :(得分:-2)

您通过将他的IP添加到防火墙手动禁止他。如果您使用的是UFW,那么您可以在命令行中编写类似的内容:

ufw insert 1 deny from <ip> to any

但你不想手动执行此操作 - Fail2Ban的目的是自动禁止某人。使用this教程配置Fail2Ban以自动更新您的UFW规则。重要的是将banaction = ufw-SOMETHING添加到jail.conf,然后在ufw-SOMETHING.conf文件夹中创建/etc/fail2ban/action.d/,其中包含以下内容:

[Definition]
actionstart =
actionstop =
actioncheck =
actionban = ufw insert 1 deny from <ip> to any
actionunban = ufw delete deny from <ip> to any

这将在预定义的时间内完全禁止IP。如果要在下次重新启动之前禁止他,请省略actionunban命令。