Skip to content

Instantly share code, notes, and snippets.

@woods
Created August 26, 2013 15:41
Show Gist options
  • Save woods/6342887 to your computer and use it in GitHub Desktop.
Save woods/6342887 to your computer and use it in GitHub Desktop.
Example script to set a dynamic record in DNSimple based on the current cable modem address. This can be run in /etc/cron.hourly.
#!/bin/bash
#
# Since paig is on a dynamic IP address cable modem, we use this script to
# periodically update DNS with the current record. In this case, we're using
# the hostname paig.2surfers.com.
#
# 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: xxxxxxxxxxxxxxxxxxxxxxxx' \
-H 'Accept: application/json' \
-H 'Content-Type: application/json' \
-k -i -s -X PUT \
-d "{\"record\":{\"content\":\"$IP_ADDRESS\"}}" \
https://dnsimple.com/domains/2surfers.com/records/1612769 > /tmp/update_ip_address.out
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment