Skip to main content

CloudFlare Dynamic DNS updater

Project description

# Cloudflare DNS client

Use the Cloudflare API to keep records up to date with your current IP address(es). By default it will try to get both IPv4 and IPv6 addresses from icanhazip.com. (new in v1.1.0)

This cron expression will add/update an A/AAAA record for domain.tld with your external IP address every 30 minutes: `*/30 * * * * cf-ddns.py --name domain.tld`

Make sure to set the required environment variable(s): * CF_API_TOKEN, for the recommended least privilege access model. * CF_EMAIL and CF_TOKEN, for the old access mode with the superuser account token.

Execute cf-ddns.py -h for a list of all the arguments.

You can add multiple names like this: `--name subdomain1.domain.tld someother.domain.tld`

If you want to use Sentry for alerts, set the DSN in the SENTRY_DSN environment variable.

## Requirements: - A Cloudflare account and domain name. - Python 3.4 or newer - Requests (https://github.com/kennethreitz/requests) - Optional: Raven (for Sentry alerting)

## Disclaimer: This software is provided as is. It should be safe, but don’t blame me if your computer blows up. It is tested on Mac OSX Python 3.7, Synology NAS Python 3.5.

## Installation: `pip install --upgrade cf-ddns`

Optionally with Sentry alerting:

`pip install --upgrade cf-ddns[sentry]`

## Usage with API (bearer) tokens If you want to use an API token, there are two options for zone permissions: 1. Allow access to read all zones. 2. Allow access to only a specific zone.

If you go with 2. (recommended), you have to set the zone id manually as a command-line argument with `--zone-id`. If you don’t you’ll get an error saying you don’t have permission to list all zones. This is because cf-ddns is trying to find your zone id from the DNS name you gave it and it needs to list all zones to do so.

Additionally the token must have access to edit DNS records.

Complete (bearer) token instructions: 1. Go to your Cloudflare profile page and click “API Tokens” in the top menu 2. Create new token 3. Type a name for you token and select “Start with a template” 4. Choose the “Edit zone DNS” template 5. Under “Zone Resources” choose the zone you want to use cf-ddns with 6. Continue and save, then copy the token to the CF_API_TOKEN environment variable. 7. Find the zone id on the dashboard Overview page and add it to the command in the `--zone-id` argument. 8. Execute cf-ddns with the `--verify-token` option to verify your setup. It will exit with code 0 for success and 1 for failure. Results are logged as well.

Check out the [Cloudflare blog post](https://blog.cloudflare.com/api-tokens-general-availability/) for more information about API tokens.

[@maedox](https://twitter.com/maedox/)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

cf-ddns-1.1.2.tar.gz (5.6 kB view details)

Uploaded Source

Built Distribution

cf_ddns-1.1.2-py3-none-any.whl (6.4 kB view details)

Uploaded Python 3

File details

Details for the file cf-ddns-1.1.2.tar.gz.

File metadata

  • Download URL: cf-ddns-1.1.2.tar.gz
  • Upload date:
  • Size: 5.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for cf-ddns-1.1.2.tar.gz
Algorithm Hash digest
SHA256 3221b9a24ff0f35a42001c48106ccb1d97538481340a23950e2f932f5acd06ec
MD5 73b1a4632d9a0fc2ca0653cf4352db3a
BLAKE2b-256 3cb845bb02a67dd741eb3b1207ced1fc21d6a2a30ead39e4df4fbff98a4dfdda

See more details on using hashes here.

File details

Details for the file cf_ddns-1.1.2-py3-none-any.whl.

File metadata

  • Download URL: cf_ddns-1.1.2-py3-none-any.whl
  • Upload date:
  • Size: 6.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.12.1 pkginfo/1.4.2 requests/2.20.0 setuptools/40.5.0 requests-toolbelt/0.8.0 tqdm/4.28.1 CPython/3.7.4

File hashes

Hashes for cf_ddns-1.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 8f6d81f212e6a3cb3c11866a600acc1b3ecee3d331e92811c8d145764e40404b
MD5 796d76e3c145e899c610b6ed66b7a880
BLAKE2b-256 d6f443476da3b1361bd101f86a8ea41214c36c95887a5dc5b6cf12be0bd97ac7

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page