The Dynamic Host Configuration Protocol (DHCP) automatically assigns IP addresses and other network configuration parameters (subnet mask, default gateway, DNS server) to devices when they connect to a network. Without DHCP, every device on a network would need to be manually configured—an impossibility in networks with thousands of devices.
DHCP uses a 4-step handshake (DORA):
When a device connects to a network, it has no IP address. It broadcasts a DHCP Discover message to the entire local network on UDP port 67, asking "Is there a DHCP server here?"
The DHCP server receives the broadcast and responds with a DHCP Offer, proposing an available IP address along with the lease duration, subnet mask, gateway, and DNS server addresses.
The client broadcasts a DHCP Request, formally requesting the offered IP address. Broadcasting ensures that if multiple DHCP servers responded, the others know their offer was declined.
The DHCP server confirms the assignment with a DHCP ACK. The client now configures its network interface with the assigned parameters.
DHCP does not permanently assign IP addresses. Each assignment has a Lease Duration (e.g., 24 hours). The client must renew the lease before it expires. If the client disconnects without releasing the address, the lease eventually expires and the IP is returned to the pool.
DHCP uses broadcast messages, which do not cross router boundaries. If the DHCP server is on a different subnet, a DHCP Relay Agent (configured on the router) intercepts the broadcast and forwards it as a unicast packet to the DHCP server on the remote subnet.