linux – 使用IPTables限制每个源IP的ICMP

前端之家收集整理的这篇文章主要介绍了linux – 使用IPTables限制每个源IP的ICMP前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
错误地认为限制模块是每个源IP,但它似乎是基于所有请求:
  1. 577 36987 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 3/sec burst 5
  2. 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:'
  3. 46 3478 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8
  4. ...
  5. 0 0 ACCEPT icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8 limit: avg 3/sec burst 5
  6. 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:'
  7. 0 0 DROP icmp -- * * 0.0.0.0/0 0.0.0.0/0 icmp type 8

如何根据源IP地址使用iptables / netfilter对icmp进行速率限制?

解决方法

如果你仍然想知道一个提示
  1. 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中找到的那样.

猜你在找的Linux相关文章