Page 1 of 2

[HOWTO] DNS-O-MATIC Script / Update process

Posted: Fri Apr 03, 2009 10:42 am
by Bobcat
If you want your QNAP NAS to update DNS-O-MATIC or OPENDNS...here is a script that will do it...

1) Logon to you QNAP NAS via telnet or SSH (use putty)
2) cd /
3) cd usr/local/bin
4) mkdir dnsomatic
5) cd dnsomatic
6) vi dnsomatic.sh
7) Click the insert key on your keyboard
8) paste the script below into your screen. (modify with your user/pass etc)
9) click ESC on keyboard
10) type ":wq"
11) type chmod a+x dnsomatic.sh
11b) to run script manually ./dnsomatic.sh
12) follow the instructions here if you want your dnsomatic script to run every 5 mins to update in case of an ip change (http://www.grim.se/guide/qnap-crontab)
12a) replace this line for the one listed in the link "echo '*/5 * * * * /usr/local/bin/dnsomatic.sh' >>/tmp/crontab.tmp"


Make sure you only use wordpad for linux files; not notepad. Cranky Carriage returns happen

+++++++++BEGIN SCRIPT ON NEXT LINE +++++++++++++++++++++
#!/bin/sh
HOSTNAME="all.dnsomatic.com"
USER="username"
PASS="password"
TMPFILE="/tmp/oldip.DNS-O-Matic"
DATENOW=$(date)

