Cloudflare DNS Updater written in Rust. Works for IPv4 and IPv6 alike.
Find a file
Neshura 27bb82767b
Various bugfixes and changes
1: Script had AAAA hardcoded, this would've changed all records to AAAA.
2: Script was not saving the DNS Records ids, only their names this would've made it impossible to actually edit the DNS Record
3: Lowered the amount of printing going on, removed irrelevant information such as zoneid from the print statements, also removed most printing during the update phase
2022-11-28 20:25:42 +01:00
.gitignore Wrote new version of script, please test before merging 2022-11-27 19:00:42 +01:00
cloudflare-dns-new.py Various bugfixes and changes 2022-11-28 20:25:42 +01:00
cloudflare.json Workaround for #2 did not work 2022-11-27 16:10:55 +01:00
cloudflare_script.py Uncaught syntax error 2022-11-27 18:50:01 +01:00
config.ini Upload New File 2022-11-26 19:51:00 +00:00
Dockerfile Adjust Dockerfile for feature/reorganize 2022-11-27 17:07:46 +01:00
README.md Modified README.md (new information), added requirements.txt for easy venv setup 2022-11-27 16:42:15 +01:00
requirements.txt Modified README.md (new information), added requirements.txt for easy venv setup 2022-11-27 16:42:15 +01:00
set_ip.sh Added ipv4 specification to bash script 2022-11-27 18:39:34 +01:00

Cloudflare DNS Updater

Create and activating a venv

Make sure Python 3.10 or higher is installed. Use cd to change to the location of this repository.

Now, run

py -3.10 -m venv venv

Replace the -3.10 with other Python versions if necessary (ex.: -3.11)

Activate the venv using the command

venv/scripts/activate

Installing the required packages

Make sure the venv is activated.

Run the following command

pip install -r requirements.txt

Alternatively, the packages can be installed manually by using pip install.

The full list of packages needed:

  • cloudflare (Version 2.0.0 or greater)
  • Buildins:
    • json
    • configparser
    • ipaddress
    • sys

Using the script

Before running the script, make sure there exists a config.ini file next to the cloudflare_script.py. The config has to have the following structure:

[cloudflare]
TOKEN=<cloudflare api token>

[server]
HOSTNAME=hostname-of-website.com

Run the script using the following arguments:

python cloudflare_script.py <ipversion> <path/to/ip/list>

IP-Version can be 4 or 6. The IP-List has to conform to the following structure and be a json file:

{
  "AAAA": [
    "ipv6 site prefix"
  ],
  "A": [
    "ipv4 site prefix"
  ]
}

To only get the currently registered DNS records for a given API key, run

python cloudflare_script.py

THis will print all DNS records for the API key with name, ip, cloudflare id and ip-version