pufferfish Asked: 2010-08-19 00:45:07 +0800 CST2010-08-19 00:45:07 +0800 CST 2010-08-19 00:45:07 +0800 CST Command line program to test DHCP service 772 Is there a simple ping-like command to test whether a DHCP service is running on a network? ...on Linux linux ubuntu dhcp 9 Answers Voted mivk 2017-09-28T07:46:55+08:002017-09-28T07:46:55+08:00 Based on this answer, assuming you have installed nmap (sudo apt install nmap): sudo nmap --script broadcast-dhcp-discover Add the -e $interface option if you have more than one network interface. (For example: nmap --script broadcast-dhcp-discover -e eth0) Sample output: Starting Nmap 7.01 ( https://nmap.org ) at 2017-09-27 17:40 CEST Pre-scan script results: | broadcast-dhcp-discover: | Response 1 of 1: | IP Offered: 192.168.81.94 | DHCP Message Type: DHCPOFFER | Server Identifier: 192.168.81.2 | IP Address Lease Time: 5m00s | Subnet Mask: 255.255.255.0 | Router: 192.168.81.2 | Domain Name Server: 192.168.81.2 | Domain Name: example.lan | NTP Servers: 192.168.81.10, 192.168.81.2 | NetBIOS Name Server: 192.168.81.10 |_ NetBIOS Node Type: 8 WARNING: No targets were specified, so 0 hosts scanned. Nmap done: 0 IP addresses (0 hosts up) scanned in 0.66 seconds Or this output on a different network, with nmap v. 6 : Starting Nmap 6.00 ( http://nmap.org ) at 2017-09-27 17:42 CEST Pre-scan script results: | broadcast-dhcp-discover: | IP Offered: 192.168.4.101 | DHCP Message Type: DHCPOFFER | Server Identifier: 192.168.4.1 | IP Address Lease Time: 7 days, 0:00:00 | Subnet Mask: 255.255.255.0 | Time Offset: 7200 | Router: 192.168.4.1 | Domain Name Server: 208.91.112.53, 208.91.112.52 | Renewal Time Value: 3 days, 12:00:00 |_ Rebinding Time Value: 6 days, 3:00:00 WARNING: No targets were specified, so 0 hosts scanned. Nmap done: 0 IP addresses (0 hosts up) scanned in 1.15 seconds Best Answer sandoz 2011-09-21T05:16:52+08:002011-09-21T05:16:52+08:00 Even if you don't use a Nagios monitoring server, you can grep the check_dhcp binary or compile it from source and use the check to test a DHCP-Server. E.g. ./check_dhcp -v -s <dhcp_server_address> -r <expected_ip_address> -m <mac_address_touse> Paul M 2013-04-13T06:15:57+08:002013-04-13T06:15:57+08:00 or you can try dhcpcd in test mode: dhcpcd -T eth0 Craig McQueen 2015-11-27T17:01:14+08:002015-11-27T17:01:14+08:00 dhcpdump is good for sniffing and displaying DHCP packets on the network. E.g. # dhcpdump -i eth0 --------------------------------------------------------------------------- TIME: 2015-11-27 11:41:37.379 IP: 0.0.0.0 (0:11:b9:5:0:b8) > 255.255.255.255 (ff:ff:ff:ff:ff:ff) OP: 1 (BOOTPREQUEST) HTYPE: 1 (Ethernet) HLEN: 6 HOPS: 0 XID: abce9327 SECS: 0 FLAGS: 0 CIADDR: 0.0.0.0 YIADDR: 0.0.0.0 SIADDR: 0.0.0.0 GIADDR: 0.0.0.0 CHADDR: 00:11:b9:05:00:b8:00:00:00:00:00:00:00:00:00:00 SNAME: . FNAME: . OPTION: 53 ( 1) DHCP message type 1 (DHCPDISCOVER) OPTION: 57 ( 2) Maximum DHCP message size 576 OPTION: 55 ( 4) Parameter Request List 1 (Subnet mask) 3 (Routers) 28 (Broadcast address) 6 (DNS server) --------------------------------------------------------------------------- You can use it in conjunction with another tool to do DHCP requests, or just use it to watch PCs/devices query DHCP. Sirex 2010-08-19T01:21:18+08:002010-08-19T01:21:18+08:00 Why not just make a DHCP request? dhclient For verbose output use: dhclient -v Vladimir Panteleev 2015-06-16T18:13:11+08:002015-06-16T18:13:11+08:00 I wrote a DHCP test client program a while ago, works on Windows and POSIX: https://github.com/CyberShadow/dhcptest topdog 2010-08-19T01:09:10+08:002010-08-19T01:09:10+08:00 There is a program called dhcping (with just one p) natxo asenjo 2010-08-22T05:11:42+08:002010-08-22T05:11:42+08:00 if you use nagios you could monitor it with check_dhcp John P. Fisher 2013-01-10T10:38:03+08:002013-01-10T10:38:03+08:00 On Debian-Ubuntu systems: dhcpd -f gives good feedback and tests the configuration. On RH systems try: /etc/rc.d/init.d/dhcpd configtest
Based on this answer, assuming you have installed nmap (
sudo apt install nmap
):Add the
-e $interface
option if you have more than one network interface. (For example:nmap --script broadcast-dhcp-discover -e eth0
)Sample output:
Or this output on a different network, with nmap v. 6 :
Even if you don't use a Nagios monitoring server, you can grep the check_dhcp binary or compile it from source and use the check to test a DHCP-Server. E.g.
or you can try
dhcpcd
in test mode:dhcpdump
is good for sniffing and displaying DHCP packets on the network.E.g.
You can use it in conjunction with another tool to do DHCP requests, or just use it to watch PCs/devices query DHCP.
Why not just make a DHCP request?
For verbose output use:
dhclient -v
I wrote a DHCP test client program a while ago, works on Windows and POSIX:
https://github.com/CyberShadow/dhcptest
There is a program called dhcping (with just one p)
if you use nagios you could monitor it with check_dhcp
On Debian-Ubuntu systems:
gives good feedback and tests the configuration.
On RH systems try: