Skip to main content

Python console for unbound

Project description

Build Testing Pypi

Python console for unbound server

Table of contents

Installation

python 3.12.x python 3.11.x python 3.10.x python 3.9.x python 3.8.x

This module can be installed from pypi website.

This command will install the module with yaml support for loading zone data.

pip install unbound_console[yaml]

If loading a zone using yaml is not required use the following command, zone data can instead be loaded through the LocalZone object:

pip install unbound_console

Remote Control on Unbound

unbound 1.20.x unbound 1.19.x unbound 1.18.x unbound 1.17.x unbound 1.16.x unbound 1.15.x unbound 1.14.x unbound 1.13.x unbound 1.12.x

Before to use this utility. You must activate the remote control on your unbound server. See config file example.

Execute command

You can execute commands with the function send_command. See nlnetlabs documentations for the full list of available commands.

  • Import the module in your code
from unbound_console import RemoteControl

An asyncio implementation is available, use RemoteControlAsync instead.

  • Configure the remote control client with tls support. You can also provide a unix socket unix_sock="/var/run/unbound-console.sock".
rc = RemoteControl(host="127.0.0.1", port=8953,
                   server_cert = "/etc/unbound/unbound_server.pem",
                   client_cert= "/etc/unbound/unbound_control.pem",
                   client_key= "/etc/unbound/unbound_control.key")
  • Execute a command and get output
o = rc.send_command(cmd="status")
print(o)

Loading zone from YAML file

YAML zone definition example:

This requires installing unbound_console with yaml support

zone:
  name: home.
  type: static
  records:
    - "router.home. 86400 IN A 192.168.0.1"
    - "192.168.0.1 86400 IN PTR router.test."

Call load_zone with the yaml file to load-it in your unbound server.

o = rc.load_zone(zone_data='<yaml content>')
print(o)

Loading zone from "LocalZone" object

Example loading from a LocalZone object:

from unbound_console import LocalZone

zone = LocalZone(
    name="home",
    type="static",
    records=[
      "router.home. 86400 IN A 192.168.0.1",
      "192.168.0.1 86400 IN PTR router.test.",
    ],
)
o = rc.load_zone(zone_data=zone)
print(o)

Execute bulk command

domains_bulk = []
domains_bulk.append( "www.google.com always_nxdomain")

o = rc.send_command(cmd="local_zones", data_list=domains_bulk)
print(o)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

unbound_console-0.6.4.tar.gz (7.1 kB view details)

Uploaded Source

Built Distribution

unbound_console-0.6.4-py3-none-any.whl (7.8 kB view details)

Uploaded Python 3

File details

Details for the file unbound_console-0.6.4.tar.gz.

File metadata

  • Download URL: unbound_console-0.6.4.tar.gz
  • Upload date:
  • Size: 7.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/5.1.1 CPython/3.12.6

File hashes

Hashes for unbound_console-0.6.4.tar.gz
Algorithm Hash digest
SHA256 39992635a2d5a579f1de72cbc57b86d78f196449040dc336627afb244eaf13d8
MD5 7b59cf1e60e40e5e768bfee743dd3ae0
BLAKE2b-256 5aef07735326409eb96ddedce2369462881ee943f149f5de81ff002a22471cbe

See more details on using hashes here.

File details

Details for the file unbound_console-0.6.4-py3-none-any.whl.

File metadata

File hashes

Hashes for unbound_console-0.6.4-py3-none-any.whl
Algorithm Hash digest
SHA256 f32fe6a74293cfec3b5caa19ebdb2352b9d600e3124fc474b6e29390161ca161
MD5 86fbb65c2af43cf2acb6c330753e8657
BLAKE2b-256 681a38a57e15729df502e2a2da1b66445e2e916b88056e2e0f4c6832ca8552dc

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page