dhcpdoctor
Tool for testing IPv4 and IPv6 DHCP services
Description
dhcpdoctor sends DHCP requests and checks if it gets an offer from DHCP server.
It supports BOOTP+DHCP for IPv4 (-4) and DHCPv6 for IPv6 (-6).
It can operate as a DHCP client by sending requests on the local network via
broadcast/multicast or as a DHCP client and relay in one tool by unicasting
requests to the specified IP address (-s). When relaying requests you can
specify the relay address to send from (-f). By default the IP address of
the interface request is sent from is used. When specifying custom relay from
address, keep in mind that the DHCP server will send the response back to the
address you specify here, so it must be an address on the machine you are
running tests from.
You can specify a custom client MAC or DUID (-c). By default the MAC address
of the interface to send request from is used.
You can specify the interface to send requests from with -i.
Program output and exit codes are Nagios/Icinga compatible. Response time from DHCP server is measured and returned as performance data.
Requirements
dhcpdoctor needs needs Python 3.4 or later to run.
Since it uses scapy under the hood to craft, dissect, send and receive packets, it needs root permissions to run.
Installing
Via pip:
pip install dhcpdoctor
Icinga2 check command
You can use dhcpdoctor as a check command from Icinga2 or Nagios.
There is dhcpdoctor.conf config with a CheckCommand definition for Icinga2 you can use. A service that uses this check command might look like this:
apply Service "dhcpd6" {
import "generic-service"
check_command = "dhcpdoctor"
vars.dhcpdoctor_ipv6 = true
vars.dhcpdoctor_client_id = "00:11:11:11:11:11"
assign where host.dhcpd6
}
If you are building an RPM from provided SPEC file, the
CheckCommand config will be installed to
/etc/icinga2/conf.d/check_commands/dhcpdoctor.conf.
Developing
We use poetry to manage Python dependencies and virtual environments.
To setup development virtual environment:
poetry install
Run the tool:
poetry run dhcpdoctor -h
Vagrant can be used to quickly spin-up VMs with DHCP servers to test against:
vagrant up
vagrant ssh dhcpdoctor
cd /vagrant
poetry run dhcpdoctor -h
exit
vagrant destroy
See comments in Vagrantfile for more information.
Releases
poetry run bumpversion patch
Instead of patch you can give minor or major.
This creates a commit and tag. Make sure to push it with git push --tags.
The dev-version.sh script will bump the version for development or release as
needed (based on whether we are on a git tag or not) and is called in CI jobs.
Building
Here is how to build dhcpdoctor using pyinstaller into a single binary file
and then package that into a RPM for Red-Hat based systems. The resulting
binary is setuid root, because dhcpdoctor needs to work on privileged UDP
ports, but is usually run as a special user when invoked from Nagios or Icinga.
pip3 install --upgrade bumpversion poetry pyinstaller
poetry install --no-dev
poetry run pip freeze | grep -v egg=dhcpdoctor > requirements.txt
pip3 install -r requirements.txt
./dev-version.sh
./build.sh
Metadata
Release files for dhcpdoctor 1.0.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| dhcpdoctor-1.0.0.tar.gz | 7.8 kB | Without provenance | Details for dhcpdoctor-1.0.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| dhcpdoctor-1.0.0-py3-none-any.whl | Python 3 | none | any | Details for dhcpdoctor-1.0.0-py3-none-any.whl |
Total release size: 26.1 kB
Release files / dhcpdoctor-1.0.0.tar.gz
| Download URL | dhcpdoctor-1.0.0.tar.gz |
|---|---|
| Size | 7.8 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
de69549b2a50d0d4fa961877b03a87178a018689edc26b62fd20ac220ba0fe45
|
|
BLAKE2b-256 checksum How to use checksums |
a681e2fb5d04373257f9fe34f5e1c5fd324d6dc8fa3bcc84005ff2ebbb1c4e91
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.6.8 Linux/4.13.0-46-generic
|
Release files / dhcpdoctor-1.0.0-py3-none-any.whl
| Download URL | dhcpdoctor-1.0.0-py3-none-any.whl |
|---|---|
| Size | 18.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
46109863f5ca8e05d5a201554d35eae91ce5685ee1ab0a4ee9bb1b03cd791577
|
|
BLAKE2b-256 checksum How to use checksums |
7b127b584846562feb4ea7e3047c527407a68d248d65ab7113b6e63bded52802
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/0.12.11 CPython/3.6.8 Linux/4.13.0-46-generic
|
Security for dhcpdoctor 1.0.0
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.