我search了,我无法find一个规则来限制每秒和每IP的inputUDP端口的传入数据包的计数。
我需要每个连接到我的套接字的IP ,而不是一个特定的 IP 。
我在Ubuntu 14.0.4 LTS amd64上使用iptables。
我很熟悉UDP是如何工作的。 在我的情况下,有人可以使用不同的端口创build大量的UDP套接字。
我只需要一个IP就可以连接到我的UDP端口。
这可能与iptables? 我知道Netfilter和C ++,我可以这样做吗?
以下是你可以做的事情:
iptables -A INPUT -p udp -s 111.111.111.111 --dport 123 -m limit --limit 25/minute --limit-burst 100 -j ACCEPT
你需要限制 iptables扩展。 提供的示例限制了每分钟最多25个连接。 limit-burst 100表示限制/分钟只有在连接总数达到极限突发电平后才被执行。
从手册:
-s, --source address[/mask][,...] Source specification. Address can be either a network name, a hostname, a network IP address (with /mask), or a plain IP address. Hostnames will be resolved once only, before the rule is submitted to the kernel. Please note that specifying any name to be resolved with a remote query such as DNS is a really bad idea. The mask can be either an ipv4 network mask (for iptables) or a plain number, specifying the number of 1's at the left side of the network mask. Thus, an iptables mask of 24 is equivalent to 255.255.255.0. A "!" argument before the address specification inverts the sense of the address. The flag --src is an alias for this option. Multiple addresses can be specified, but this will expand to multiple rules (when adding with -A), or will cause multiple rules to be deleted (with -D).