DHCP: dhtest a tool to send customized packets to a DHCP Server


dhtest is a tool to generate DHCP packets and send it to a DHCP server.

A (not complete list) what dhtest can do:

  • Query send a DHCP request by using a MAC other then the Interface of the host
  • Send DHCP release packets for specific MAC to the DHCP Server
  • Set various DHCP options

But use it with care! Your Network administrator may not be amused 🙂 . When you alter the MAC, the switch to which you are connected sees both MAC Addresses. In many enterprise environment only one MAC per Switchport is allowed. Also you kickout the Machine with the given MAC.

dhtest has its home at github.

Installation is easy. Here the way on Debian Linux.
Prepare your build environment.

apt-get update && apt-get -y install build-essential git

Clone the repository dhtest git repository

cd ~
git clone https://github.com/saravana815/dhtest



And test it

root@debdev:~/software/dhtest# ./dhtest -?
Usage: ./dhtest [ options ]
  -m mac_address
  -r, --release                         # Releases obtained DHCP IP for corresponding MAC
  -L, --option51-lease_time [ Lease_time ] # Option 51. Requested lease time in secondes
  -I, --option50-ip     [ IP_address ]  # Option 50 IP address on DHCP discover
  -o, --option60-vci    [ VCI_string ]  # Vendor Class Idendifier string
  -h, --option12-hostname [ hostname_string ] # Client hostname string

Example: This command sends a DHCP release for named MAC to DHCP Server

./dhtest -m 08:00:27:8e:a9:a9 --release -S
You can also attach tcpdump to the interface in a second shell to see whats happen on the wire (The release is encapsulated in the Request).

tcpdump -vni eth0 port 67
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 262144 bytes
12:31:01.972831 IP > BOOTP/DHCP, Request from 08:00:27:8e:a9:a9, length 250

12:31:28.472611 IP > BOOTP/DHCP, Request from 08:00:27:8e:a9:a9, length 300

12:31:28.473457 IP > BOOTP/DHCP, Reply, length 548

Note: Some parameter (changing MAC) requieres root permissions because dhtest uses raw sockets.

Advertisment to support michlstechblog.info

One thought on “DHCP: dhtest a tool to send customized packets to a DHCP Server”

Leave a Reply

Your email address will not be published. Required fields are marked *

Time limit is exhausted. Please reload CAPTCHA.