Skip to main content

PyPi version GitHub latest commit Tests

powerdns-cli

PowerDNS-CLI is a cli 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 from another machine.

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

To manually install the package from git, checkout the repository and run pip install . in the git repository.

Configuration

powerdns-cli uses keyword-based actions. Flags may only follow after the last action keyword.
To get things going, for example, add a zone:
$ powerdns-cli zone add -a MyApiKey -u http://localhost example.com PRIMARY

All flags may alternatively be provided as environment variables. Each option must be prefixed with POWERDNS_CLI_ and the settings title in upper case. 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 options in ./.powerdns-cli.conf, $HOME/.powerdns-cli.conf or $HOME/.config/powerdns-cli/configuration.toml. The file format is toml, strings will need to be quoted explicitly. This is the required structure and their defaults, the option keys are not case sensitive:

apikey = "mytestkey" # default is None
api-version = 4 # default is None
debug = false
insecure = false
json = false
server-id = "localhost"
timeout = 5
url = "http://example.com" # default is None

Only these settings can be accessed through the configuration file.

Depending on the context, for example editing records, further options may be available. Instead of the flag, the corresponding env variable may be used. All options reside under POWERDNS_CLI_*. To set the TTL through the environment of record add, use export POWERDNS_CLI_TTL=60.

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, the -j-switch provides more verbose output as json:

$ 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."
}

The integration test uses all common cli options to test for api compatibility.

Scripting

  • message and success are guaranteed to be set.
  • message is emitted on stdout. It contains human readable output, except:
  • If an action requests data, as do list and export, it resides in data. Otherwise, data is null.
  • If an action requests data, message == data - so stdout will emit data as well.

Caveats

  1. It is not possible to simply create a RRSet with several entries. Instead, powerdns-cli record add needs to be used repeatedly.
  2. Use record replace to ensure a RRSet has only a single value.
  3. 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. Suported versions are documented here. Therefore, PowerDNS Authoritative Nameserver versions 4.8+ are part of the testing right now.

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.

Release files for powerdns-cli 1.2.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for powerdns-cli 1.2.3
File Size Uploaded
powerdns_cli-1.2.3.tar.gz 70.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for powerdns-cli 1.2.3
File Interpreter ABI Platform
powerdns_cli-1.2.3-py3-none-any.whl Python 3 none any Details

Total release size:155.5 kB

Release files / powerdns_cli-1.2.3.tar.gz

Download URL powerdns_cli-1.2.3.tar.gz
Size 70.4 kB
Tags Source
SHA-256 checksum
How to use checksums
efa959c6463f8d461c955faadb2eb0a31429778797126bd842b4cd5499c00ffb
BLAKE2b-256 checksum
How to use checksums
f956ab69074704c3cb11cdf9f463cb91d95511c5dfce5ece202fdb9000119e3f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

Release files / powerdns_cli-1.2.3-py3-none-any.whl

Download URL powerdns_cli-1.2.3-py3-none-any.whl
Size 85.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
27a7115cace0954f12da4ff56e1c6f903ded42ddc26c74ca58db74a6b703e727
BLAKE2b-256 checksum
How to use checksums
0c5e4e7d17967535d1a069be7fb9fce696d8b9e1894cd455c87b850a4f16ddb2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 3, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2.3 This release

2 release files

1.2.2

2 release files

1.2.1

2 release files

1.2.0

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.0.21

2 release files

0.0.19

2 release files

0.0.18

2 release files

0.0.17

2 release files

0.0.15

2 release files

0.0.14

2 release files

0.0.13

2 release files

0.0.12

2 release files

0.0.11

2 release files

0.0.10

2 release files

0.0.9

2 release files

0.0.8

2 release files

0.0.6

2 release files

0.0.5

2 release files

0.0.4

2 release files

0.0.3

2 release files

0.0.2

2 release files

0.0.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page