I have got the following scenario:
I have a Linux box with two NICs and all network traffic comes in trough one NIC and goes out to the other one. So basically I'm already the man in the middle.
But now, I want to redirect all traffic which has the destination IP-address "xyz" and target port 500 to port 500 on my local machine, where my own deamon is running. Then after a certain event I want to stop the redirection (by just removing the rule or so) and just let the traffic pass, like all other traffic.
I wonder whether I can do this with iptables or some other tool already included in Linux? So far I have not found a working solution. I also have problems to run commands as root from a shell script I invoked with system()
. It doesn't start as root even though I changed the ownership and privileges of the script to root. I wanted to use the shellscript to revoke the redirection (when I manage to get it working).