How to SSH to a private ip behind a router using public dynamic IP

Solution 1:

You have to add a port-forward rule in your router and set the destination IP address of the required computers LAN IP and port 22.

You can not specify to SSH which computer you want to connect to, you can only connect to an IP address (or a resolvable domain name) and a port (default 22). Only to those for which you set a port-forward rule on your router.

However, you can add multiple rules to each computer but the WAN side port must be different for each one, ie. you can use port 22 only once.

For example:

  • WAN port 22 ---> LAN IP: 192.168.1.1 PORT: 22
  • WAN port 2220 ---> LAN IP: 192.168.1.2 PORT: 22
  • WAN port 2221 ---> LAN IP: 192.168.1.3 PORT: 22

See my answer to a very similar question: Why can't I access my web server from outside the network?