Linux – Simulate a bad TCP connection with iptables

iptableslinuxport-forwardingtcp

I want to forward TCP connections on a certain port of the machine A to another port on the machine B (which is actually the same that originated the connection to machine A) and simulate random or deterministic packet drops.

How can I do it with iptables?

Best Answer

man what? right, man iptables:

statistic

This module matches packets based on some statistic condition. It supports two distinct modes settable with the --mode option.

or

random

This module randomly matches a certain percentage of all packets. --average percent Matches the given percentage. If omitted, a probability of 50% is set.