Script to set your home (or business) IP address via cloudflare dns on A-record domain record.
Specially used when you do not have a fixed IP address.
This script checks your current IP address by using the Amazon service checkip.amazonaws.com. The service checkip.amazonaws.com provides the public IP address of the client making the request. Please be sure that your device running this script is not behind a VPN.
do a git clone
git clone [email protected]:oddobert/ddns_online.git
Go into the folder that was created
cd python_ddns
Create an environment when needed within the folder
# macOS/Linux
# You may need to run sudo apt-get install python3-venv first
python3 -m venv .venv
# Windows
# You can also use py -3 -m venv .venv
python -m venv .venv
Then install the needed requirements with
pip install -r requirements.txt
Create a config.ini from the config_sample.ini
NOTICE: KEEP your zone_id and API-Key to yourself!!!! Do not share with anyone!!!
With the following information
- zone_id =
- api_token =
- ip_address_type = A
- dns_name =
For this script to work your need:
- A cloudflare account (pick the free one)
- Set a A-record, with current ip address to the desired domain / subdomain
- A zone_id, can be found on the right side of the screen when you scroll down
- A API-Key, also found on right side of screen, make sure the API-key is able to edit the DNS
python ddns.py
That's all folks!
Notice! Before building and running the Dockerfile please create your own config.ini file with the right information
You can als run a docker instance with this script (as you like running Dockers)
This docker is running the Alpine Python framework. It's smaller than 80Mb, so lightweight (the normal python mage is 980mb)! Great to run on a Raspberry Pi.
To create the Docker environment (I assume you already have docker running) do:
docker build -t auto_ddns .
The docker build command builds Docker images from a Dockerfile and a “context”. A build’s context is the set of files located in the specified PATH or URL. The build process can refer to any of the files in the context. For example, your build can use a COPY instruction to reference a file in the context.
To run the docker (on the background) do:
docker run -d auto_ddns
That's all folks!
OddObert.
Originally based on: 👤 Theo van der Sluijs
- Github: @tvdsluijs