Accessing the Same Port on Multiple Virtual Machines

Because port forwarding only allows a single rule for each port, this could present a challenge if you need to access that port on multiple machines.  This would be most evident with the ports used to access the consoles (TCP 22 for Linux, TCP 3389 for Windows).  One work around is to change the port forwarding rule each time you need to access a different system.  A better solution is to set up port forwarding so that it uses a different public port for each instance which is then redirected to a specific machine.  Below illustrates how this would work:

Portforwardingoverview

Port forwarding rules to do this would look something like the following:

Ipforwarded

Note: If you set up access to multiple machines using different ports for each, it will be extremely important that you maintain good records as to which port goes where.

Best practice

Do not use ports that are associated with other commonly used services when creating these forwarding rules.  Instead, use ports in the higher ranges because they typically are not used.  Eg., forwarding public port TCP 21 to private port TCP 22 could cause issues since 21 is normally reserved for FTP.  Using 1022 or 10022 or any other high number (up to 65535) is much safer.  Using higher numbers also could provide a convenient numbering convention, such as 1022 for the first instance, 2022 for the second, and so on.

Accessing Linux server with PuTTY

If you have port forwarding setup to SSH to multiple Linux servers, you can access each using PuTTY as illustrated below:

Puttyconnection

The "Host Name (or IP address)" would remain the same; just change the "Port".  If the setting are as required, click on the "Save" button to preserve them.  You will be prompted for a name for the saved set, and whether or not you wish to also save login information.

Accessing Windows server with mstsc.exe

Bring up your "Remote Desktop Connection".  Click on the "Show Options" button to allow you to enter your settings.

Mstsc 

With the GUI open, enter the address of your virtual network, the port you are forwarding and the domain\user information.  

Mstscwithsettings

If the settings are as required, click on the "Allow me to save credentials" check box and then the "Save" button to preserve them.

If you are comfortable using the Windows command line, the command line syntax would be:  mstsc /v:<your assigned address>:<your public port>.  As an example, if your virtual network address was 99.99.99.99 and you set up a rule to forward port 33891 to port 3389 on instance i-999-99999-VM, the command would be mstsc /v:99.99.99.99:33891.  That would bring up your Windows logon for that instance.