Curt's Dynamic DNS Updater is a Python script designed to update DNS records automatically for dynamic IP addresses. This solution supports multiple DNS providers including Cloudflare.
- Automatic IP detection and DNS record update
- Support for multiple DNS providers
- Configurable via an INI file
- Runs continuously with a configurable check interval
- Python 3.12
requests
library
-
Update your package list:
sudo apt update
-
Install dependencies:
sudo apt install -y software-properties-common
-
Add the deadsnakes PPA:
sudo add-apt-repository ppa:deadsnakes/ppa sudo apt update
-
Install Python 3.12:
sudo apt install -y python3.12 python3.12-venv python3.12-dev
-
Clone the repository:
git clone https://github.com/cpjet64/curtsddns.git cd curtsddns
-
Create a virtual environment:
python3.12 -m venv venv
-
Activate the virtual environment:
source venv/bin/activate
-
Install the required dependencies:
pip install requests
-
Configure your DNS settings in the
config.ini
file usingconfig.ini.example
as a template:cp config.ini.example config.ini
The config.ini
file should be structured as follows:
[settings]
DNS_PROVIDER = cloudflare
CHECK_INTERVAL = 60
[cloudflare]
CLOUDFLARE_API_TOKEN = your_cloudflare_api_token
CLOUDFLARE_ZONE_ID = your_cloudflare_zone_id
CLOUDFLARE_RECORD_NAME = your_dns_record_name
To start the script, simply run:
python curtsddns.py
For continuous operation, you can set up a systemd service:
Copy the curtsddns.service file to /etc/systemd/system/ and then modify as needed:
sudo cp curtsddns.service /etc/systemd/system/
sudo nano /etc/systemd/system/curtsddns.service
Have the file created for you using the current user and file location:
echo "[Unit]
Description=Curt's Dynamic DNS Updater Service
After=network.target
[Service]
Type=simple
User=$(whoami)
WorkingDirectory=$(pwd)
ExecStart=$(pwd)/venv/bin/python $(pwd)/curtsddns.py
Restart=on-failure
[Install]
WantedBy=multi-user.target" | sudo tee /etc/systemd/system/curtsddns.service
Reload the systemd daemon:
sudo systemctl daemon-reload
Enable and start the service:
sudo systemctl enable curtsddns
sudo systemctl start curtsddns
- curtsddns.py: Main script for updating DNS records.
- cloudflare_module.py: Module for handling Cloudflare DNS updates.
- config.ini: Configuration file (create from config.ini.example).
- config.ini.example: Example configuration file.
- curtsddns.service: Systemd service file for running the script as a service.
- Dockerfile:Docker configuration file.
To run Curt's Dynamic DNS Updater in a Docker container, follow these steps:
- Docker installed on your system
-
Clone the repository:
git clone https://github.com/cpjet64/curtsddns.git cd curtsddns
-
Configure your DNS settings in the
config.ini
file usingconfig.ini.example
as a template:cp config.ini.example config.ini
Modify your
config.ini
according to your environment:nano config.ini
The
config.ini
file should be structured as follows:[settings] DNS_PROVIDER = cloudflare CHECK_INTERVAL = 60 [cloudflare] CLOUDFLARE_API_TOKEN = your_cloudflare_api_token CLOUDFLARE_ZONE_ID = your_cloudflare_zone_id CLOUDFLARE_RECORD_NAME = your_dns_record_name
-
Build the Docker image:
docker build -t curtsddns .
-
Run the Docker container:
docker run -d --restart unless-stopped --name curtsddns -v $(pwd)/config.ini:/app/config.ini curtsddns
-d
runs the container in detached mode.--name curtsddns
gives the container a name.-v $(pwd)/config.ini:/app/config.ini
mounts theconfig.ini
file from the host to the container.
-
To stop the container:
docker stop curtsddns
-
To start the container:
docker start curtsddns
-
To view the container logs:
docker logs curtsddns
-
To remove the container:
docker rm curtsddns
- Ensure that the
config.ini
file is properly configured before running the container. - You can customize the
Dockerfile
and Docker run command to suit your specific needs.
By following these steps, you can easily run Curt's Dynamic DNS Updater in a Docker container, simplifying deployment and management.
This project is licensed under the MIT License.
Contributions are welcome! Please fork the repository and submit a pull request.
For support or inquiries, please contact Curt at curt@curtpme.com.