What's new

Iptable command to cause packet loss

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

Can you explain your scenario a bit more.

Also, what do you mean by "per IP address", an IP address on your LAN? Unsolicited traffic from the internet will be dropped by iptables FORWARD chain. That's 100% packet loss for the sender.
 
Can you explain your scenario a bit more.

Also, what do you mean by "per IP address", an IP address on your LAN? Unsolicited traffic from the internet will be dropped by iptables FORWARD chain. That's 100% packet loss for the sender.

What I want to do is to randomly drop a percentage of all incoming packets to one of my lan devices, to basically simulate a poor internet connection!
 
I don't think it's possible to do it with iptables on the router because it doesn't have the required modules (statistic or random).
 
HOWTO

Enable the statistic match module in the firmware build configuration
Code:
vi ~/asuswrt-merlin/release/src-rt-6.x.4708/linux/linux-2.6.36/config_base.6a
OLD LINE: # CONFIG_NETFILTER_XT_MATCH_STATISTIC is not set
NEW LINE: CONFIG_NETFILTER_XT_MATCH_STATISTIC=m

Build the firmware
Code:
make clean
make {target-platform}

Copy the new kernel module to your router /jffs/bin folder. My routers is RT-AC68U and RT-AC56U, both ARM architectures. Use 'find' command to search for the kernel module, xt_statistic.ko.
Code:
find ~/asuswrt-merlin -type f -name "xt_statistic.ko"
### here it is:  ~/asuswrt-merlin/release/src/router/arm-uclibc/target/lib/modules/2.6.36.4brcmarm/kernel/net/netfilter/xt_statistic.ko

Now login to the router to install and load the module
Code:
insmod /jffs/bin/xt_statistic.ko
modprobe xt_statistic

Now this works
Code:
iptables -A INPUT -m statistic --mode random --probability 0.1 -j DROP
iptables -A OUTPUT -m statistic --mode random --probability 0.1 -j DROP

Undo it when you're done playing around
Code:
iptables -D INPUT -m statistic --mode random --probability 0.1 -j DROP
iptables -D OUTPUT -m statistic --mode random --probability 0.1 -j DROP


Download: http://www.megafileupload.com/21Eh/xt_statistic_asuswrt-merlin-378.53-arm.rar
MD5: 1bbd3bfc76be38b3a1903d11ffb420bb
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top