linux – 使用IPTables限制每个源IP的ICMP
发布时间:2020-12-13 18:15:07 所属栏目:Linux 来源:网络整理
导读:我错误地认为限制模块是每个源IP,但它似乎是基于所有请求: 577 36987 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 3/sec burst 5 46 3478 LOG icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 LOG flags 0 level 4 prefix `INET-PING-DRO
我错误地认为限制模块是每个源IP,但它似乎是基于所有请求:
577 36987 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 3/sec burst 5 46 3478 LOG icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 LOG flags 0 level 4 prefix `INET-PING-DROP:' 46 3478 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 ... 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 3/sec burst 5 0 0 LOG icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 LOG flags 0 level 4 prefix `WEB-PING-DROP:' 0 0 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 如何根据源IP地址使用iptables / netfilter对icmp进行速率限制? 解决方法
如果你仍然想知道一个提示:
iptables -I INPUT -p icmp -m hashlimit --hashlimit-name icmp --hashlimit-mode srcip --hashlimit 3/second --hashlimit-burst 5 -j ACCEPT 假设INPUT中的最后一个规则是drop或默认策略是DROP.每个ip限制为每秒3次ping(突发5次).并非所有传入的IP总数,正如您在-m limit中找到的那样. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |