prplos/.gitlab/tests/cram/generic/acceleration-plan-components/dhcpv4-force-option
…
..
017-dhcpv4-force-option.t ci: cram: add DHCPv4 Force option cram tests 2026-06-02 17:59:31 +01:00
dhcpv4_option_probe.py
README.md ci: cram: add DHCPv4 Force option cram tests 2026-06-02 17:59:31 +01:00

DHCPv4 Option Probe Client (Python)

This directory contains the Python DHCPv4 probe client:

  • dhcpv4_option_probe.py

What the client checks

The client performs the DHCP exchange:

  • DHCPDISCOVER
  • DHCPOFFER
  • DHCPREQUEST
  • DHCPACK

Option checks are based on:

  • options requested in DHCPREQUEST (param_req_list)
  • options received in the final DHCPACK

The output is extracted from the final DHCPACK only.

Requirements

  • python3
  • scapy
  • root privileges (raw packet send/receive)

Install dependency:

pip install scapy

Usage

sudo -E python3 dhcpv4_option_probe.py --iface <interface> --request-options "1,3,6,15,42"

Default output format:

RECEIVED_TAGS=1,3,6,15,42

Debug mode

Pass --debug to print the full scapy packet dump for each DHCP exchange to stderr:

sudo -E python3 dhcpv4_option_probe.py --iface <interface> --request-options "1,3,6,15,42" --debug

The debug output includes:

  • --- DHCPDISCOVER sent --- — full packet before sending
  • --- DHCPOFFER received --- — full packet from server
  • --- DHCPREQUEST sent --- — full packet before sending
  • --- DHCPACK received --- — full packet from server
  • DEBUG_DHCPREQUEST_PRL=<tags> — the parameter request list sent in DHCPREQUEST (stdout)

Debug output goes to stderr so the RECEIVED_TAGS= line on stdout is unaffected.

Real-environment recommendation (network delay tolerance)

Use a higher timeout when network delays are expected:

sudo -E python3 dhcpv4_option_probe.py --iface <interface> --request-options "1,3,6,15,42" --timeout 12

Exit codes

  • 0: success (DHCPACK received and parsed)
  • 2: error (DHCPOFFER/DHCPACK missing, DHCPNAK, or invalid DHCP response)