https://github.com/subbyte/cloudflare-ddns-posix
Cloudflare DDNS update service
https://github.com/subbyte/cloudflare-ddns-posix
cloudflare curl ddns openbsd posix shellscript
Last synced: 16 days ago
JSON representation
Cloudflare DDNS update service
- Host: GitHub
- URL: https://github.com/subbyte/cloudflare-ddns-posix
- Owner: subbyte
- License: gpl-3.0
- Created: 2024-02-18T19:32:38.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-01-15T01:02:01.000Z (3 months ago)
- Last Synced: 2025-02-13T08:52:40.413Z (2 months ago)
- Topics: cloudflare, curl, ddns, openbsd, posix, shellscript
- Language: Shell
- Homepage:
- Size: 19.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Cloudflare Dynamic DNS Update Service
Most existing Cloudflare DDNS scripts:
1. Use Python for network access (libressl complication on OpenBSD)
2. Need to config each domain individually in the zone
3. May not handle domain properties such as *proxied*/*non-proxied*## Design
- Update all domains, *proxied* and *non-proxied*, in a given zone
- Track IP update fast (every minute) without authenticated Cloudflare API
- Keep it simple (no Python, no bash) to run on BSD
- Be comprehensive regarding error handling and loggingHow to fast track IP update?
This script is designed to be run as cron job every minute. To minimize
authenticated connections to Cloudflare, it has an argument `sentinel_domain`,
which is any *non-proxied* domain in the given zone. `sentinel_domain` resolves
to the public IP directly (monitored publically with `dig`). If it is different
from the current public IP, then the script connects to Cloudflare to update
the DNS records.Why comprehensive?
The big drawback of shell scripting is unenforced error handling, especially
compared to pure functional languages such as Haskell. This could lead to tons
of unexpected behaviors in long-term real-world deployments. We need
comprehensive error handling and logging here.## Requirements
- `dig`
- `curl`
- `jq`## Install
1. Create `/etc/ddns/cloudflare.keys` with contents:
```
ZONE_ID=xxxxxx
API_TOKEN=xxxxxx
```2. Set the file `/etc/ddns/cloudflare.keys` to be only readable by the ddns service executor
3. Copy `ddns` to a directory of your choice, e.g., `/usr/local/bin/`
4. Add a cron job using `crontab -e` under the service executor/user:
```
* * * * * /usr/local/bin/ddns /etc/ddns/cloudflare.keys sentinel.domain 2>&1 | /usr/bin/logger -t ddns
```