Skip to content

Instantly share code, notes, and snippets.

@jpts
Forked from yourbuddyconner/dns_update.sh
Last active April 10, 2017 15:11
Show Gist options
  • Save jpts/bcdab17e0da7e729d35c4a22af905fc5 to your computer and use it in GitHub Desktop.
Save jpts/bcdab17e0da7e729d35c4a22af905fc5 to your computer and use it in GitHub Desktop.
NameCheap Dynamic DNS Updater Script
  1. Enable Dynamic DNS for your domain. You'll get a "password" that you can use for their API Endpoint.
  2. Replace variable values with your own.
  3. Put the script in a safe place (I just used my home folder)
  4. Set a cron job (or other recurring service) to run your script.
  5. ???
  6. Profit
#/bin/bash
Host_Name=host
Domain=example.com
Password="PASS_HASH_FROM_NAMECHEAP"
IP_Address=$(curl -s icanhazip.com)
url="https://dynamicdns.park-your-domain.com/update?host=$Host_Name&domain=$Domain&password=$Password"
result=$(curl -s --globoff $url)
NEW_IP=$(echo $result | sed -E 's/^.*IP>(.+)<\/IP.*$/\1/')
DONE=$(echo $result | sed -E 's/^.*Done>(.+)<\/Done.*$/\1/i')
echo "Request URL: $url"
if [[ $DONE == 'true' ]]; then
echo "New IP: $NEW_IP"
else
echo "Success: $DONE"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment