Set Dynamic DNS


Home | Projects

Set Dyn DNS

This is just a quick hack that updates the dynamic dns entry of your dhs.org account.

It requires wget, nslookup and some other UNIX tools.

If you put this script into your /etc/ppp/ip-up.d/ directory, it should get executed everytime you fire up your (i)ppp connection.

Either copy&paste it or follow this link to download it.

#!/bin/sh

sleep 10

USER="weaselp"
PASSWD=`cat /etc/dhs_passwd`
HOSTNAME="defiant"
DOMAIN="2y.net"

while /bin/true ; 
do
	EXTIF="ippp0"
	EXTIP=`/sbin/ifconfig | grep -A 4 $EXTIF | awk '/inet/ { print $2 } ' | sed -e s/addr://`
	
	if ( ! ping -c 3 ns1.dhs.org | grep -q '100% packet loss') ; then
	    NSIP=`nslookup $HOSTNAME.$DOMAIN ns1.dhs.org | grep -A 1 $HOSTNAME.$DOMAIN | awk '/Address:/ { print $2 }'`
	elif ( ! ping -c 3 ns2.dhs.org | grep -q '100% packet loss') ; then
	    NSIP=`nslookup $HOSTNAME.$DOMAIN ns2.dhs.org | grep -A 1 $HOSTNAME.$DOMAIN | awk '/Address:/ { print $2 }'`
	elif ( ! ping -c 3 ns3.dhs.org | grep -q '100% packet loss') ; then
	    NSIP=`nslookup $HOSTNAME.$DOMAIN ns3.dhs.org | grep -A 1 $HOSTNAME.$DOMAIN | awk '/Address:/ { print $2 }'`
	elif ( ! ping -c 3 ns4.dhs.org | grep -q '100% packet loss') ; then
	    NSIP=`nslookup $HOSTNAME.$DOMAIN ns4.dhs.org | grep -A 1 $HOSTNAME.$DOMAIN | awk '/Address:/ { print $2 }'`
	elif ( ! ping -c 3 ns5.dhs.org | grep -q '100% packet loss') ; then
	    NSIP=`nslookup $HOSTNAME.$DOMAIN ns5.dhs.org | grep -A 1 $HOSTNAME.$DOMAIN | awk '/Address:/ { print $2 }'`
	else
	    exit 1;
	fi

	if [ "$EXTIP" != "$NSIP" ] ; then
		/usr/bin/logger -p syslog.info -i -t set_dyn_dns "updating dns entry for $HOSTNAME.$DOMAIN to $EXTIP"
		wget -O - \
"http://$USER:$PASSWD@members.dhs.org/nic/hosts?\
updatetype=Online&\
ip=$EXTIP&\
mx=&offline_url=&\
cloak="Y"&\
cloak_title=offline&\
hostscmd=edit&\
hostscmdstage=2&\
type=4&\
domain=$DOMAIN&\
hostname=$HOSTNAME" \
> /dev/null 2> /dev/null

		sleep 30
	else
		/usr/bin/logger -p syslog.info -i -t set_dyn_dns "dns entry for $HOSTNAME.$DOMAIN has IP $EXTIP. nice :)"
		break
	fi
done



Use Any Browser Here - Campaign for a Non Browser Specific WWW Valid HTML 4.0! Peter Palfrader
Last modified: Mon Feb 28 16:37:31 CET 2000