|
…
|
||
|---|---|---|
| .. | ||
| 017-dhcpv4-force-option.t | ||
| dhcpv4_option_probe.py | ||
| README.md | ||
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:
DHCPDISCOVERDHCPOFFERDHCPREQUESTDHCPACK
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
python3scapy- 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 serverDEBUG_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 (DHCPACKreceived and parsed)2: error (DHCPOFFER/DHCPACKmissing,DHCPNAK, or invalid DHCP response)