Skip to content

Instantly share code, notes, and snippets.

@joaoportela
Last active October 25, 2025 11:32
Show Gist options
  • Select an option

  • Save joaoportela/e302483ee1fc7420526a22f37c4a61c0 to your computer and use it in GitHub Desktop.

Select an option

Save joaoportela/e302483ee1fc7420526a22f37c4a61c0 to your computer and use it in GitHub Desktop.

Broadcast DHCP Request

Broadcast a DHCP request (using NMAP). Usefull to check if:

  • You have multiple DHCP servers in your network.
  • DHCP servers are responding with expected values (DNS servers, IP range, etc).

Uses a fixed MAC address, which means it does not exaust the IP pool.

Uses NMap script broadcast-dhcp-discover:

Sends a DHCP request to the broadcast address (255.255.255.255) and reports the results. By default, the script uses a static MAC address (DE:AD:CO:DE:CA:FE) in order to prevent IP pool exhaustion. The script reads the response using pcap by opening a listening pcap socket on all available ethernet interfaces that are reported up. If no response has been received before the timeout has been reached (default 10 seconds) the script will abort execution. The script needs to be run as a privileged user, typically root.

Alternatives

For debugging a specific DHCP server, consider using

#! /bin/bash
DEVICE="${$1:-default}"
sudo nmap --script broadcast-dhcp-discover -e "${DEVICE}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment