server osoffice software linux support script mail dyndns open office zimbra igel beratung administration groupware howto terminal ubuntu updates router source firewall dynamic client ipupdate computing edition community crontab schulungen wartung auftragsbearbeitung backup finanzbuchhaltung systeme fakturierung heinz exchange shell canonical betriebssystem apple dienstleistung grossklaus security microsoft macosx novell suse redhat
Dynamic DNS Updates Behind Router Firewall
Script Code.
This is a simple script for the DynDns client to be used as a normal user on the system
#!/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
What is dynamic DNS and what is it good for?
DynDNS helps users who connect to the internet via a provider using dhcp and don't have a static IP address. Which means that your IP address will change every time you connect to the internet, which in turn makes it near to impossible to run a local web or mail server from your office or home, because the DNS (Name Service) which maps IP addresses to Domain names uses static IP addresses, and static IP addresses cost money.This is where DynDNS comes in handy to save the day, so that you can run your own website or mail server from your office with out an expensive static IP address!
How it works: There are many dynamic DNS provides of which some are free and some are not, with which you can map your current public IP address to some URL which points to your office or home web server. Meaning even though your public IP address might change every 24 hours users of your website will still be able to visit the URL via their book marks.
A common problem with DynDNS updates from a computer which is behind a router or firewall is that the IP address that the dynamic DNS client sends to the Name server is the private IP address of the computer it is running on. This private IP address can not be accessed from the internet. This is what our script below works around as it looks up what your public IP address is and updates this public IP address to the Name server.
To do this we need to run a small script on a computer behind your office or home firewall which checks the current public IP address of your internet connection and then updates the DNS server entry for it when the IP address changes. As soon as the IP address changes with help of the program called
"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 )

