Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a simple ping-like command to test whether a DHCP service is running on a network? ...on Linux

share|improve this question
up vote 3 down vote accepted

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>
share|improve this answer

why not just make a dhcp request ?

dhclient

share|improve this answer
2  
Probably because that will make your system use the IP assigned by the DHCP server which is not what one wants when e.g. trying to find out if there are rogue DHCP servers in his network. – ThiefMaster Jun 9 '12 at 18:54
3  
-n option helps here? – akostadinov Jan 24 '13 at 22:20
    
Option -n seems to be broken on ISC DHCP Client v4.2.4 on Ubuntu 14 LTS? – Josip Rodin Apr 15 at 14:33

There is a program called dhcpping

share|improve this answer

On Debian-Ubuntu systems:

dhcpd -f

gives good feedback and tests the configuration.

On RH systems try:

/etc/rc.d/init.d/dhcpd configtest
share|improve this answer

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.

share|improve this answer

if you use nagios you could monitor it with check_dhcp

share|improve this answer

or you can try dhcpcd in test mode:

dhcpcd -T eth0

share|improve this answer

I wrote a DHCP test client program a while ago, works on Windows and POSIX:

https://github.com/CyberShadow/dhcptest

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.