iptables port forwarding + remote debugging
Here is the situation:
Machine_A (eth0: 192.168.0.253)
Machine_B (eth0: 192.168.0.100, eth1: 10.0.0.100)
Machine_C (eth1: 10.0.0.3)
I want to remotely debug a process on Machine_C from Machine_A. However, since they are in two different networks, I am trying to setup port forwarding using iptables (192.168.0.100:50003::10.0.0.3:2000), i.e. all requests on port 50003 on Machine_B (192.168.0.100) would be forwarded to port 2000 on Machine_C (10.0.0.3).
Assuming port forwarding works fine, I will start gdbserver on Machine_C to listen on port 2000, while Machine_A will use 'target remote 192.168.0.100:50003'.
Does this sound right?
If so, I am not able to get it working. Here is the iptables script I have run on 192.168.0.100:
iptables -t nat -A PREROUTING -i eth0 -p tcp --dport 50003 -j DNAT --to 10.0.0.3:2000
iptables -t nat -A POSTROUTING -i eth0 -s 10.0.0.3 -p tcp --sport 2000 -j MASQUERADE --to 50003
I would appreciate any help/comments in this regard.
Thanks in advance,