Skip to content

Instantly share code, notes, and snippets.

@woods
Last active January 9, 2019 20:14
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save woods/6899600 to your computer and use it in GitHub Desktop.
Save woods/6899600 to your computer and use it in GitHub Desktop.
A cron script to periodically update a DNS record in DNSimple for a dynamic IP address.
#!/bin/bash
#
# When a machine is on a dynamic IP address cable modem, we use this script to
# periodically update DNS with the current record.
#
# Keep the contents of this file secret, since it contains the domain's API
# key. The ID of the record to be updated by hovering over it in DNSimple's
# web interface.
IP_ADDRESS="`curl -s http://icanhazip.com/`"
curl -H 'X-DNSimple-Domain-Token: XXXXXXXXXXXXXXXXXXXXXXXXXXX' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
--include --silent \
-X PUT -d "{\"record\":{\"content\":\"$IP_ADDRESS\"}}" \
https://dnsimple.com/domains/example.com/records/1234567 > /tmp/update_ip_address.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment