cloudflare-dns-updater/README.md

72 lines
1.4 KiB
Markdown
Raw Normal View History

2022-11-26 19:24:15 +00:00
# Cloudflare DNS Updater
## Create and activating a venv
2022-11-26 19:24:15 +00:00
Make sure Python 3.10 or higher is installed.
Use `cd` to change to the location of this repository.
2022-11-26 19:24:15 +00:00
Now, run
2022-11-26 19:24:15 +00:00
```
py -3.10 -m venv venv
2022-11-26 19:24:15 +00:00
```
Replace the `-3.10` with other Python versions if necessary (ex.: `-3.11`)
2022-11-26 19:24:15 +00:00
Activate the venv using the command
```
venv/scripts/activate
```
2022-11-26 19:24:15 +00:00
## Installing the required packages
2022-11-26 19:24:15 +00:00
Make sure the venv is activated.
2022-11-26 19:24:15 +00:00
Run the following command
```
pip install -r requirements.txt
```
2022-11-26 19:24:15 +00:00
Alternatively, the packages can be installed manually by using `pip install`.
2022-11-26 19:24:15 +00:00
The full list of packages needed:
- cloudflare (Version 2.0.0 or greater)
- Buildins:
- json
- configparser
- ipaddress
- sys
2022-11-26 19:24:15 +00:00
## Using the script
2022-11-26 19:24:15 +00:00
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:
```ini
[cloudflare]
TOKEN=<cloudflare api token>
2022-11-26 19:24:15 +00:00
[server]
HOSTNAME=hostname-of-website.com
```
2022-11-26 19:24:15 +00:00
Run the script using the following arguments:
```
python cloudflare_script.py <ipversion> <path/to/ip/list>
```
2022-11-26 19:24:15 +00:00
IP-Version can be 4 or 6.
The IP-List has to conform to the following structure and be a json file:
```json
{
"AAAA": [
"ipv6 site prefix"
],
"A": [
"ipv4 site prefix"
]
}
```
2022-11-26 19:24:15 +00:00
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