How do I forward TCP from one IP to another?

1

1

Here's a thing: I have a piece of software listening on 127.0.0.1:port and only (I can choose the port). I want it to work as a server and accept connections from outer network. How can I forward the communication from (e.g.) 192.168.0.1:port to 127.0.0.1:port?

I am using Ubuntu 11.04. Tried to look into iptables, but they don't actually offer the thing I want to archieve.

Corkscreewe

Posted 2011-05-09T21:25:48.027

Reputation: 111

rinetd (http://www.ubuntugeek.com/rinetd-redirects-tcp-connections-from-one-ip-address-and-port-to-another.html) looks like exactly something I want - except it needs to be downloaded and installed. I am looking for a system-settings solution. Hope there's one

– None – 2011-05-09T21:50:45.967

Answers

0

You should change the ip address that the software is listening on.

If you bind it to the ip 0.0.0.0 and port 80, then it will be able to listen on all interfaces (127.0.0.1 and 192.168.0.1).

user745849

Posted 2011-05-09T21:25:48.027

Reputation:

I wish I could do that. Can't modify its settings though – None – 2011-05-09T21:36:58.557

0

You can easily make a tunnel using SSH.

something like: ssh -L 3307:192.168.0.1:3306 user@127.0.0.1 will tunnel traffic from port 127.0.0.1:3306 to 192.168.0.1:3307

McKracken

Posted 2011-05-09T21:25:48.027

Reputation: 101

0

You can do this in your firewall (you should be using one). I use Firestarter and it has an easy interface for forwarding ports.

BZ1

Posted 2011-05-09T21:25:48.027

Reputation: 371