最近的模块,首选rcheck或更新?

假设我有以下规则:

iptables -P INPUT DROP iptables -P FORWARD ACCEPT iptables -P OUTPUT ACCEPT iptables -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT iptables -A INPUT -p tcp -m conntrack --ctstate NEW -m tcp --dport 22 -m recent --set --name counting1 --rsource iptables -A INPUT -m recent --update --seconds 60 --hitcount 2 --name counting1 --rsource -j LOG --log-prefix "SSH ataque " iptables -A INPUT -m recent --update --seconds 60 --hitcount 2 --name counting1 --rsource -j RETURN -A INPUT -j ACCEPT 

我已经阅读了手册,但是我仍然不清楚在什么情况下最好使用–rcheck或–update选项…更新意味着hitcount被重置为0并重新启动(如上例所示)60秒?

请记住,这些规则只是举例来揭露这个问题

提前致谢

提前致谢

从iptables的手册页:

  [!] --rcheck Check if the source address of the packet is currently in the list. [!] --update Like --rcheck, except it will update the "last seen" timestamp if it matches. 

因此,使用update不会重置hitcount,它会(重新)设置上次看到的时间戳。 以下是关于 – --seconds

  --seconds seconds This option must be used in conjunction with one of --rcheck or --update. When used, this will narrow the match to only happen when the address is in the list and was seen within the last given number of seconds. 

这意味着使用--rcheck使得规则一次只匹配规则中的时间间隔(例如,使用--seconds ),而使用--update会延长匹配规则的时间间隔在间隔期间。

因此,如果每45秒有一个匹配的数据包,问题中显示的示例规则将继续logging数据包并从链路返回。 OTOH如果已经使用了--rcheck ,则每个第二个数据包都不匹配(因为两个匹配数据包的60秒间隔已经过期)。