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?
You need to create port forwarding rules in your router's settings, for each device in the local network.
For example you can crate:
Let's assume, your router has public IP address 77.60.52.10, so you will be able to connect to the device with local IP address 192.168.1.110 via this command:
Also, you will be able to connect to the device with local IP address 192.168.1.115 via:
Here you are, an example for port forwarding on TP-LINK home router:
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:
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: