On any network, as with the Internet, every device needs an address in order to send or receive communication. DHCP is a system that makes this process easier.
DHCP stands for Dynamic Host Configuration Protocol. When configured, it automatically assigns, for a limited time, an address to any (or any approved) network device that asks for one. DHCP commonly operates from the Gateway Router in consumer-grade equipment, but in this post we’ll treat the DHCP server as an abstract service instead of a specific device.
How does DHCP work?
DHCP operates in four stages between the DHCP Server and the DHCP Client. The first stage happens when a client device (when configured to use DHCP) is connected to the network be it a wired interface, or a wireless one.
First, the client broadcasts a DHCPDiscover message. Broadcast, in the context of networks, means that it sends this special message to every device on the network. This special message contains special hardware-identifying information so that the server will know who to respond to – since, of course, the client does not yet have an IP address to reply to.
All available DHCP servers will respond to this message with a DHCPOffer. This message will include an assigned address, the address “lease” time, and some other relevant information. The first DHCPOffer to be received by the client “wins”.
The client then replies to all DHCP servers with a DHCPRequest message, which notifies them which server “won” and formally accepts the offer. This allows the other DHCP servers to return their offers to the pool of available addresses to await the next request.
The final message comes from the winning DHCP server, in one of the following two forms:
- DHCPAck, which acknowledges the address and may sometimes include more network configuration information to finalize the process
- DHCPNAck, (DHCP Not Acknowledged) which indicates that the address offered is no longer available or the client computer has moved
The “lease” time is the period of time before the address needs to be renewed. At the end of the lease, if the computer is no longer connected to the network, like for example if you had a temporary houseguest connect to your network, the address lease simply expires and goes back into the pool of addresses ready to be reassigned. In places with high-client-turnover such as a convention centre, a hotel, or a cafĂ©, the lease time may be shortened to as little as a few minutes to ensure addresses are recycled efficiently and/or a larger pool of addresses may be configured – the common consumer-grade wireless router will usually come preconfigured with a pool of 254 addresses.
What would life be like without DHCP?
If the DHCP server were to fail, or otherwise be unavailable, computers are designed to fall back to a self-addressing protocol, called APIPA or Automatic Private IP Addressing. APIPA self-configures a computer with an address somewhere between 169.254.0.1 and 169.254.255.254. If those numbers seem odd or arbitrary, they’re just a range of 65534 addresses (a number reached thanks to some binary math voodoo), and have been reserved specifically for the purposes of APIPA.
What this means is if you were to connect two computers to a switch but no DHCP server, they could still technically communicate with one another, but with some limitations. You could never rely on a network printer or server when using APIPA because it would be prone to change (since nothing is there to manage the assignment). DHCP provides additional information like the Internet Gateway address, which tells clients through what device one can access the internet – without it, you would have to configure the gateway manually, and that would assume you know precisely what that address was. When you connect a wireless network, DHCP configures your computer for that network automatically and without any further intervention.
Without DHCP, you would have to manually configure each address on each device on each network you connect to. Even if you’re familiar with the concepts and process, this would be prohibitive in enterprise environments when there are possibly hundreds, or even hundreds of thousands of network devices. DHCP allows us to “plug and play”, or in the case of wireless, connect without any further configuration.
Leave a Reply