https://github.com/bigcheeze45/cloudflare_ddns
Update Cloudflare DNS when public IP changes
https://github.com/bigcheeze45/cloudflare_ddns
cloudflare ddns-script ddns-updater python3
Last synced: about 1 month ago
JSON representation
Update Cloudflare DNS when public IP changes
- Host: GitHub
- URL: https://github.com/bigcheeze45/cloudflare_ddns
- Owner: BigCheeze45
- License: mit
- Created: 2025-08-23T19:58:43.000Z (10 months ago)
- Default Branch: main
- Last Pushed: 2025-09-26T16:05:58.000Z (9 months ago)
- Last Synced: 2025-10-13T16:55:37.467Z (9 months ago)
- Topics: cloudflare, ddns-script, ddns-updater, python3
- Language: Python
- Homepage:
- Size: 25.4 KB
- Stars: 0
- Watchers: 0
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Dynamic DNS updater for Cloudflare
This script monitors your public IP address and automatically updates a specified
Cloudflare DNS record when your IP changes. Useful for maintaining access to
home servers or services when using dynamic IP addresses from ISPs.
This project is a Python implemtation of [Paul Sørensen's blog post](
https://paulsorensen.io/configure-ddns-with-cloudflare/) and does
not utilize Cloudflare Workers.
### Prerequisites
This script is helpful if the following conditions apply:
1. You have a domain.
2. Domain points to a server with a dynamic IP.
2. **DNS management is done via Cloudflare**. This script will not work as is if DNS records are managed somewhere else.
## Getting Started
If you use pip:
```shell
pip install --no-deps -r requirements.txt
```
If you use [poetry](https://python-poetry.org/):
```shell
poetry install
```
### Example `main.py`
```python
import requests
from dotenv import dotenv_values
from cloudflare import CloudflareError
from ddns_updater import update_dns_ip
if __name__ == "__main__":
# Load secrets from .env file
secrets = dotenv_values()
try:
record = update_dns_ip(**secrets)
if record:
# DNS updated
pass
except CloudflareError as ce:
pass
except requests.exceptions.HTTPError as htte:
pass
except Exception as e:
pass
```