May 08, 2011 Archives

08-05-2011 00:12

I have used No-Ip (Maybe 10 years now). It is a Dynamic DNS service like DyDNS etc. It is good but it is limited how many clients you can have much like all others. So I have toyed with setting up something myself as I have a public Linux DNS server to receive the updated IP info. After trying a few methods that had varying success, I concluded that the following was the best method. DOMAIN would equal a domain name you have set aside for this purose.

  1. We setup passwordless ssh to the server. Do a search online with your favourite search engine as there is losts of tutorials already published for this.
  2. On client side we run every 10mins
    FILE="DOMAIN-ip"
    curl  ifconfig.me/ip -o  "$FILE"  &>/dev/null
    scp  -q "$FILE" dward.name:
    exit 0
    
  3. Setup the zone to accept updates by adding the following to your named.conf for bind9:
    allow-update { localhost;};
    Restart bind9
  4. On the server side run hourly cronjob or anything to your hearts content:
    PHY="$(cat DOMAIN-ip)"
    TEMP="$(/bin/mktemp)"
    CMDS="$(/bin/mktemp)"
    CUR="$(host -t A DOMAIN localhost |grep DOMAIN|cut -d' ' -f4)"
    if [ ! "$CUR" == "$PHY" ]
    then
            TIME="$(date +%s)"
    	cat > $CMDS <<EOF
    	update delete DOMAIN A
    	update add DOMAIN 1800 A $PHY
    	send
    	EOF
    /usr/bin/nsupdate $CMDS
    rm -f $CMDS
    rm -f $TEMP
    fi
    

Edit anything there to your needs of course.
References: https://www.debian-administration.org/users/JulienV/weblog/4
http://www.shakabuku.org/writing/dyndns.html


Posted by DaveQB | Permanent Link