Update readme with planned config setup
This commit is contained in:
parent
d2f89f0938
commit
f66fd67159
1 changed files with 32 additions and 62 deletions
94
README.md
94
README.md
|
@ -1,72 +1,42 @@
|
||||||
# Cloudflare DNS Updater
|
# 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
|
## Using the application
|
||||||
```
|
|
||||||
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
|
The application necessarily requires a valid Cloudflare API Token.
|
||||||
```
|
Further the application must be located in the same network as the configured zones.
|
||||||
venv/scripts/activate
|
|
||||||
|
| 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.
|
[[entry]]
|
||||||
|
name="example.org" # "@" Symbol is not currently supported
|
||||||
Run the following command
|
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
|
||||||
pip install -r requirements.txt
|
|
||||||
```
|
```
|
||||||
|
|
||||||
Alternatively, the packages can be installed manually by using `pip install`.
|
## Debian Repository
|
||||||
|
TODO!
|
||||||
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
|
|
Loading…
Reference in a new issue