Find the answer to your Linux question:
Results 1 to 3 of 3
Hi, 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 ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Mar 2009
    Posts
    3

    iptables port forwarding + remote debugging


    Hi,

    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,
    Best regards,
    R. Iyer

  2. #2
    Linux Guru Lazydog's Avatar
    Join Date
    Jun 2004
    Location
    The Keystone State
    Posts
    2,677
    Quote Originally Posted by riyer View Post
    Hi,

    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,
    Best regards,
    R. Iyer
    You might want to change the second rule from '-i' to '-o'

    Regards
    Robert

    Linux
    The adventure of a life time.

    Linux User #296285
    Get Counted

  3. #3
    Just Joined!
    Join Date
    Mar 2009
    Posts
    3
    Hi Robert,

    Thanks for your reply.

    I tried to change the option from -i to -o as you suggested. However, it does not seem to work.

    Also, I want to know if anyone has tried doing remote debugged through ports mapped by iptables?

    Best regards,
    R. Iyer

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •