#!/bin/sh
## *** Info ***
# This is a helper script from http://www.osoffice.de for dynamic DNS updates from a
# computer that sits behind a router that does not have a dyndns client or if you have a
# second DNS entry you would like to update from behind a router / firewall.
# Updates of this script can be found on http://www.osoffice.de
# We hope this script is helpful to someone out there.
## *** Usage ***
# This script can be run as an unprivileged user, from the users crontab. This script does
# not monitor nor loop, thus important to setup a regular cronjob.
# Crontab example run "crontab -e" to edit the users cron entries and then add the
# following: 5 * * * * /bin/sh /path-to-script/dyndns-update-behind-router.sh
# This will cause the scrip to run every five min. and will only update the dyndns service
# when your IP has changed. You can run multiple version of the script just make sure that
# the CACHEFILE parameter has a different name for each instance of the script.
## *** Depends on --> "ez-ipupdate" from http://ez-ipupdate.com/ to work <--!!
## *** version 0.01 *** Works as designed :-)
##### Config Section
## Valid service types: null ezip pgpow dhs dyndns dyndns-static dyndns-custom ods tzo easydns easydns-partner gnudip justlinux dyns hn zoneedit heipv6tb
SERVICETYPE=dyndns
## Users name used to login to your Dyndns provider.
USER=YourUserName
## The users password
PASSWD=X47bDyZq
## The Dyndns host name you have defined on your Dyndns provider server.
DYNHOSTNAME=myhost.dyn-dns.com
## The directory where we will write a pid file.
PIDDIR=/tmp
## The name of our pid file.
PIDFILE=ez-ipupdate.pid
## The directory where we want to write a cache file
CACHEDIR=/tmp
## The file used for caching the ipaddress. If you are going to run more instances of this
## script on the same box, then change the cache file name below to be unique for each instance of the script.
CACHEFILE=ez-ipupdate.cache
##Log directory
LOGDIR=/tmp
## Log file
LOGFILE=dyndns-up-2-date.log
##### End Config Section
##### Best you don't mess with this line if you don't know what you are changing
IP=`wget --quiet -O - http://checkip.dyndns.org/ | awk '{print $6}' | cut -d"<" -f1`
##### the magic happens in this lines that follow... don't change anything if you don't know what you are changing.
echo >> $LOGDIR/$LOGFILE
ez-ipupdate -S $SERVICETYPE \
-u $USER:$PASSWD \
-a $IP -h $DYNHOSTNAME \
-b $CACHEDIR/$CACHEFILE \
-F $PIDDIR/$PIDFILE 2>> $LOGDIR/$LOGFILE
echo “last update done at: `/bin/date`” >> $LOGDIR/$LOGFILE
"ez-ipupdate"
we call up your dynamic DNS provider's server and inform it of the
change of your public IP address which only takes a second or two, and
then your office mail or web server will be available to all the
internet user without them even noticing the change of your IP address.
With the scrip below all you have to do is create a cron job for it and
enter you user details for your DNS provider and off you go....
How to create the crontab entry is very easy! Just run the following command from your linux console
crontab -e
Add the following line to the dialogue:
5 * * * * /bin/sh /path-to-script/dyndns-update-behind-router.sh
Then save it and your done! From now on every five min. the script will do its job.
Last Updated ( Monday, 31 March 2008 )