Skip to content

Instantly share code, notes, and snippets.

@fernandogcat
Created March 6, 2016 14:18
Show Gist options
  • Select an option

  • Save fernandogcat/ed534250659e56c58ae8 to your computer and use it in GitHub Desktop.

Select an option

Save fernandogcat/ed534250659e56c58ae8 to your computer and use it in GitHub Desktop.
Dynamic DNS using Digital Ocean API v2
#!/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