Updating DYNDNS from linux box behind router

So a few of my clients have routers that don't talk to DYNDNS or if they do seem to be pretty rubbish at it. I wrote the following php script which relies on the dyndns client. it does some screen scraping.


$temp = file_get_contents("http://checkip.dyndns.org"); //get html with IP address

$pos = strpos($temp,"Address:") + 9; //find starting position

$pos2 = strpos($temp,"/body") - 1;

$ip = substr($temp,$pos,$pos2-$pos); //get IP address

system("/sbin/ifconfig eth2:1 $ip"); //set it to a virtual device

system("/etc/init.d/ddclient restart"); //tell ddclient to restart and send it to the DYNDNS service.

You need to tell your /etc/ddclient.conf to use this virtual device:

# Configuration file for ddclient generated by debconf#
# 
/etc/ddclient.confpid=/var/run/ddclient.pid
protocol=dyndns2
use=if, if=eth2:1
server=members.dyndns.org
login=LOGIN NAME
password='PASSWORD'
HOSTNAME.homeip.net

I realized I should have just written a php script and chucked it onto a server that prints and wouldn't need any parsing etc but I didn't want to replace the script on several servers.

Hope this helps someone