bHosted DDNS met Loopia-WRT voor DD-WRT

Het script hiervoor haal je van GitHub.

Eerst moet je een module activeren.

Zet het onderstaande script (updaterIP.sh) in de JFFS-map. Activeer JFFS eerst via deze handleiding van DD-WRT.

Pas in het script bij de url-aanroep de gegevens aan die tussen [] staan, zodat ze bij jouw situatie passen.

Script:


#!/bin/sh

USE_PING=false

LOGG=/tmp/bhosted-status

PATH=$PATH:/usr/sbin:/usr/bin:/bin:/sbin

myip=wget -O - [http://ipinfo.io/ip](http://ipinfo.io/ip) 2\> /dev/null

if ! $USE_PING ; then

resolved_ip=nslookup [ARECORD] | grep -A 1 -e "Name:.*[ARECORD]" | tail -1 | awk '{print $3}'

if [ -z "$resolved_ip" ]; then

Fallback to using ping, as something failed

USE_PING=true

fi

fi

if $USE_PING ; then

The sed command removed everything but the contents of the first

parenthesis

resolved_ip=$(ping -c 1 -w 1 [ARECORD] | head -n 1 | sed 's/.((.)).*/\1/')

fi

url="http://webservices.bhosted.nl/dyndns?user=[USER]&password=[MD5PW]&ip=$myip&host=[ARECORD]"

if [ "$resolved_ip" = "$myip" ]; then

date >> $LOGG

echo "Ip Adres is $resolved_ip en blijft $myip" >>$LOGG

return

fi

tmpFile=/tmp/update-output

wget -O $tmpFile "$url" 2> /dev/null

cat $tmpFile >> $LOGG

rm $tmpFile

echo >> $LOGG

date >> $LOGG

echo "IP aangepast van $resolved_ip naar $myip" >> $LOGG


Tot slot maak je een cronjob aan (Administration > Management > Cron) die dit script aanroept. In dit voorbeeld gebeurt dat 1x per kwartier:

*/15 * * * * root /jffs/updateIP.sh

Gerelateerde artikelen