iptables 的 limit 模組使用

目的: 希望每分鐘只允許10個ICMP封包

設定
iptables -A INPUT -p icmp --icmp-type 8 -m limit --limit 6/m --limit-burst 10 -j ACCEPT
iptables -A INPUT -p icmp --icmp-type 8 -j DROP
-m limit 就是代表要使用 limit 這個功能

--limit 6/m 代表每分鐘只允許6個icmp

--limit-burst 10 代表每分鐘只允許10個icmp

是不是覺得很怪,到底是只允許6個還是10個 ??

實際舉例

PING 10.10.10.168 (10.10.10.168) 56(84) bytes of data.
64 bytes from 10.10.10.168: icmp_seq=0 ttl=64 time=4.10 ms
64 bytes from 10.10.10.168: icmp_seq=1 ttl=64 time=0.286 ms
64 bytes from 10.10.10.168: icmp_seq=2 ttl=64 time=0.281 ms
64 bytes from 10.10.10.168: icmp_seq=3 ttl=64 time=0.261 ms
64 bytes from 10.10.10.168: icmp_seq=4 ttl=64 time=0.262 ms
64 bytes from 10.10.10.168: icmp_seq=5 ttl=64 time=0.365 ms
64 bytes from 10.10.10.168: icmp_seq=6 ttl=64 time=0.325 ms
64 bytes from 10.10.10.168: icmp_seq=7 ttl=64 time=0.239 ms
64 bytes from 10.10.10.168: icmp_seq=8 ttl=64 time=0.261 ms
64 bytes from 10.10.10.168: icmp_seq=9 ttl=64 time=0.244 ms
64 bytes from 10.10.10.168: icmp_seq=10 ttl=64 time=0.295 ms
64 bytes from 10.10.10.168: icmp_seq=20 ttl=64 time=0.313 ms
64 bytes from 10.10.10.168: icmp_seq=30 ttl=64 time=0.254 ms
64 bytes from 10.10.10.168: icmp_seq=40 ttl=64 time=0.305 ms
64 bytes from 10.10.10.168: icmp_seq=50 ttl=64 time=0.263 ms
64 bytes from 10.10.10.168: icmp_seq=60 ttl=64 time=0.321 ms
64 bytes from 10.10.10.168: icmp_seq=70 ttl=64 time=0.300 ms
64 bytes from 10.10.10.168: icmp_seq=80 ttl=64 time=0.368 ms
一個開ping時,可以看到完整的10個icmp回應,但到了第11個就timeout了,所以設定就是達到每分鐘只允許10個icmp

但6是用來作什麼的? 

ping剛好預設是每秒發一次封包,當超過burst 10後,都是每10秒得到一個回應,如此一來是不是60秒內有6回應,就符合每分鐘6個icmp了。

那多久時間解除這個限制呢,6 x 10 = 60,60秒後完全解除(但也要在你不再ping了之後)
標籤: iptables limit
評論: 0 | 引用: 0 | 閱讀: 828 | 列印 | 文件 | 轉發

發表評論
暱 稱: 密 碼:
網 址: E - mail:
驗證碼: 驗證碼圖片 選 項:
頭 像:
內 容:
  • 粗體
  • 斜體
  • 底線
  • 插入圖片
  • 超連結
  • 電子郵件
  • 插入引用
  • 表情符號