IP=$(curl -s http://myip.dnsomatic.com)
if [ -r "/tmp/oldip.DNS-O-Matic" ]; then
OLDIP=`cat /tmp/oldip.DNS-O-Matic`
if [ "$OLDIP" = "$IP" ]; then
echo "IPs match; no update"
exit 0
else
RETURN=$(curl -s -m 60 -k https://${USER}:${PASS}@updates.dnsomatic.com/nic/update?hostname=${HOSTNAME}&myip=$IP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG)
echo "Return message of DNS-O-Matic : " $RETURN
echo $RETURN | grep "good" > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo $IP > /tmp/oldip.DNS-O-Matic
else
echo "" > /tmp/oldip.DNS-O-Matic
fi
fi
else
touch /tmp/oldip.DNS-O-Matic
fi

++++++++++++++++ END SCRIPT+++++++++++++++++++++++++++++++

Test on TS-109 II PRO

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Fri Apr 03, 2009 3:11 pm
by AndyChuo
Thanks for sharing!

andy

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Sat Apr 11, 2009 2:12 am
by PaKaL
It could be really nice to add DNS-O-Matic support to DynDNS option in any qnaps... This service is the best as he can update more than one DynDNS service in one command...

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Tue Dec 08, 2009 5:16 am
by techpro
Hi. I installed this script per the instructions on my TS-109 Pro but nothing happened. When I ran it manually I got an error message at line 7: curl: command not found.

How to overcome this?

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Tue Dec 08, 2009 7:05 am
by techpro
Okay. I managed to figure out how to install curl. The script works when I run it manually. But it is not running as a cron job.

[/] # crontab -l
# m h dom m dow cmd
0 3 * * * /usr/local/sbin/ImR_all -soft /Qmultimedia
0 4 * * * /sbin/hwclock -s
*/5 * * * * /usr/local/bin/dnsomatic/dnsomatic.sh
[/] #
[/] # ./usr/local/bin/dnsomatic/dnsomatic.sh
Return message of DNS-O-Matic : good 213.78.46.70
[/] #

I have restarted the NAS and the line is being added to the crontab as shown above. The path is correct as shown when I run it (note there is an error in the instructions above which does not include the folder dnsomatic.)

I'm really stumped here!

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Fri Dec 18, 2009 8:03 pm
by techpro
Thanks for all the help, guys...

For the benefit of anyone else trying to get this script or indeed any cron job going, this is what the solution was:

The script was running, but it was not working when run as a cron job because cron did not have a path to curl.

The curl program is installed in /opt/bin. Crontab apparently does not have /opt/bin in its path. I don't know how to change the path for crontab so I edited the script to use the full path of curl instead.

You're welcome.

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Fri Dec 18, 2009 10:55 pm
by Eraser-EMC2-
Hi,

you also write "/opt/bin/curl" in the script like this:

Code: Select all

IP=$(/opt/bin/curl -s http://myip.dnsomatic.com)
Stefan

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Sat Dec 19, 2009 2:36 am
by techpro
Yep, that's what I did.

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Mon Sep 06, 2010 7:25 pm
by Coume
If you reboot or upgrade the NAS, would you have to redo these steps?

Thanks
Ludo

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Mon Sep 06, 2010 8:27 pm
by techpro
No. I've often rebooted it. Don't know about upgrades, I'm still running the f/w it came with.

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Thu Sep 22, 2011 11:12 am
by Bunce
Any progress on adding DNS-O-MATIC to the list of available DDNS servers in the QNAP GUI?

Can't be a difficult one to add.

I'm sure there are other popular providers worth adding that shouldn't take much time:
- DNS-O-MATIC
- OpenDNS
- EasyDNS
- ZoneEdit
- etc

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Fri Mar 02, 2012 7:50 pm
by geoff.sim
Here is the script I use on my 439Pro2+. It resides in /mnt/HDA_ROOT.
I have updated the script to send me an appropriate email if any changes are detected.

My crontab entry calls this script every hour.

Code: Select all

0 */1 * * * /mnt/HDA_ROOT/dnsomatic.sh

Code: Select all

#!/bin/sh
HOSTNAME="all.dnsomatic.com"
USER="your_dnsomatic_user_name"
PASS="your_dnsomatic_password"
TMPFILE="/tmp/DNS-O-Matic.ip"

IP=$(/sbin/curl -s http://myip.dnsomatic.com)
if [ -r "$TMPFILE" ]
then
    OLDIP=`cat $TMPFILE`
    if [ "$OLDIP" = "$IP" ]
    then
        echo "IPs match; no update"
    else
        RETURN=$(/sbin/curl -s -m 60 -k https://${USER}:${PASS}@updates.dnsomatic.com/nic/update?hostname=${HOSTNAME}&myip=$IP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG)
        echo "Return message of DNS-O-Matic : " $RETURN
        echo $RETURN | grep "good" > /dev/null 2>&1
        if [ "$?" -eq "0" ]
        then
            echo $IP > $TMPFILE
            /sbin/log_tool -a "dnsomatic ip has changed, $RETURN" -t 1
        else
            echo "" > $TMPFILE
            /sbin/log_tool -a "dnsomatic ip has changed, $RETURN" -t 2
        fi
    fi
else
    touch $TMPFILE
    /sbin/log_tool -a "dnsomatic ip touched" -t 1
fi

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Sat Sep 01, 2012 10:00 pm
by rvn_2009
Got my TS-212 the other day and i'm very happy with it.

I already had an OpenDNS account and want to use it for securing my network and as the QNAP supported DHCP as a server and running an ip updater it all seemed easy enough (it is after all just a linux box)!

When i created my OpenDNS account it auto created my DNS-O-Matic account and linked the network up. This is all fine, however, because the usernames are now created based on your email address this script by the OP no longer works (it doesn't like the first "@" in the url from my username/email address). Fortunately this is easy enough to correct, see my amended script below:-

Code: Select all

#!/bin/sh
HOSTNAME="all.dnsomatic.com"
USER="username"
PASS="password"
TMPFILE="/tmp/oldip.DNS-O-Matic"
DATENOW=$(date)

IP=$(curl -s http://myip.dnsomatic.com)
if [ -r "/tmp/oldip.DNS-O-Matic" ]; then
OLDIP=`cat /tmp/oldip.DNS-O-Matic`
if [ "$OLDIP" = "$IP" ]; then
echo "IPs match; no update"
exit 0
else
RETURN=$(curl -s -m 60 -k -u ${USER}:${PASS} https://updates.dnsomatic.com/nic/update?hostname=${HOSTNAME}&myip=$IP&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG)
echo "Return message of DNS-O-Matic : " $RETURN
echo $RETURN | grep "good" > /dev/null 2>&1
if [ "$?" -eq "0" ]; then
echo $IP > /tmp/oldip.DNS-O-Matic
else
echo "" > /tmp/oldip.DNS-O-Matic
fi
fi
else
touch /tmp/oldip.DNS-O-Matic
fi
Hope this helps someone else!

Danny

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Tue Jan 08, 2013 3:57 am
by River Trent
Bunce wrote:Any progress on adding DNS-O-MATIC to the list of available DDNS servers in the QNAP GUI?

Can't be a difficult one to add.

I'm sure there are other popular providers worth adding that shouldn't take much time:
- DNS-O-MATIC
- OpenDNS
- EasyDNS
- ZoneEdit
- etc
+1 for adding DNS-O-Matic.
This would be great for people running multiple websites from their QNAP

Re: [HOWTO] DNS-O-MATIC Script / Update process

Posted: Wed Feb 20, 2013 10:52 pm
by sunilmkt
I have bad experience for updating through DNS-O-matic. script works well. Thanks