- A tcp packet arrives on eth0 with destination 22.214.171.124.
- This packet meets some criteria that makes me want to intercept it (lets say I am interested in all packets from source 10.0.0.5 or all packets on port 80).
- The packet is singled out with an iptables rule so that I can do something funky to it.
Rather than ignoring the packet or routing it to its correct destination, what can I do to send it to the local ip stack so that any program listening on the correct port recieves it?
To clarify: I do not want to modify the destination ip of the packet, and I do not want to spoof the destination ip to the whole network - I only want to steal packets I can match with an iptables rule.
I have tried iptables -j REDIRECT but it seems either not to be able to do this
I have also thought of creating a temporary interface that accepts packets from all ips and using iptables to sent the packets of intrest to it, but according to what I have read that will cause linux to seal every packet it sees because it thinks it has a valid destination ip for all of them, even if routing is turned off.
The solution does not have to be exclusive to tcp as long as it works with tcp.
Is there any way to do this?