Skip to content

Instantly share code, notes, and snippets.

@geoorgeous
Last active July 23, 2019 15:53
Show Gist options
  • Save geoorgeous/385a2f22a91ab53a0c99b3576f08ec96 to your computer and use it in GitHub Desktop.
Save geoorgeous/385a2f22a91ab53a0c99b3576f08ec96 to your computer and use it in GitHub Desktop.
A simple bash script that will update a host's IP address using the ZoneEdit DNS management service. Currently using on *and only tested on* my RaspberryPi Raspbian Apache2 web server
#!/bin/bash
# This file is intended to be used to update a host's IP address
# that uses the ZoneEdit DNS management service.
# This script uses dig to obtain the network's current public IP
# address which means it should be executed on a machine running
# on the same network as your server.
USERNAME=username
PASSWORD=password
HOST=examplehost.com
IP_ADDR="$(dig +short myip.opendns.com @resolver1.opendns.com)"
HTTP="https://dynamic.zoneedit.com/auth/dynamic.html?host=${HOST}&dnsto=${IP_ADDR}"
curl -u $USERNAME:$PASSWORD $HTTP
# To make this in to a cron job so this will run automatically,
# open your crontab jobs file by running the following command:
# sudo crontab -e
# then input the following line at the bottom of the file and save changes.
# */15 * * * * /path/to/update_ip.sh
# Doing this will make this script execute every 15th
# minute of every hour, keeping your domain up to date
# with your dynamic IP address within 15 minutes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment