Bekijk de volledige versie : Maintainin multiple dyndns accounts from wl500g.

15-02-2006, 13:35
This tutorial is based on wl500g hardware with Oleg's firmware.

I have three different dyndns accounts and I'm using wget with cron-jobs like (macsat's cron solution (http://www.macsat.com/macsat/content/view/28/29/)) to update these accounts.
As I'm totally new to Linux, I might have made some choices that could be done differently (meaning more elegantly) and maybe also the chosen location of the files and directories does not fully comply to common Linux-practices, but hey.. it works for me!

Here we go.

Assume you have to maintain following account: wl500g.homelinux.com (this is a dyndns domain). I have decided to make my scripts reflect my chosen name in this domain, so they will show 'wl500g' in this tutorial. Please apply your own name for each domain you need to maintain.

I have made a script (/opt/etc/cron.5mins/dnsupd_wl500g.sh) to check if the current ip-address has changed. This script will run every 5 minutes (cron) and it will update the ip-address in dyndns if it finds that the ip-address has changed.

#Get the current ip and put it into /opt/etc/dyndns/dyndns/tmp_ip_wl500g.ip
wget -q http://checkip.dyndns.org/index.html --output-document=/opt/etc/dyndns/tmp_ip_wl500g.ip
#Parse the answer to get only the ip and put it into /opt/etc/dyndns/new_ip_wl500g.ip
sed -e 's/^.*Address: //' -e 's/<.*$//' /opt/etc/dyndns/tmp_ip_wl500g.ip > /opt/etc/dyndns/new_ip_wl500g.ip
#Check if ip has changed.
if [ "`cat /opt/etc/dyndns/new_ip_wl500g.ip`" = "`cat /opt/etc/dyndns/old_ip_wl500g.ip`" ]
then echo "No new IP";
else wget -q http://dyndnsusername:dyndnspwd@members.dyndns.org/nic/update?hostname=wl500g.homelinux.com\&wildcard=ON --output-document=/opt/etc/dyndns/upd_ip_wl500g.ip
echo "New IP";
cat /opt/etc/dyndns/upd_ip_wl500g.ip;
rm /opt/etc/dyndns/upd_ip_wl500g.ip;
rm -f /opt/etc/dyndns/old_ip_wl500g.ip
rm /opt/etc/dyndns/tmp_ip_wl500g.ip
mv /opt/etc/dyndns/new_ip_wl500g.ip /opt/etc/dyndns/old_ip_wl500g.ip

To make this script work, you have to:
a) Make the script executable (chmod 755 /opt/etc/cron.5mins/dnsupd_wl500g.sh)
b) Create directory: mkdir /opt/etc/dyndns/

If all goes well, this script will run the check every 5 minutes. If it finds the ip address unchanged, it will do nothing. If it finds the ip changed, then the wget command will be executed to updated the registered ip at dyndns. (for more information on the syntax, see: http://www.dyndns.org/developers/specs/syntax.html)

But dyndns accounts need a forced update so they don't expire. you may update 24-35 days after your previous update with the same IP address to "touch" the record and prevent it from expiring (https://www.dyndns.com/services/dns/dyndns/faq.html#q15). I want to update before the notification email from dyndns gets sent to my registration email-address, so approx. day 25 or 26 or so..

I have made another script (/opt/etc/cron.daily/dnsupd_force_wl500g.sh]) to run daily to keep a counter and run a forced ip-updated when the counter reaches 25.

daycount="`cat /opt/etc/dyndns/dyndns_counter_wl500g`";
if [ "`cat /opt/etc/dyndns/dyndns_counter_wl500g`" -le "24" ]
then daycount=`expr $daycount + 1`
echo $daycount > /opt/etc/dyndns/dyndns_counter_wl500g
else rm /opt/etc/dyndns/old_ip_wl500g.ip
echo 1 > /opt/etc/dyndns/dyndns_counter_wl500g

To make this script work, you have to:
a) Make the script executable (chmod 755 /opt/etc/cron.daily/dnsupd_force_wl500g.sh)
b) Create the file with the counter /opt/etc/dyndns/dyndns_counter_wl500g (echo 1 > /opt/etc/dyndns/dyndns_counter_wl500g)

Explanation: On day 25, the script will remove file /opt/etc/dyndns/old_ip_wl500g.ip and reset the counter. By removing the file /opt/etc/dyndns/old_ip_wl500g.ip, the 5mins cronjob will actually jump to the wget instruction to update the ip-address registration at dyndns.
Exceptions: When the router was powered down more than a day (no cron jobs running), the counter will not be in line with actual expiration period at dyndns. Also: The daily script should not actually run at the same time when the 5mins script is updating the file /opt/etc/dyndns/old_ip_wl500g.ip otherwise, the forced update might not work.

I have setup 3 scripts for every of my personal dyndns registrations. I've kept the script files for each account separate, so I can drop them easily when I remove the account at dyndns.

(Oh, by the way: I have disabled the dyndns upfdate in the web-admin pages of the wl500g which didn't work on mine anyway.)

don tunante
18-02-2006, 21:41
I don't know if you will find my solution more elegant, but it's simple

I created /etc/ddns.conf:

max-interval=2073600 #24 days in sec

then I put the folloving line into /usr/local/sbin/post-mount (has to be executable):

ez-ipupdate -c /etc/ddns.conf

there will be checked every 5min if the IP address changed, if yes, it will be updated at dyndns

on the web interface dyndns client is set to no

13-04-2006, 12:55
Slightly deviating from the post,

I have noticed that my wl-500 doesnt auto update the dyndns settins i have entered. I have checked though the logs and cant see any record of it doing this.

I will attempt to fall back on don tunante's solution as I only have a single domain to update. Just would like to comment on a few things as im new to the *nix game.

daemon Not sure what this line does
period=300 is this the 5 min timer, i assume that due to my high lease time I could set this to 2/3 days at a time?
retrys=2016 Not sure what this line does
resolv-period=300 Not sure what this line does
max-interval=2073600 #24 days in sec Not sure what this line does
interface=ppp0 this is the wan port
service-type=dyndns Is this just a lable for the service?
user=<<username>>:<<password>> Username and password for dyndns
host=<<host1>>,<<host2>>... Multiple dyndns accounts
wildcard Domain wild card

Now would this file be called ddns.conf and that configs made executable?

Then a line is added to /usr/local/sbin/post-mount to run the script, Correct?
and I thanks to your post, I understand I have to disable the gui dyndns update (which does not work atm for myself)

I have cron already running, and would like to get the dyndns problem sorted.

Thanks for the post, if you could answer my comments this would be great.



don tunante
15-04-2006, 16:19
daemon ez-ipupdate will run as a daemon, stays running
period=300 period between update attempts, checks every 5 min. if public IP address has changed
retrys=2016 if the update process fails it will try 2016 times
resolv-period=300 time between failed resolve attempts
max-interval=2073600 max. time between updates see why (http://www.dyndns.com/services/dns/dyndns/faq.html#q15)
interface=ppp0 ip of this interface will be monitored
service-type=dyndns service, like in the drop-down list in the GUI
user=<<username>>:<<password>> Username and password for dyndns
host=<<host1>>,<<host2>>... host names registered at dynDNS
wildcard enable wildcard

I gave the name for this configuration file /etc/ddns.conf, and it hasn't to be executable

/usr/local/sbin/post-mount has to be executable and include the line

ez-ipupdate -c /etc/ddns.conf
yes, you have to disable the DynDNS feature in the GUI

using this configuration file you don't need cron, as ez-ipupdate will run as a daemon and check every 5 min. if the IP address of the ppp0 interface has changed (you can't be sure, when exactly it will change, even in case of a longer lease time), if yes, then updates it at DynDNS, and if there is no connection to DynDNS, it will keep trying 2016 times, every 5 min. (1 week)

More about ez-ipupdate (http://leaf.steinkuehler.net/doc/guide/bucu-ezipupd.html#ezipupd3)

20-04-2006, 21:46
Thanks for the great reply,

One more question....

do I have to keep the << >>'s around my ursername and password/host?

Edit, you dont need the << >>'s and I had to change my interface=ppp0 to interface=vlan1


19-06-2006, 23:33
Hi guyz

I've configured ez-ipupdate to maintain one dynamic domain, and it works perfectly.

Now, I'ld like to maintain multiples domains, which are not hosted by the same service (dyndns and zoneedit, by the way).
Does anyone know how to do this ? I've tried 2 differents configuration files, but it seems to be impossible tu run multiple instances of ez-ipupdate.

Thanks in advance

26-07-2006, 02:08
@don tunante: Thanks for the tut. It work great.

19-05-2007, 14:18
I have detected that the "wildcard" parameter in the .conf file for ez-ipupdate does not properly applies with dyndns.org. I can see in dyndns.org the IP gets updated but the wildcard checkbox.

One thing that seems somehow strange in the .conf file is that the "wildcard" parameter stands alone and not belonging to any specific domain. Does it mean that all multiple domains defined in the .conf file will be affected by this parameter? In dyndns.org every domain has its own wildcard checkbox.

I have not found how to get this to work yet.

24-12-2007, 20:33
Hi there, I have a question in regards of this line:

interface=ppp0 ip of this interface will be monitored

Should it be the same for both DSL and Cable modem connections?


don tunante
21-03-2008, 21:12
Hi there, I have a question in regards of this line:

Should it be the same for both DSL and Cable modem connections?


ppp0 is suitable for PPPOE connections, for DHCP connections it's