What's new

DDNS DigitalOcean

  • SNBForums Code of Conduct

    SNBForums is a community for everyone, no matter what their level of experience.

    Please be tolerant and patient of others, especially newcomers. We are all here to share and learn!

    The rules are simple: Be patient, be nice, be helpful or be gone!

untarded

New Around Here
Here is a ddns-start custom script for DigitalOcean. Since I already host a few domains there it made sense to utilize their dns service. In order to utilize this you will need to do some prep work though. DigitalOcean assigns id numbers to each dns record and those ids are not available in their web interface so you'll have to call the api to pull the dns records for a particular domain in curl or an api tool like Postman (Chrome browser app).


1) Be sure you've added the domain and the A record in your dns online.
2) You need to generate an access token.
3) make the following api call (replace example token with your access token) to get a list of all of the dns records for your domain (if your using sofware to make the api call like Postman then reference https://developers.digitalocean.com/#list-all-domain-records).

Code:
curl -X GET -H 'Content-Type: application/json' -H 'Authorization: Bearer [B]b7d03a6947b217efb6f3ec3bd3504582[/B]' "https://api.digitalocean.com/v2/domains/[B]mydomain.com[/B]/records"

4) Make note of the "id" value of the particular record you are looking to manage (the "name" value)
5) Edit the following script adding your access token, the record id and the domain.

Code:
#!/bin/sh

## START EDIT HERE.
do_access_token="blahblahblahblahblahblahblahblahblahblah";
do_record_id="1234567"
do_api_url="https://api.digitalocean.com/v2";
do_domain="mydomain.com";   		
curl_timeout="15";
## END EDIT.

ip_address=$1;

curl -s --connect-timeout $curl_timeout -H "Content-Type: application/json" -H "Authorization: Bearer $do_access_token" -X PUT "$do_api_url/domains/$do_domain/records/$do_record_id" -d'{"data":"'"$ip_address"'"}';

/sbin/ddns_custom_updated 1
 
Last edited:

Similar threads

Latest threads

Sign Up For SNBForums Daily Digest

Get an update of what's new every day delivered to your mailbox. Sign up here!
Top