Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a legacy application listening on port 5050 bound to localhost interface (i.e. 127.0.0.1). This app runs on a Linux box (an embedded system). I have an app, lets call it App C that runs on PC and would like to connect to it. But can't as legacy app doesn't accept connections from outside the box. I don't have the option of changing legacy app source code.
Is there a way to run something like ssh to listen on port 7070 on embedded box and forward incoming traffic to port 5050? I know ssh allows that. But it expects ssl type connections from outside. I am wondering if it can be launched just to do port forwarding without any kind of ssl tunnel stuff. Something like SOCKS proxy.

Feel free to suggest other tools if you know one that does the job.

share|improve this question
1  
Does iptables exist on the embedded system? If so, you can should be able to take care of this using a DNAT rule, which is probably the "right" way to handle this. –  cjc Sep 6 '11 at 14:20

4 Answers 4

You might also be able to configure xinetd to do this:

Define a new service running on port 7070, and configure it using redirect (from man xinetd.conf)

redirect Allows a tcp service to be redirected to another host. When xinetd receives a tcp connection on this port it spawns a process that establishes a connection to the host and port number specified, and forwards all data between the two hosts.
share|improve this answer
    
This is very similar to rinetd that I ended up using. But thanks for your tip. –  videoguy Sep 8 '11 at 14:05

SSH can do what you want. Refer to The SSH man page, specifically the -L and -R options (-L creates a listener on the Local machine, forwarding to something on the remote machine/network. -R creates a listener on the Remote side forwarding to something on the local machine/network).

Ports forwarded with -L or -R do not require any specific protocol handshake - the forwarding is transparent to the applications connecting to that port, though the channel is encrypted by SSH.

share|improve this answer
    
I found rinetd which can do this easily. SSH expects sshd somewhere to establish encrypted tunnel which is more hoops to jump through compared to rinetd. –  videoguy Sep 6 '11 at 15:55
    
@videoguy that's a new one on me -- looks pretty useful. You should post it as an answer and come back later to accept it :) –  voretaq7 Sep 6 '11 at 17:08

Should be possible. Try with

ssh -R *: 7070:localhost:5050 -N host.example.com
share|improve this answer
    
I get Bad remote forwarding specification '*:' –  dgmdan Mar 5 '13 at 20:15

I found rinetd which can do this easily. SSH expects sshd somewhere to establish encrypted tunnel through which incoming connections get connected. rinetd is pretty good as it doesn't have dependencies on other entities. It just does port forwarding.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.