我使用以下方法实现了SSH连接速率限制。
iptables -N SSH_BRUTE_FORCE_MITIGATION
iptables -A SSH_BRUTE_FORCE_MITIGATION -m recent --name SSH --set
iptables -A SSH_BRUTE_FORCE_MITIGATION -m recent --name SSH --update --seconds 300 --hitcount 10 -m limit --limit 1/second --limit-burst 100 -j LOG --log-prefix "iptables[ssh-brute-force]: "
iptables -A SSH_BRUTE_FORCE_MITIGATION -m recent --name SSH --update --seconds 300 --hitcount 10 -j DROP
iptables -A SSH_BRUTE_FORCE_MITIGATION -j ACCEPT如何重置速率限制计数器?
编辑:尝试了sudo iptables -Z,但是引发了下面的错误。
$ sudo iptables -Z
[sudo] password for pi:
iptables v1.8.2 (nf_tables): RULE_REPLACE failed (Invalid argument): rule in chain INPUT发布于 2021-04-19 20:49:13
若要重置-m recent --name SSH数据:
echo / | sudo tee /proc/net/xt_recent/SSH来自man 8 iptables-extensions,“最近”一节:
/proc/net/xt_recent/* are the current lists of addresses
and information about each entry of each list.
Each file in /proc/net/xt_recent/ can be read from to see
the current list or written two using the following commands to modify the list:
echo +addr >/proc/net/xt_recent/DEFAULT
to add addr to the DEFAULT list
echo -addr >/proc/net/xt_recent/DEFAULT
to remove addr from the DEFAULT list
echo / >/proc/net/xt_recent/DEFAULT
to flush the DEFAULT list (remove all entries). 这与可以用iptables -Z清除的按规则数据包/字节计数器不一样。
这也不同于-m limit (用于限制速率日志记录)或-m hashlimit计数器。那些不提供这样的proc接口。可能的解决办法:
xt_recent/xt_limit/xt_hashlimit将丢弃相关的数据。--name/--hashlimit-name (追加数字即可) https://serverfault.com/questions/1060841
复制相似问题