Iptables 的阻塞連接會持續多久?有沒有辦法設定超時時間?

Iptables 的阻塞連接會持續多久?有沒有辦法設定超時時間?
iptables -A INPUT -m state --state NEW -m recent --set                  # If we receive more than 10 connections in 10 seconds block our friend.
iptables -A INPUT -m state --state NEW -m recent --update --seconds 5  --hitcount 15 -j Log-N-Drop

我從 iptables 有這兩個相關規則。如果 5 秒內建立的連線超過 15 個,它將記錄該嘗試並阻止它。 iptables 維護計數器多久?如果再次嘗試連接,它會刷新嗎?

答案1

如果 5 秒內建立的連線超過 15 個,則它們的連線將被拒絕,直到收到最後一個資料包後 5 秒。

答案2

您可以透過執行以下命令來獲取有關此模組的協助iptables -m recent --help

與您的問題相關的主要選項是:

[!] --update                    Match if source address in list, also update last-seen time.

所以我的理解是,使用 --update 它將刷新,但您需要在刪除之前進行更新。因此,如果它是第一個,它將“過期”。上的例子作者頁面也可能有幫助。如果有更多 IP,以下模組參數也會發揮作用:

ip_list_tot = 100;每個表格記住的地址數量

編輯:老實說,再想一想,我對所有可能的場景都有點困惑。我會透過使用 scapy for fping 之類的工具製作不同的來源 IP 位址來對此進行大量測試。以下模組參數也可能有幫助:

debug=0 ; Set to 1 to get lots of debugging info

也許嘗試過這些選項的人會有更好的答案,抱歉:-/

相關內容