CyberShadow / dhcptest

Cross-platform DHCP test client
https://blog.cy.md/2013/01/10/dhcp-test-client
363 stars 57 forks source link

dhcptest

This is a DHCP test tool. It can send DHCP discover packets, and listen for DHCP replies.

The tool is cross-platform, although you will need to compile it yourself for non-Windows platforms.

The tool is written in the D Programming Language.

Download

You can download a compiled Windows executable from my website, here.

The latest development build for Windows can be downloaded from GitHub Actions.

Building

With DMD (or another D compiler) installed, run:

$ dmd dhcptest.d

Usage

By default, dhcptest starts in interactive mode. It will listen for DHCP replies, and allow sending DHCP discover packets using the "d" command. Type help in interactive mode for more information.

If you do not receive any replies, try using the --bind option (or --iface on Linux) to bind to a specific local interface.

The program can also run in automatic mode if the --query switch is specified on the command line.

An example command line to automatically send a discover packet and explicitly request option 43, wait for a reply, then print just that option:

dhcptest --quiet --query --request 43 --print-only 43

Options can also be specified by name:

dhcptest --quiet --query \
     --request    "Vendor Specific Information" \
     --print-only "Vendor Specific Information"

Query mode will report the first reply recieved. To automatically send a discover packet and wait for all replies before the timeout, use --wait. For additional resilience against dropped packets on busy networks, consider using the --tries and --timeout switches:

dhcptest --quiet --query --wait --tries 5 --timeout 10

You can spoof the Vendor Class Identifier, or send additional DHCP options with the request packet, using the --option switch:

dhcptest --query --option "60=Initech Groupware"

Option 82 (Relay Agent Information) can be specified as follows:

dhcptest --query --option "Relay Agent Information=agentCircuitID=\"foo\", agentRemoteID=\"bar\""

Run dhcptest --help for further details and additional command-line parameters.

For a list and description of DHCP options, see RFC 2132.

License

dhcptest is available under the Boost Software License 1.0.

Changelog

dhcptest v0.9 (2023-03-31)

dhcptest v0.8 (2023-03-24)

dhcptest v0.7 (2017-08-03)

dhcptest v0.6 (2017-08-02)

dhcptest v0.5 (2014-11-26)

dhcptest v0.4 (2014-07-21)

dhcptest v0.3 (2014-04-05)

dhcptest v0.2 (2014-03-25)

dhcptest v0.1 (2013-01-10)