drop incoming/outgoing packets using iptables
Hi,
I am running a java application from my linux machine, which connects over internet to a remote computer on a given port. Now, during the run of the application, if the internet link goes down, then the application behaviour is unpredictable, so I want to reproduce the timeout problem by dropping the incoming and outgoing packets from the given IP using iptables. Following are the rules I am using for dropping the incoming/outgoing packets :
iptables -t mangle -I OUTPUT -p tcp --syn -d 203.88.194.194 -j DROP
iptables -t mangle -I PREROUTING -p tcp --syn -s 203.88.194.194 -j DROP
Now, if I apply these rules before starting my application, then it properly drops the packets and application gives timeout. But let say I haven't applied these rules at the start of the application, (means the IP is not blocked when the application starts), so application connects to the remote IP on the specified port, opens input/output streams on it. If I apply the above rules now to disable the incoming/outgoing traffics from the given IP, then it doesn't work, means it will transfer data on both the input and output streams properly and no timeout comes.
What is the problem here and what would be the work around?
Ankit
|