While talking about APIPA, i thought it was probably worth a look at DHCP and how it works in relative details. DHCP – or Dynamic Host Configuration Protocol, is the protocol used to assign IP addresses to NIC’s on a private network. Wikipedia defines it as “protocol used by networked devices (clients) to obtain the parameters necessary for operation in an Internet Protocol network”.

DHCP uses a fairly easy to follow procedure;

  • DHCP Discovery – this is where the client broadcasts on the subnet to find available DHCP Servers that can allocate it a Dynamic IP Address. This is done so by creating a UDP Request packet with the broadcast destination of 255.255.255.255.
  • DHCP Offers – When a DHCP Server recieves the IP Discovery Packet sent during DHCP Discovery, it extends an “IP Lease Offer”. This is done by reserving an IP address and offering this IP address to the client using aDHCPOffer message. The DHCPOFFER message contains the MAC Address of the Client, along with the offered IP Address, the relevant subnet mask and the lease duration. Also contained in the packet is the IP Address of the DHCP Server that is sending the DHCPOFFER message. Unlike the DHCPDISCOVERY Packet, the DHCPOFFER packet is unicast (for obvious reasons).
  • DHCP Request – When the Client has successfully recieved and accepted the information, a broadcast is initiated to the DHCP Servers IP Address to tell other DHCP Servers they shouldnt issue any IP information to this client as the client has already obtained an IP Address and the neccessary info. This aids to free up IP Allocations for other clients.
  • DHCP Acknowledgement – The final stage in regards to a DHCP Request to actual application of the IP Address to the NIC.  After the server has recieved the DHCPREQUEST message from the client, it initiates an acknowledgement phase involving sending a DHCPACK packet to the client. The packet, includes various configuration information that the client may have requested along with the lease duration.

 

A very good, VERY low level look at how DHCP works is available at this link http://en.wikipedia.org/wiki/Dhcp#DHCP_acknowledgement . It goes into the HEX That is used within DHCP Packet flag fields.

References:

RFC 2131 – DHCP – http://tools.ietf.org/html/rfc2131 ; Wiki – http://tools.ietf.org/html/rfc2131 ; Learn-Networking – http://learn-networking.com/network-design/dynamic-host-configuration-protocol