You can get the script for this from GitHub.
First you need to activate a module.
Place the script below (updaterIP.sh) in the JFFS folder. First activate JFFS via this DD-WRT guide.
In the script, adjust the data between [] in the url call so that it matches your situation.
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 address is $resolved_ip and stays $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 changed from $resolved_ip to $myip" >> $LOGG
Finally, create a cronjob (Administration > Management > Cron) that calls this script. In this example, this happens once every quarter of an hour:
*/15 * * * * root /jffs/updateIP.sh