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

FTP Server, File Server, DDNS, SAMBA, AFP, NFS
Bobcat
Starting out
Posts: 24
Joined: Sat Jun 21, 2008 7:24 pm

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

Post 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
User avatar
AndyChuo
Experience counts
Posts: 2388
Joined: Thu Sep 13, 2007 11:56 am
Location: Taipei, Taiwan

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

Post by AndyChuo »

Thanks for sharing!

andy
=============================================================>>>
TS-659-Pro [RAID6] rtorrent+SABnzbdplus+SickBeard+Couchpotato [Best PVR] Plex+PMS [Ultimate Streamer]
Apple iPad [Best Tablet] HTC One M8 [Mobile Phone] Samsung UA46ES6100 [My Screen] KRK Rokit 6 [Audio Speakers]
Chrome Cast [Screen Casting] Philips Hue [Personal Lighing]
Buffalo WZR-1750DHP [My Wifi Hub] D-Link DGS-1005D [Gbit Network]
=============================================================>>>
PaKaL
Starting out
Posts: 23
Joined: Tue Jan 06, 2009 10:55 pm

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

Post 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...
techpro
Starting out
Posts: 21
Joined: Thu Jul 31, 2008 10:00 pm
Location: UK
Contact:

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

Post 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?
techpro
Starting out
Posts: 21
Joined: Thu Jul 31, 2008 10:00 pm
Location: UK
Contact:

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

Post 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!
techpro
Starting out
Posts: 21
Joined: Thu Jul 31, 2008 10:00 pm
Location: UK
Contact:

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

Post 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.
Eraser-EMC2-
Been there, done that
Posts: 711
Joined: Sat Oct 13, 2007 5:26 pm
Location: Germany

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

Post 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
_________________
Windows 7 32/64bit, German
TS-439 , 1x 512GB SSD/1x 512GB Samsung ; SAMBA as NT4 PDC, DHCP/DNS-Server
TS-431+, 1x 1TB WD green, 2x 3TB WD red , 1x 2TB Samsung
TS-220 , 2x 2TB Samsung, for Backup
techpro
Starting out
Posts: 21
Joined: Thu Jul 31, 2008 10:00 pm
Location: UK
Contact:

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

Post by techpro »

Yep, that's what I did.
Coume
Starting out
Posts: 37
Joined: Sun Apr 11, 2010 11:01 pm

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

Post by Coume »

If you reboot or upgrade the NAS, would you have to redo these steps?

Thanks
Ludo
techpro
Starting out
Posts: 21
Joined: Thu Jul 31, 2008 10:00 pm
Location: UK
Contact:

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

Post by techpro »

No. I've often rebooted it. Don't know about upgrades, I'm still running the f/w it came with.
Bunce
Starting out
Posts: 44
Joined: Mon Apr 06, 2009 5:31 pm

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

Post 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
geoff.sim
Starting out
Posts: 10
Joined: Wed Feb 09, 2011 1:33 am

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

Post 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
rvn_2009
First post
Posts: 1
Joined: Thu Aug 30, 2012 4:47 am

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

Post 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
User avatar
River Trent
Know my way around
Posts: 144
Joined: Wed Dec 02, 2009 10:24 pm

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

Post 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
sunilmkt
New here
Posts: 7
Joined: Wed Dec 05, 2012 8:06 pm
Contact:

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

Post by sunilmkt »

I have bad experience for updating through DNS-O-matic. script works well. Thanks
Locked

Return to “File Sharing”