Digital Ocean Dynamic DNS

I wrote a Python script to update DNS records managed by Digital Ocean. This might be useful for home servers with dynamic IP addresses.

The script queries the ipify API to get the public IPv4 and IPv6 addresses of the server running the script. Each specified record in a specified domain is then updated, if, and only if, the A or AAAA record known by Digital Ocean does not match the corresponding IP address returned by ipify.

Note: This project is managed on Codeberg.


Installation is straightforward.

Clone the Repository

git clone DigitalOceanDynamicDNS

Create Python Environment

cd DigitalOceanDynamicDNS
python3 -m venv env

Install Libraries

The script requires the requests library. All requirements can be installed by invoking pip:

source bin/env/activate
pip install -r requirements


To configure doDynDNS, a .do.conf file must be created in the root folder of the project:

touch .do.conf

The configuration requires two sections, a DigitalOcean section containing a valid API Access Key, and a DNS section, containing the specific domain and specific records to update. Multiple records can be specified by simply putting each record into a new line:

key = ***

domain =
records = sub1


To automatically run the script periodically, create a cronjob

crontab -e
*/5 * * * * cd /pathToFolder && /pathToFolder/env/bin/python3 /pathToFolder/

Manual Run

To manually run the script, activate the environment and then invoke the Python interpreter.

Activate the Environment

source env/bin/activate




The script automatically logs its last run in the doDynDNS.log file.