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.
- Sitelutions PHP Script
- Resolve a hostname to IP in a bash script
- Find out your router’s external IP address using the Linux command line
- HOWTO: Check you external IP Address from the command line
- Append Line to a File
- string concatenation in bash
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.