Bash Script for Sitelutions.com DynDNS

I use sitelutions.com for my websites and subdomains; I love using sitelutions because it’s the best free solution I found for my servers with dynamic IPs. The only problem is that there’s not very many dyndns update clients available. So, I tried my hand at scripting and this is what I’ve come up with.

#!/bin/sh

#### SITELUTIONS DYNDNS UPDATE SCRIPT ####

USERNAME="email"
PASSWORD="password"

#Separate record ids by a comma

RECORDIDS="1234567"
TTL="600"

LOGFILE="/var/log/sitelutions.log"

### Ways to retrieve IP address ##

##(Default) use sitelutions
IP="&detectip=1"

##Retrieve from external site (HTTP)
##icanhazip.com (alternatives: ipid.shat.net/iponly, whatismyip.com, etc)
#IP=`wget -O - -q icanhazip.com`

##existing domain IP
#IP=`nslookup domain.com | grep Add | grep -v '#' | cut -f 2 -d ' '`

#Build https request
REQUEST="https://www.sitelutions.com/dnsup?user=$USERNAME&pass=$PASSWORD&id=$RECORDIDS&ip=$IP"
OUTPUT=`wget -O - -q $REQUEST`

LOG=`date +%c`" "$OUTPUT
echo $LOG >> $LOGFILE

Once you’ve confirmed that this works you can simply throw it in as a cronjob that runs every 30 minutes or so. I have mine run every 3 hours.

Hope this is helpful to anyone else using sitelutions! Bash scripting is pretty cool, I’m definitely going to use it more. If you have any tips on how to improve the script feel free to comment.

Resources:

Update 12/1/2010: I’ve stopped updating the TTL in my script below because I’m getting an error “failure (invalid ttl)” – it appears 600 is not a good value for the TTL. You can add it back if you want, though it works without it and will simply use the existing value for TTL. More on the Sitelutions api can be found here.

Comments

Sitelutions

Hello,

That's a good script! We're adding your script to the list of Dynamic DNS clients on our website, and it should be live by the end of the day today (after a couple rounds of testing, of course).

As for suggestions: you could include a simple if/then statement to check multiple sources for the IP address, and compare them to each other. If they come out "in agreement", it can then move forward and publish the change.

Keep up the good work!

Leave a comment

Your email address will not be published. Required fields are marked *

Loading...