小编dev*_*sda的帖子

丢弃总数的 50% 数据包的方法

在我的机器上,我希望只有 50% 的数据包会收到。

我正在开发 centOS 5.5。

为此,我在网上搜索。我得到了 IPtables。我使用了 IPtables 的随机补丁。

命令

sudo iptables -A INPUT -p icmp --icmp-type echo-request -m random --average 50 -j DROP
Run Code Online (Sandbox Code Playgroud)

输出

iptables v1.3.5: Couldn't load match `random':/lib64/iptables/libipt_random.so: cannot open shared object file: No such file or directory

Try `iptables -h' or 'iptables --help' for more information.
Run Code Online (Sandbox Code Playgroud)

但上面表明该库丢失了。

然后,我怎样才能丢弃总数的 50% 数据包。请更正我的上述方法或建议新的方法。

告诉我如何将这些库添加到 IPtables 现有包中。[我试过了,但在互联网上找不到这些库]

编辑 1

我还需要记录丢弃的数据包,因此我更改了 iptables 规则集,如下所示:

iptables -L -n -v 输出是 [这是在系统 1 上运行]

Chain INPUT (policy ACCEPT 1875K packets, 114M bytes)
 pkts …
Run Code Online (Sandbox Code Playgroud)

linux bash iptables centos packet-capture

3
推荐指数
1
解决办法
7730
查看次数

标签 统计

bash ×1

centos ×1

iptables ×1

linux ×1

packet-capture ×1