let's imagine i am at school with an android phone. I have a computer at home and that computer has a virtual machine working on it. here is the scenario, client and virtual client has ssh-client and ssh-server both and they can communicate each other in the local network. when i want to connect to my virtual client from school by android phone through internet there must be an ip address. the problem is virtual machine and client has the same public ip. so how do i connect one of the two machines?

1 Answer 1


You need to create port forwarding rules in your router's settings, for each device in the local network.

For example you can crate:

  • rule, where router's port 1110 is redirected to port 22 (this is the standard SSH port) of the device in the local network, which has local IP, and
  • rule, where router's port 1115 is redirected to port 22 of the device with local IP

Let's assume, your router has public IP address, so you will be able to connect to the device with local IP address via this command:

ssh [email protected] -p 1110

Also, you will be able to connect to the device with local IP address via:

ssh [email protected] -p 1115

Here you are, an example for port forwarding on TP-LINK home router:

enter image description here

EDIT: Home routers usually have UPnP configuration interface. In Ubuntu, you can create port forwarding (mapping) through this interface with some tool like UPnP PortMapper.

It is a good idea to set up static IP addresses for the devices in your local network. One of the ways to do that is through address reservation page in the router's setting:

address reservation

EDIT: Assignment of static IP could be done also through the configuration of the OS. Here's an example of how to do this in:

Further reading:

You must log in to answer this question.

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