Daily Ubuntu / Linux news and application reviews.

ads

SSH Server With Dynamic IP Address [How to - Linux]

A few days ago, I wrote an article on how to use your home computer to get past internet restrictions with SSH but I didn't cover the aspect of the computer running the SSH sever not having a static IP. So here is how to use DynDNS hostname for your dynamic IP.

The first thing you need to do is create an https://dyndns.com/ account and then go to My account > My hosts > add a dynamic dns and pick some hostname such as myhomepc.homelinux.com or whatever you want. This will point to your current IP but if your IP is dynamic, it will change so we need to update this info in DynDNS automatically.

For this, we'll create a script in your /etc/cron.hourly/ folder:

sudo gedit /etc/cron.hourly/dyndns

There are 2 different versions for this script: bash and python, use whichever you want from below, but make sure the file name is dyndns without extension (no .py) because the scripts in cron.hourly won't run if they have an extension: