Skip to main content

PiHoleClient

alt text

This Python module provides a class PiHoleClient that allows you to interact with a Pi-hole server via SSH. It uses the paramiko library to establish the SSH connection.

Features

  • Create DNS records
  • Push DNS records to the Pi-hole server
  • Delete DNS records from the Pi-hole server
  • Read the custom list of DNS records from the Pi-hole server
  • Close the SSH connection

Usage

First, you need to create an instance of PiHoleClient with the SSH details of your Pi-hole server:

from piholesdk import PiHoleClient

pihole_node =  {"ssh_ip_address":"192.168.178.100",
               "ssh_username":"root",
               "ssh_password":"password"}

client = PiHoleClient(**pihole_node)

You can then use the methods provided by the PiHoleClient class to interact with your Pi-hole server.

client.read_custom_list()
{'status': True,
 'message': 'Retrieved A record list.',
 'data': {'netbox.domain.com': '192.168.178.102',
  'guacamole.domain.com': '192.168.178.102',
  'pfsense.domain.com': '192.168.178.1',
  'pihole.domain.com': '192.168.178.100',
  'vault.domain.com': '192.168.178.102',
  'jenkins.domain.com': '192.168.178.102',
  'grafana.domain.com': '192.168.178.102',
  'rabbitmq.domain.com': '192.168.178.102',
  'portainer.domain.com': '192.168.178.102',
  'proxmox03.domain.com': '192.168.178.32',
  'proxmox01.domain.com': '192.168.178.30',
  'proxmox02.domain.com': '192.168.178.31',
  'yangsuite.domain.com': '192.168.178.102',
  'homeassistant.domain.com': '192.168.178.161',
  'prometheus.domain.com': '192.168.178.103',
  'ubuntu.domain.com': '192.168.178.97'}}

Creating a DNS Record

record = PiHoleClient.create_dns_record(hostname="jur", ip_address="6.6.6.9", domain="domain.com")

Pushing a DNS A Record to PiHole Server

client.push_dns_record(record)
Out[8]: {'status': True, 'message': 'A record added successfully.'}

Deleting a DNS Record

client.delete_dns_record(record)
{'status': True, 'message': 'A Record deleted successfully.'}

Dependencies

Only Paramiko library

Note

Please ensure that the user you are connecting with has the necessary permissions to perform the operations on the Pi-hole server.

For more information, visit the PyPI page.

You can also connect with me on LinkedIn.

Metadata

Release files for piholesdk 0.1.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 piholesdk 0.1.3
File Size Uploaded Provenance
piholesdk-0.1.3.tar.gz 3.0 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for piholesdk 0.1.3
File Interpreter ABI Platform
piholesdk-0.1.3-py3-none-any.whl Python 3 none any Details

Total release size: 6.4 kB

Release files / piholesdk-0.1.3.tar.gz

Download URL piholesdk-0.1.3.tar.gz
Size 3.0 kB
Tags Source
SHA-256 checksum
How to use checksums
2ee63169b9edbaf57839d58016fd9ef89adfc45f0955bed07b1a3e1213fd7bbf
BLAKE2b-256 checksum
How to use checksums
d467467f02a5665ad7ef5255449a4c210353aa4e8ea9e59de0b211944230ef0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Release files / piholesdk-0.1.3-py3-none-any.whl

Download URL piholesdk-0.1.3-py3-none-any.whl
Size 3.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b616a66b4f015480d0198ebbfd10090cc20902cf5d48a0301728c257f9f8b862
BLAKE2b-256 checksum
How to use checksums
40dd59823b36ef78358de25025aef26db83386b1afc1a20e09bd65a295e495cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.12.2

Security for piholesdk 0.1.3

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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

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