1.0.0 Rework #25
1 changed files with 32 additions and 62 deletions
94
README.md
94
README.md
|
@ -1,72 +1,42 @@
|
|||
# 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`)
|
||||
## Using the application
|
||||
|
||||
Activate the venv using the command
|
||||
```
|
||||
venv/scripts/activate
|
||||
The application necessarily requires a valid Cloudflare API Token.
|
||||
Further the application must be located in the same network as the configured zones.
|
||||
|
||||
| Environment Variable | Required | Usage |
|
||||
|:--------------------:|:--------:|:----------------------------------:|
|
||||
| CF_API_TOKEN | x | Cloudflare API Token |
|
||||
| STATUS_POST_URL | | Post Endpoint for a Uptime Monitor |
|
||||
*Note: Variables can be stored in a .env file*
|
||||
|
||||
The actual configuration happens in two or more files:
|
||||
`interfaces.toml` contains all IPv6 interfaces available/used by the zone config files.
|
||||
`.toml` files in `zone.d` contain settings for individual zones.
|
||||
|
||||
Example:
|
||||
|
||||
*interfaces.toml*
|
||||
```toml
|
||||
[[interface]]
|
||||
alias = "example-interface-1" # this is what a user inputs in the zone.toml
|
||||
address = ":da5e:d3ff:feeb:4346" # static part of the IP, the rest will be dynamically generated using the host
|
||||
```
|
||||
|
||||
## Installing the required packages
|
||||
*zone.d/example.org.toml*
|
||||
```toml
|
||||
email = "owner@example.org" # Email of User owning the Zone
|
||||
name = "example.org" # Zone Name
|
||||
id = "0183f167a051f1e432c0d931478638b5" # Zone ID
|
||||
|
||||
Make sure the venv is activated.
|
||||
|
||||
Run the following command
|
||||
```
|
||||
pip install -r requirements.txt
|
||||
[[entry]]
|
||||
name="example.org" # "@" Symbol is not currently supported
|
||||
type="10" # Options are: "4" (only IPv4/A Record), "6" (only IPv6/AAAA Record) and "10" (both)
|
||||
interface="example-interface-1" # Only required on type values 6 and 10
|
||||
```
|
||||
|
||||
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:
|
||||
```ini
|
||||
[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:
|
||||
```json
|
||||
{
|
||||
"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
|
||||
## Debian Repository
|
||||
TODO!
|
Loading…
Reference in a new issue