In order to connect to the Server via the internet we need to know the Public IP address of the internet gateway used by the server. In our case this will be the Public IP address allocated to the router - it is important not to confuse this with the Private IP address assigned to the router on the Local Area Network (LAN). When using SSH client software (e.g. PuTTY) replace any references in the guide to IP Address 192.168.2.2 (the Private IP address of the server) with the Public IP Address of the internet gateway.
Various websites can be used to check the Public IP address of your internet gateway - use whatismyip.com or search for a similar site/service.
Many Internet Service Providers (ISP's) do not provide fixed Public IP addresses. To test whether your Public IP address is fixed or dynamic check your Public IP address then reboot your router and recheck it. If the Public IP address has changed on rebooting the router then your system uses dynamic IP addresses.
Dynamic IP addresses are unreliable when attempting to connect to a server via the internet as a router reboot (including when the power supply to the router is turned off or interrupted) will result in a new Public IP address being assigned. If your ISP assigns dynamic IP addresses then either contact them to request that they assign a static IP address (there is often a cost involved) or use a dynamic DNS service. Dynamic DNS services use hardware or software based clients to check the Public IP address of the internet gateway - your account will be updated following any changes to your Public IP address. To connect to the Server simple use your dynamic DNS hostname (some services may refer to this as the domain name) instead of an IP address.
The router used in the test system supports the DynDNS.org service - this service is available free of charge, visit the site to create an account. Once an account has been created make a note of the following information -
The above information will need entering in the dynamic DNS client. On the test system this is achieved by opening a web browser and entering 192.168.2.1 (the routers Private IP address) in the address bar to open the routers settings menu. Selecting the DDNS menu option will open the following window -
Account / E-Mail> refers to the username used to log in to the DynDNS account, Password / Key> refers to the password used to log in to the DynDNS account and Domain refers to the hostname. Once the Dynamic DNS software or hardware client has been configured it will broadcast any changes to the routers IP address to the service. To connect to the server simply replace the IP address with the hostname - e.g. when using SSH Client software replace any references in the guide to 192.168.2.2 with my_name.dyndns.org.
Many routers have a built in firewall and must be set up to forward port 22 (the default SSH port) to the server. As the server has been assigned a static IP address port 22 will need forwarding to 192.168.2.2. Instructions for forwarding ports is beyond the scope of this guide - refer to the Port Forward site for instructions on setting up port forwarding for your own router. For the Belkin router used on the test system this is achieved by opening the router settings menu (enter the Private IP address in a web browser) and selecting the Virtual Servers menu option. Now enter the following settings and then click on the Apply Changes button -
Note - if connecting to the server via the LAN, port forwarding is unnecessary. If you are able to connect to the server via the LAN in testing but are unable to connect to it via the internet it is likely to be due to incorrect port forwarding or software firewall settings.