Update script DNS-O-Matic v1.0
2008 November 7
I have updated the DNS-O-Matic scrip. You can check previous versions here or here. The new version writes to the log and updates all domainnames to the same IP for a single domain update look at a previous update.
Here is the code or can be downloaded here.
#!/bin/bash
HOSTNAME="all.dnsomatic.com"
USER="username"
PASS="password"
TMPFILE="/tmp/oldip.DNS-O-Matic"
LOGFILE="/var/log/DNS-O-Matic.log"
DATENOW=$(date)
IP=$(curl -s http://whatismyip.akamai.com/)
if [ -r "/tmp/oldip.DNS-O-Matic" ]; then
OLDIP=`cat /tmp/oldip.DNS-O-Matic`
echo $DATENOW ": found:" $IP " cached IP:" $OLDIP >> $LOGFILE
if [ "$OLDIP" = "$IP" ]; then
exit 0
else
RETURN=$(curl -s 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
6 Responses
leave one →
Thank you.
Do yourself & the myip.dk folks a favour and have a read of the page source of the document that you are retrieving.
@Gerry,
What do you mean by read page, instead of a curl and directly do egrep on it. Do?
please explain…
Do as the server admin requests, and use the alternative URI http://www.myip.dk/text/ ; It’ll reduce their server load, you won’t
have to do any grep’ing and everybody wins.
From:
$ curl http://myip.dk/|less +/INFO:
The HTML of this page/site might change at any point in time,
so if your writing a utility that needs your current external
IP address, please request the following url instead:
http://www.myip.dk/text/
The added benefit of using that address instead, is beneficial
for both of us, it doesnt return anything but the actual ip
address as normal “text/plain” so theres nothing to parse, and
it reduces the load of the server considerable.
I reserve the right to block your requests if your doing more
than 4 automated requests per 5 minutes 24/7. This only applies
to automated tools, theres no restrictions for actual users.
@Gerry,
I will change it but when I try to reach the page (http://www.myip.dk/text/) I get the following error:
Directory Listing Denied
This Virtual Directory does not allow contents to be listed.
When they fix it I’ll change the script.
Thx will change the script directly