PowerDNS Authoritative API client
Project description
powerdns-cli
PowerDNS-CLI is a cli tool to interact with the
PowerDNS Authoritative Nameserver.
PowerDNS itself does only offer an API to interact with remotely and
its pdns_util does only work on the PowerDNS-Host, not remotely from another machine.
So, you may use this tool to work with your PowerDNS Authoritative Nameserver.
Installation
Installation is available through pypi.org:
pip install powerdns-cli
Or as an oci container:
podman run --rm -it ghcr.io/IamLunchbox/powerdns-cli:latest powerdns-cli
If you want to clone from git, checkout the git tags and run pip install ..
Configuration
powerdns-cli is built with the click framework and uses keyword-based actions. Flags may
only follow after the last action.
To get things going you may, for example, add a zone:
$ powerdns-cli zone add -a MyApiKey -u http://localhost example.com PRIMARY
You may provide all flags through environment variables as well. Use the long
flag name in upper-case and prefix it with POWERDNS_CLI_. For example:
$ export POWERDNS_CLI_APIKEY="MyApiKey"
$ export POWERDNS_CLI_URL="http://localhost"
$ powerdns-cli zone add example.com PRIMARY
It is also possible to set the common configuration items in $HOME/.powerdns-cli.conf or
$HOME/.config/powerdns-cli/configuration.toml. The file format is toml, so you have to
explicitly use quotes for strings.
This is the required structure and the defaults:
apikey = ""
api-version = 4
debug = false
insecure = false
json = false
url = ""
Features
- Access to all API-Endpoints PowerDNS Auth exposes.
- CLI configuration through flags, environment variables or a configuration file.
- Exporting and importing data in JSON.
- Exporting RRSets in BIND.
- Idempotence.
- "Builtin" access to the current api-specification
Usage
Usage: powerdns-cli [OPTIONS] COMMAND [ARGS]...
Manage PowerDNS Authoritative Nameservers and their Zones/Records.
Options:
-h, --help Show this message and exit.
Commands:
autoprimary Change autoprimaries, which may modify this server.
config Show servers and their configuration
cryptokey Manage DNSSEC-Keys.
metadata Configure zone metadata.
network Set up networks views.
record Edit resource records (RRSets) of a zone.
tsigkey Set up server wide TSIGKeys, to sign transfer messages.
version Show the powerdns-cli version
view Configure views, which limit zone access based on IPs.
zone Manage zones and their configuration.
Refer to each action and its help page to find out more about each function.
Examples
# Add a zone
$ powerdns-cli zone add example.org. native
Successfully created example.org.
# Add some records
$ powerdns-cli record add www example.org A 127.0.0.1
www.example.org. A 127.0.0.1 created.
$ powerdns-cli record add @ example.org MX "10 mail.example.org."
example.org. MX 10 mail.example.org. created.
# Import example.com from integration test
$ cat ./integration/import-zone.json | powerdns-cli zone import -
Successfully added example.com..
# Delete zone, skipping confirmation
$ powerdns-cli zone delete example.com -f
Successfully deleted example.com..
If something goes wrong or does not work, use the -j-switch to get a more verbose json output.
This outputs includes some logging and a http-log, which might give you a hint what happened.
For example:
$ powerdns-cli record add @ example.org MX "10 mail.test.de" -j
[...]
{
"request": {
"method": "PATCH",
"url": "http://localhost:8082/api/v1/servers/localhost/zones/example.org."
},
"response": {
"status_code": 422,
"reason": "Unprocessable Entity",
"json": {
"error": "Record example.org./MX '10 mail.test.de': Not in expected format (parsed as '10 mail.test.de.')"
},
"text": ""
}
}
],
"data": null,
"success": false,
"message": "Failed to create example.org. MX 10 mail.test.de."
}
For scripting purposes: It is always guaranteed, that message and success is set. If your
action requests data, as do list and export, it resides in data. Otherwise, data should be null.
When JSON is not requested, the stdout message will be the export contents.
If you are in need of all the possible cli options, you may also take a look at the integration test. It uses all common cli options to test for api compatibility.
Caveats
- It is not possible to simply create a RRSet with several entries. Instead, you have to
use
powerdns-cli record extendor import a file. - There are no guardrails for removing records from a zone, only for removing a zone altogether.
Version Support
All the PowerDNS authoritative nameserver versions, which receive patches / security updates, are covered by integration tests. You can check if your version gets updates here. And you can check here which versions are actually tested.
If the PowerDNS-Team does not apply releases and changes to their publicly released docker images (see here), they won't be covered by the integration tests.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file powerdns_cli-1.1.0.tar.gz.
File metadata
- Download URL: powerdns_cli-1.1.0.tar.gz
- Upload date:
- Size: 69.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5a9a7066d2f8517d984657d7feea8f280855cd946221aaaa021eb01e841a14fc
|
|
| MD5 |
3b4ded2caeef0a90847d20417bfbf573
|
|
| BLAKE2b-256 |
dec3051259b6962a21437d1687f50421cd853b6434e8d95dba151cbfca69e9cb
|
Provenance
The following attestation bundles were made for powerdns_cli-1.1.0.tar.gz:
Publisher:
release.yml on IamLunchbox/powerdns-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
powerdns_cli-1.1.0.tar.gz -
Subject digest:
5a9a7066d2f8517d984657d7feea8f280855cd946221aaaa021eb01e841a14fc - Sigstore transparency entry: 713778635
- Sigstore integration time:
-
Permalink:
IamLunchbox/powerdns-cli@8dc7722894d31e347ed4a31949360c1d64143968 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/IamLunchbox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8dc7722894d31e347ed4a31949360c1d64143968 -
Trigger Event:
push
-
Statement type:
File details
Details for the file powerdns_cli-1.1.0-py3-none-any.whl.
File metadata
- Download URL: powerdns_cli-1.1.0-py3-none-any.whl
- Upload date:
- Size: 84.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
16bf2b12a33d4339b200196c65669b89ac228e14184f6e9d3419b3820778c5e4
|
|
| MD5 |
2253377dc277e5a328fdb31ef02622df
|
|
| BLAKE2b-256 |
c7c11a084a6a1f6b607dc2a1d3d0031042fb41e0a7882340a919f4fbee691ba8
|
Provenance
The following attestation bundles were made for powerdns_cli-1.1.0-py3-none-any.whl:
Publisher:
release.yml on IamLunchbox/powerdns-cli
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
powerdns_cli-1.1.0-py3-none-any.whl -
Subject digest:
16bf2b12a33d4339b200196c65669b89ac228e14184f6e9d3419b3820778c5e4 - Sigstore transparency entry: 713778648
- Sigstore integration time:
-
Permalink:
IamLunchbox/powerdns-cli@8dc7722894d31e347ed4a31949360c1d64143968 -
Branch / Tag:
refs/tags/1.1.0 - Owner: https://github.com/IamLunchbox
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@8dc7722894d31e347ed4a31949360c1d64143968 -
Trigger Event:
push
-
Statement type: