Created
March 6, 2016 14:18
-
-
Save fernandogcat/ed534250659e56c58ae8 to your computer and use it in GitHub Desktop.
Dynamic DNS using Digital Ocean API v2
This file contains hidden or 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 | |
| #update an A record in digital Ocean. Dynamic DNS style. | |
| #API info here: | |
| #https://developers.digitalocean.com/#domains-list | |
| #your domain ID | |
| domain_id="XXX" | |
| #record to update | |
| record_id="XXX" | |
| #your api key | |
| api_key="XXX" | |
| ### don't change ### | |
| ip="$(curl http://ipecho.net/plain)" | |
| echo content="$(curl -H "Authorization: Bearer $api_key" -H "Content-Type: application/json" \ | |
| -d '{"type": "A", "name": "'"$record_name"'", "data": "'"$ip"'"}' \ | |
| -X PUT "https://api.digitalocean.com/v2/domains/$domain_id/records/$record_id")" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment