Last active
January 9, 2019 20:14
-
-
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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