DHC assigns an IP address to interfaces (computers, or other network endpoints). Using IPv4 each address is a 32-bit number (4 bytes). The address is allocated so that no two systems have the same IP address. Some systems have more than one IP address, in which case they may be reached by any of their IP addresses.
The Dynamic Host Configuration Protocol (DHCP) can be used with both IPv4 and IPv6. With dynamic addressing using DHC, a device can have a different IP address every time it connects to the network (dynamic use), or can be allowed to continue with the same address (static use). In some use cases, the device's IP address can even change while it is still connected.
DHCP Interaction (origin of figure unknown)
When a computer or other networked device connects to an IPv4 network, the DHCP client software in the operating system sends a broadcast query requesting necessary information. An IPv4 client broadcasts messages on the network subnet using the IPv4 destination address 255.255.255.255 or the specific subnet broadcast address.
---> Client sends: DHCP-DISCOVER (broadcast in IPv4)
<--- Server sends: DHCP-OFFER (usually unicast, may be broadcast)
---> Client sends: DHCP-REQUEST (broadcast in IPv4)
<--- Server sends: DHCP-ACK (unicast)
Each DHCP server on the network may respond to the request. (There could be more than one server). The DHCP server manages a pool of IP addresses and information about client configuration parameters such as default gateway, domain name, the name servers, and time servers.
When a DHCP server receives a DHCP-DISCOVER message from a client, which is an IP address lease request, the server reserves an IP address for the client in its local database and then makes a lease offer by sending a DHCP-OFFER message to the client. This message contains the client's MAC address, the IP address that the server is offering, the subnet mask, the lease duration, and the IP address of the server making the offer.
The client then sends a DHCP-REQUEST (broadcast) asking to use the offered address.
When a server receives the DHCP-REQUEST, it may respond with specific information for each client (DHCP-ACK), as previously configured by an administrator, or with a specific address and any other information valid for the entire network, and the time period for which the allocation (lease) is valid. When other DHCP servers see a request message, they withdraw any offers that they might have made to a client (assuming that the request will be granted by the server it was sent to).
The client ACKs the completed request.
A host typically queries for the DHC information immediately after booting. A DHCP cache is used at the client to record the binding until the lease expires. This avoids needing to quert again, while the lease remains valid
Once a lease has been made, the address is used by the client as the source IP address of all packets sent to the network, it also uses the addressing information to set the local broadcast address, netmask and to configure the local router (gateway). It may also use this information to set the IP address of the DNS Server.
Before the lease expires, the client will periodically ask for the assignment to be refreshed. To do this, it sends a DHCP-Request for the same parameter values that were previously offered. The server could confirm the infromation DHCP-ACK. This could continue use of the same address, but the servcer could instead choose to assign a new address, based on the assignment policies set by administrators.
IP packet header
RFC1541 DHCP for IPv4
RFC3315 DHCP for IPv6