4

I have a server, which can be seen from outside of my small network, sever has domain name and such. And I have a local machine, which can be seen by server, but is not accessible from outside.

So I want to be able to connect to port on the sever, but talk to my local machine instead.

Can I make traffic arriving on one port on the server be relayed to another port on my local machine?

2 Answers 2

5

You can simply use openssh to do so: https://help.ubuntu.com/community/SSH/OpenSSH/PortForwarding

The commands to look for are -L or -R.

Let's say you want to forward port 4444 on the server to port 5555 on the local machine. On the Server use

ssh -L 4444:local_machine_name:5555 user@local_machine_name 

or on the local machine use

ssh -R 4444:localhost:5555 user@server_machine_name 

(In the first example you could connect to any other machine, no need to connect to local_machine_name, you could just use localhost to connect to the server itself).

Another more complex way is to use the server as a router. See https://help.ubuntu.com/community/Router and especially https://help.ubuntu.com/community/Router#Enable_IP_forwarding_and_Masquerading. This is what most small cable or DSL home router do.

2
3

This is possible using iptables. There is a nice howto on linuxhomenetworking.com and more info on iptables can be found on the ubuntu wiki . Note that there is also a GUI interface to iptables called Firestarter.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .