NETGEAR is aware of a growing number of phone and online scams. To learn how to stay safe click here.
Forum Discussion
bnichols
Apr 25, 2009Guide
DNS-O-Matic add-on
Am just trying Super Poussin's new DNS-O-Matic add-on. Installed, disabled, modified the dnsomatic file and restarted the service. There doesn't seem to be a way to confirm that it's working. If I ...
sethcshort
Aug 01, 2013Aspirant
I didn't continue using DDClient, it seemed too much of a pain to configure.
Instead, I went back to DnsOMatic, and debugged the script (the "dnsomatic" file that's in [ReadyNAS]/addons-scripts/DnsOMatic).
NOTE: I DISCOVERED THAT MY PROBLEMS STEMMED FROM THE FACT THAT MY PASSWORD HAD SYMBOLS IN IT (specifically "!") WHICH BROKE THE SCRIPT. I'D SUGGEST CHANGING YOUR PASSWORD TO JUST LETTERS/NUMBERS.
While I was in there, I made some of the stuff into variables that can be easily edited to allow the script to update with different services. I currently use it to update directly to no-ip.com's service, so I don't have to keep track of two accounts. I also removed the excess code and commented the rest so it should be easier to understand. And I made it so the log file will appear in the same folder as the script so the casual user can see it.
Here's the modified script that should work properly with DnsOMatic's service:
---
And here's the same script, but the first few variables are adjusted to work with no-ip. Basically, we're hijacking this plugin to serve our own nefarious ends. 8)
Note the changes to HOSTNAME (insert your no-ip hostname here), DYNUPDHOST and MYIPHOST (using no-ip's service), and ADDHOSTARGS (I removed the stuff that I didn't need for no-ip updates).
SO... in theory, you can replace the code in your dnsomatic script file with this code and be good to go. Don't forget to disable the add-on before editing, and re-enable afterward.
I've tried both versions of the scripts above, and they do work.
Have fun!
Seth
Instead, I went back to DnsOMatic, and debugged the script (the "dnsomatic" file that's in [ReadyNAS]/addons-scripts/DnsOMatic).
NOTE: I DISCOVERED THAT MY PROBLEMS STEMMED FROM THE FACT THAT MY PASSWORD HAD SYMBOLS IN IT (specifically "!") WHICH BROKE THE SCRIPT. I'D SUGGEST CHANGING YOUR PASSWORD TO JUST LETTERS/NUMBERS.
While I was in there, I made some of the stuff into variables that can be easily edited to allow the script to update with different services. I currently use it to update directly to no-ip.com's service, so I don't have to keep track of two accounts. I also removed the excess code and commented the rest so it should be easier to understand. And I made it so the log file will appear in the same folder as the script so the casual user can see it.
Here's the modified script that should work properly with DnsOMatic's service:
#!/bin/bash
HOSTNAME="all.dnsomatic.com"
USER=xxxxxx
PASS=password
DYNUPDHOST="updates.dnsomatic.com"
MYIPHOST="myip.dnsomatic.com"
ADDHOSTARGS="&wildcard=NOCHG&mx=NOCHG&backmx=NOCHG"
TMPFILE="/addons-scripts/DnsOMatic/oldip.DNS-O-Matic"
LOGFILE="/addons-scripts/DnsOMatic/DNS-O-Matic.log"
DATENOW=$(date)
TIME=$(date +%R)
DOW=$(date +%w)
# Turn debug to "Yes" if you want verbose info to be logged
DEBUG="NO"
# If password hasn't changed from default, this hasn't been updated -- exit out now
if [ $PASS = "password" ]; then
exit 0
fi
# Find out my external IP via "my IP" service
IP=$(/usr/local/bin/curl -s http://${MYIPHOST})
if [ $DEBUG = "Yes" ]; then
echo $DATENOW ": Running" $DOW $TIME $IP>> $LOGFILE
fi
if [[ -z $IP ]]; then
# NO IP discovered, can't update
echo $DATENOW ": NO Internet IP : exiting" >> $LOGFILE
exit 0
fi
# If the "oldip" file exists, pull OLDIP from it
if [ -r "$TMPFILE" ]; then
OLDIP=`cat $TMPFILE`
if [ $DEBUG = "Yes" ]; then
echo $DATENOW ": found:" $IP " cached IP:" $OLDIP >> $LOGFILE
fi
# If old IP cache doesn't exist (see above), create it for use next time
else
touch $TMPFILE
fi
# IF it's Monday at 1AM, force an update by blanking OLDIP
if [ $DOW = "1" ];then
if [ $TIME = "01:00" ]; then
echo $DATENOW ": Resetting IP" $TIME >> $LOGFILE
OLDIP=""
fi
fi
# IF cached IP and current IP match, no change, quit
if [ "$OLDIP" = "$IP" ]; then
if [ $DEBUG = "Yes" ]; then
echo $DATENOW ": Current IP " $IP " and cached IP " $OLDIP " match, NO UPDATE" >> $LOGFILE
fi
exit 0
# Otherwise, update to current IP
else
echo $DATENOW ": Current IP" $IP "and cached IP" $OLDIP " MISMATCH, requesting IP update" >> $LOGFILE
RETURN=$(/usr/local/bin/curl -k -s http://${USER}:${PASS}@${DYNUPDHOST}/nic/update?hostname=${HOSTNAME}&myip=${IP}${ADDHOSTARGS})
echo $DATENOW ": Return message of $DYNUPDHOST : " $RETURN >> $LOGFILE
echo $RETURN | grep "good|nochg" > /dev/null 2>&1
# IF the update was a success (got a "good" or "nochg" response), put the new ip address into the oldip tempfile
if [ "$?" -eq "0" ]; then
echo $IP > $TMPFILE
echo $DATENOW ": Update successful. New IP" $IP " written to cache " $TMPFILE >> $LOGFILE
else
# Otherwise, blank the tempfile to force another try next time
echo "" > $TMPFILE
echo $DATENOW ": IP cache cleared " $TMPFILE >> $LOGFILE
fi
fi
---
And here's the same script, but the first few variables are adjusted to work with no-ip. Basically, we're hijacking this plugin to serve our own nefarious ends. 8)
Note the changes to HOSTNAME (insert your no-ip hostname here), DYNUPDHOST and MYIPHOST (using no-ip's service), and ADDHOSTARGS (I removed the stuff that I didn't need for no-ip updates).
#!/bin/bash
HOSTNAME="XXXXXXXX.XXXXXXXX.XXX"
USER=xxxxxx
PASS=password
DYNUPDHOST="dynupdate.no-ip.com"
MYIPHOST="ip1.dynupdate.no-ip.com"
ADDHOSTARGS=""
TMPFILE="/addons-scripts/DnsOMatic/oldip.DNS-O-Matic"
LOGFILE="/addons-scripts/DnsOMatic/DNS-O-Matic.log"
DATENOW=$(date)
TIME=$(date +%R)
DOW=$(date +%w)
# Turn debug to "Yes" if you want verbose info to be logged
DEBUG="NO"
# If password hasn't changed from default, this hasn't been updated -- exit out now
if [ $PASS = "password" ]; then
exit 0
fi
# Find out my external IP via "my IP" service
IP=$(/usr/local/bin/curl -s http://${MYIPHOST})
if [ $DEBUG = "Yes" ]; then
echo $DATENOW ": Running" $DOW $TIME $IP>> $LOGFILE
fi
if [[ -z $IP ]]; then
# NO IP discovered, can't update
echo $DATENOW ": NO Internet IP : exiting" >> $LOGFILE
exit 0
fi
# If the "oldip" file exists, pull OLDIP from it
if [ -r "$TMPFILE" ]; then
OLDIP=`cat $TMPFILE`
if [ $DEBUG = "Yes" ]; then
echo $DATENOW ": found:" $IP " cached IP:" $OLDIP >> $LOGFILE
fi
# If old IP cache doesn't exist (see above), create it for use next time
else
touch $TMPFILE
fi
# IF it's Monday at 1AM, force an update by blanking OLDIP
if [ $DOW = "1" ];then
if [ $TIME = "01:00" ]; then
echo $DATENOW ": Resetting IP" $TIME >> $LOGFILE
OLDIP=""
fi
fi
# IF cached IP and current IP match, no change, quit
if [ "$OLDIP" = "$IP" ]; then
if [ $DEBUG = "Yes" ]; then
echo $DATENOW ": Current IP " $IP " and cached IP " $OLDIP " match, NO UPDATE" >> $LOGFILE
fi
exit 0
# Otherwise, update to current IP
else
echo $DATENOW ": Current IP" $IP "and cached IP" $OLDIP " MISMATCH, requesting IP update" >> $LOGFILE
RETURN=$(/usr/local/bin/curl -k -s https://${USER}:${PASS}@${DYNUPDHOST}/nic/update?hostname=${HOSTNAME}&myip=${IP}${ADDHOSTARGS})
echo $DATENOW ": Return message of $DYNUPDHOST : " $RETURN >> $LOGFILE
echo $RETURN | grep "good|nochg" > /dev/null 2>&1
# IF the update was a success (got a "good" or "nochg" response), put the new ip address into the oldip tempfile
if [ "$?" -eq "0" ]; then
echo $IP > $TMPFILE
echo $DATENOW ": Update successful. New IP" $IP " written to cache " $TMPFILE >> $LOGFILE
else
# Otherwise, blank the tempfile to force another try next time
echo "" > $TMPFILE
echo $DATENOW ": IP cache cleared " $TMPFILE >> $LOGFILE
fi
fi
SO... in theory, you can replace the code in your dnsomatic script file with this code and be good to go. Don't forget to disable the add-on before editing, and re-enable afterward.
I've tried both versions of the scripts above, and they do work.
Have fun!
Seth
Related Content
NETGEAR Academy
Boost your skills with the Netgear Academy - Get trained, certified and stay ahead with the latest Netgear technology!
Join Us!