views:

91

answers:

2

There is a scenario where an application tells a device on a network to get their IP address from the network router's DHCP server. If a DHCP server is not available, the device's behavior becomes erratic. Is there a method to procedurally detect if the network router supports DHCP? Or, is this something the device needs to do when attempting to get its IP address from the DHCP server?

+5  A: 

DHCP client on the device is doing exactly that. Well, almost that.

The DHCP DISCOVERY message is broadcast on the link. Then, if there are any DHCP servers willing to serve this particular MAC address, each one reserves an IP address from its pool, and answers with the OFFER message. The client then picks what server it wants to "bind" to and issues the REQUEST message. The server confirms the granted lease of the IP address with an ACK message.
The client discovers "non-availability" of DHCP servers by simply timing out waiting for offers.

Take a look at the DHCPing project. Might give you some ideas.

Links to the DHCP RFCs:

RFC 2131, Dynamic Host Configuration Protocol
RFC 2132, DHCP Options and BOOTP Vendor Extensions

Nikolai N Fetissov
A: 

I was something along the lines of this Windows DHCP C API.

zooropa
That looks like bunch of hooks into their dynamic DNS implementation.
Nikolai N Fetissov