我已经在Centos 7上运行了iptables,使用版本v1.4.21,但也在v1.6.0上进行了测试(请注意,我没有重建内核,因为它说我不再需要扩展).
@H_404_19@我设置了一个配额,它被使用:
@H_301_3@# iptables -nvx -L 192.168.2.5 Chain 192.168.2.5 (2 references) pkts bytes target prot opt in out source destination 3639 3999378 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 4000000 bytes 142 175468 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 #然后,当我向此链添加任何其他规则时,现有规则“重置”字节使用情况并再次使用配额:
@H_301_3@# iptables -I 192.168.2.5 -m quota --quota 1000 -j ACCEPT # iptables -nvx -L 192.168.2.5 Chain 192.168.2.5 (2 references) pkts bytes target prot opt in out source destination 2 168 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 1000 bytes 7239 7998334 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 4000000 bytes 890 387931 DROP all -- * * 0.0.0.0/0 0.0.0.0/0即使未超出此限制,此行为也始终会将配额量添加到规则中,即使我正在影响其他规则:
@H_301_3@# iptables -nvx -L 192.168.2.5 Chain 192.168.2.5 (2 references) pkts bytes target prot opt in out source destination 379 67755 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 4000000 bytes 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 # iptables -I 192.168.2.5 -m quota --quota 1000 -j ACCEPT # iptables -nvx -L 192.168.2.5 Chain 192.168.2.5 (2 references) pkts bytes target prot opt in out source destination 2 168 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 1000 bytes 379 67755 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 4000000 bytes 0 0 DROP all -- * * 0.0.0.0/0 0.0.0.0/0 # iptables -nvx -L 192.168.2.5 Chain 192.168.2.5 (2 references) pkts bytes target prot opt in out source destination 11 924 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 1000 bytes 4159 4066453 ACCEPT all -- * * 0.0.0.0/0 0.0.0.0/0 quota: 4000000 bytes 315 190056 DROP all -- * * 0.0.0.0/0 0.0.0.0/0有任何想法吗?
我的一个解决方法是自己捕获字节并将它们添加到新规则的配额中.当它已经超过时,它运行良好,但如果没有,由于读取,计算,删除和添加之间的差距,我可能会错过字节.