【发布时间】:2015-01-07 14:53:59
【问题描述】:
我正在使用 fail2ban 来阻止我的服务器上的失败登录尝试。该块是使用具有以下配置的 IP 表执行的:
actionstart = iptables -N fail2ban
iptables -A fail2ban -j RETURN
iptables -I <chain> -p tcp -m multiport --dports <port> -j fail2ban
actionstop = iptables -D <chain> -p tcp -m multiport --dports <port> -j fail2ban
iptables -F fail2ban
iptables -X fail2ban
actionban = iptables -I fail2ban 1 -s <ip> -j DROP
actionunban = iptables -D fail2ban -s <ip> -j DROP
我关心的是规则处理性能。上述规则处于有状态模式,我一直想知道无状态模式是否会使处理速度更快。为了清楚起见,我在 TCP 端口(例如 22 或 25)上阻止了入侵者 IP 地址。
我在某处读到,对于 TCP 连接,添加 ESTABLISHED,RELATED 状态会更好。但是由于每个 IP 都指向不同的连接,那么应用这些状态是否有意义?
更新:
这是一个示例iptables -L:
Chain INPUT (policy ACCEPT 399 packets, 36043 bytes)
pkts bytes target prot opt in out source destination
39 4230 fail2ban tcp -- * * 0.0.0.0/0 0.0.0.0/0 multiport dports 22,25,80,99,100,101
Chain FORWARD (policy ACCEPT 0 packets, 0 bytes)
pkts bytes target prot opt in out source destination
Chain OUTPUT (policy ACCEPT 282 packets, 39686 bytes)
pkts bytes target prot opt in out source destination
Chain fail2ban (1 references)
pkts bytes target prot opt in out source destination
0 0 DROP all -- * * 192.168.0.1 0.0.0.0/0
0 0 DROP all -- * * 192.168.0.2 0.0.0.0/0
0 0 DROP all -- * * 192.168.0.3 0.0.0.0/0
0 0 DROP all -- * * 192.168.0.4 0.0.0.0/0
39 4230 RETURN all -- * * 0.0.0.0/0 0.0.0.0/0
【问题讨论】:
标签: performance iptables fail2ban