Friday, May 04, 2007

Dynamic DNS Setup In Ubuntu Using DynDNS

I use Dyndns.org for dynamic domain services. There is easy setup and you can update your IP via a web browser, or schedule an application to run on a regular basis. Updating your IP address is important because you will lose your domain if you don’t update your record every 30-35 days. Here is a basic guide.

In Debian/Ubuntu you can install the updater via apt:


sudo apt-get install ipcheck

Create bin directory, dyndns directory and updater script:



mkdir ~/bin
mkdir ~/.dyndns
touch ~/bin/dyndns-update.sh
chmod 700 ~/bin/dyndns-update.sh
vi ~/bin/dyndns-update.sh

#!/bin/sh

USERNAME=yourusername
PASSWORD=yourpassword
HOSTNAME=your.domain.name

cd ~/.dyndns
if [ -f ~/.dyndns/ipcheck.dat ]; then
/usr/sbin/ipcheck -r checkip.dyndns.org:8245 \
$USERNAME $PASSWORD $HOSTNAME
else
/usr/sbin/ipcheck --makedat -r checkip.dyndns.org:8245 \
$USERNAME $PASSWORD $HOSTNAME
fi

Edit your crontab:


crontab -e

Add the following line to your crontab to run the script daily.


* 6 * * * /home/username/bin/dyndns-update.sh

5 comments:

Anonymous said...

awesome! Thanks for a great post.

Anonymous said...

Man... I did everything you said and my problem is cron will not execute that... It does go through the others commands and they run (I have tested) but this particular one will not.

It runs from the terminal but not from the crontab. I use Ubuntu 7.10. Any hel would be appreciated ;)

Patrick said...

cooives: I updated the script with the absolute path to ipcheck. Perhaps that will work better. I couldn't think of why you had issues with the cron until yesterday, when an absolute path issue prevented me from running a cron script.

lusitanv said...

Thanks,

I will test it today and I will give you some feedback :)

Anonymous said...

That works. Great article!