How To   DDNS

internet connection picture Some ISPs frequently change the IP address they provide you, while others provide it on a long lease but may still change it. Most ISPs allocate their range of IP addresses dynamically (using DHCP), and the “lease” is often until you reboot the router or set to 24 hours, which is why your address might change frequently. For most users, changing IP doesn’t matter, but in my case, I need a known address so I can login remotely. To do this easily, you could have your ISP give you a fixed address (aka a static IP address), but if they offer this service at all, they will charge you for it.

I don't want to pay for the static IP address, so I need an alternative. One alternative is to make use of a Dynamic DNS (DDNS) address service. These services associate your actual address (in its numerical form) with a fixed mnemonic address in real time, so as long as you have mnemonic form, it will point you to your server. This service can also cost you money. (e.g. Dyn has stopped their free plans but No-IP provides a quasi-free service). Your home router will also need to support the DDNS client. Not all routes support DDNS, but OpenWrt does and is fairly easy to install if you want to go in this direction.

The cheapskate alternative is to create a service on your server that email or other wish notifies you, when the IP address changes. This is practical if the IP address isn't changing too frequently, which happens to be my case. My choose is to use a simple service for periodically looking up my IP address, specifically using the website ifconfig.co. The design is to execute the command curl ifconfig.co periodically, check if the IP address has changes, and if so, email or text the change to myself.

To do this, I placed the shell program listed below, which I call ip_check, in cron to run every hour.

To run the script in cron every hour, I edited the cron table via the command crontab -e and place the following in the table: @hourly /home/jeff/bin/ip_check -x. Also note that cron can be temperamental, so check out the post "Reasons why crontab does not work" if you have problems getting it working.

The above shell program makes use of the utility apprise, a push notification tool for the Pushover service. This will notify me on my cell phone of any changes to the external IP address.


Comments

comments powered by Disqus