almost human fully human



Own DDNS service powered by Digital Ocean

Although Digital Ocean provide its own DNS servers, it’s possible to set a simple DDNS, since they provide a handy api for domain settings manipulation. I’ve written a small script that has to be installed on every machine, which IP we want to track. Remember to modify token, domain_name and record_name variables.

This script was made for using a Digital Ocean's droplet as a ddns service.
[!] Remember to put your credentials below.
[!] Script needs requests library. To install it use pip: pip install requests.
Before you'll start, check if it works properly with your config. Simply run it:
Use cron to execute it every x minutes. There's an example of 5 minutes interval:
*/5 * * * * /usr/bin/python /home/user/
This script was released into the public domain.
Contact me:


token = "insertyourtokenhere"
domain_name = ""
record_name = "examplerecord"


import requests, re
from requests.auth import HTTPBasicAuth

headers = { "Authorization": "Bearer " + token }

def get_ip():
    return re.findall( r'[0-9]+(?:\.[0-9]+){3}', requests.get("").text )[0]

def get_record_id(domain):
    records_url = "" % domain

    r = requests.get(records_url, headers=headers).json()

    for a in r['domain_records']:
        if a['name'] == record_name:
            return (domain, a['id'])

def set_record_ip(recdata):
    record_url = "" % recdata
    r = requests.put(record_url, headers=headers, data={"data": str(get_ip())})
    return r.status_code

if set_record_ip(get_record_id(domain_name)) == 200:
    print("Done. Address for record %s of domain %s set to %s." % (record_name, domain_name, get_ip()))