Find the answer to your Linux question:
Results 1 to 1 of 1
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Jul 2011
    Location
    Calgary, AB
    Posts
    1

    TCP Port Relay for CentOS?


    I have a CentOS box (lets call it Server). When ServerA receives data on ports 1001 to 1003 it should send it to ServerB which is accessed via VPN through the gateway to which ServerA is connected.

    I tried using Socat to do this but when I try to make a connection Socat says there is no route to host(?) even though I can SSH into ServerB from ServerA.

    Can someone suggest a way to do this?

    EDIT:

    I got it partially to work using SSH forwarding on ServerA and socat on ServerB. Keep in mind I do have SSH access to ServerA from ServerB.

    On ServerA entered the following SSH command:

    ssh -g -L localip:localport:remoteip:remoteport
    Remote IP has to be the internal IP address of the remote server. Remote port is the port on which socat will listen.

    On ServerB entered the following socat command

    socat TCP-LISTEN:listeningport,fork TCP:destinationip:destinationport
    Where listeningport is the port on which socat listens for incoming connections from ServerA, destinationip is the IP address of recipient device to which the data will be sent and destinationport is the port on which that device is listening for connections.

    Current issue: after about an hour the SSH forwarders from ServerA stopped working. Killed the SSH processes and re-entered the commands and the connections are working again.
    Last edited by omber; 07-04-2011 at 02:54 AM. Reason: Partial solution found

Posting Permissions

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