vendredi 25 janvier 2013

How to write your own DDNS IP update script

My brand new Synology D413j can't update it's public IP address on public DDNS sevices, like synology.om or noip.com. As it prevents remote access to it, I've started to work on the problem. 

But today I'm tired, will fix that tomorrow! For now, here are the rought steps:

1)
You'll have to create a Cront table to run periodial updates, i.e. runnung the update script: you're going to write:

DiskStation> cat /etc/crontab
#minute hour    mday    month   wday    who     command
15      23      *       *       2,5     root    /usr/syno/bin/synopkg chkupgradepkg


2) Your update script must find the current public IP. To my surprise, that's doable using standard too curl:
curl ip.alt.io

3) Finally, you must send the new address to the side. They API is HTTP-based so I just tried to go through Wget:

wget  --http-user=yean3d --http-password=heythisismypassword  --user-agent="Synology DDNS bugfixer/1.0 myniceamail@gmail.com" http://dynupdate.no-ip.com/nic/update?hostname=mynoiphostname.no-ip.org&myip=THE_IP_RETURN_BY_CURL

.... so far Wget says: "cannot write to update, access is defined". I'm tired, I'll figure out tomorrow.

NOTE: may httpget is even better and simpler?

Aucun commentaire: