Dynamic Host Configuration Protocol (DHCP)
Scenario
Imagine moving into a new town where you must manually register your house at City Hall to receive a unique house number before you can receive mail. DHCP automates this: it assigns you a temporary address the moment you step foot in town.
What is the exact sequence of messages exchanged to acquire an IP address?
Mental model
DHCP is a hotel receptionist handing out room keys.
When you connect to a network, you need an IP address to participate. The DHCP server 'leases' you an available IP (room key) for a set period. When you disconnect, the key goes back into the pool for the next guest.
Explanation
Dynamic Host Configuration Protocol (DHCP) is an Application Layer protocol that automatically assigns IP addresses and other network configuration parameters to devices on a network. Without DHCP, a network administrator would have to manually configure the IP address, subnet mask, default gateway, and DNS servers for every single laptop, phone, and smart device that connects.
DHCP operates on a client-server model and uses a four-step transaction famously known as the DORA process: Discover, Offer, Request, and Acknowledge. When a device (the client) joins a network, it has no IP address. It begins by broadcasting a DHCP Discover message to the entire local network, essentially shouting, 'Are there any DHCP servers out there? I need an IP address!'
When a DHCP server receives the Discover broadcast, it reserves an available IP address from its configured pool and responds with a DHCP Offer message. This message contains the proposed IP address, lease duration, and other network settings. If there are multiple DHCP servers on the network, the client might receive multiple offers.
The client usually selects the first offer it receives and broadcasts a DHCP Request message. This message explicitly accepts the offered IP address and implicitly declines any others, letting the other servers return their proposed IPs to their available pools.
Finally, the chosen DHCP server sends a DHCP Acknowledge (ACK) message to the client, confirming the lease of the IP address. The client configures its network interface with the provided details and can now communicate on the network. Because the IP is 'leased' rather than permanently given, the client must periodically renew its lease. If the device leaves the network and the lease expires, the server reclaims the IP address to give to someone else.
Key points
- Discover: Client broadcasts a plea for an IP address.
- Offer: DHCP server offers an available IP address.
- Request: Client requests the specific IP offered.
- Acknowledge: Server confirms the lease and provides configuration details.
Common mistakes
- Thinking DHCP provides static IP addresses: By default, DHCP provides dynamic IP addresses from a pool. These addresses can change. However, a server can be manually configured to reserve a specific static IP for a specific MAC address.
- Assuming the Request step is unicast: The DHCP Request is actually broadcast to the entire network. This is necessary so that if multiple DHCP servers made offers, the unselected servers hear the broadcast and know their offers were rejected.
Glossary
- DHCP
- A network protocol that automatically hands out IP addresses and settings to devices as soon as they connect to a network, saving you from typing them in manually.
- subnet mask
- A specific network setting that helps a computer figure out which other devices are on its local network versus which ones are far away on the internet.
- Application Layer protocol
- A high-level set of rules that defines how specific software applications (like web browsers or email clients) talk to each other over the network.
Recall questions
- What does the acronym DORA stand for in the context of DHCP?
- What happens when a DHCP lease expires?
- Why does a client use a broadcast message for the DHCP Discover step?
Questions & answers
During the DHCP process, which step involves the client accepting a specific IP address and rejecting others?
DHCP Request
Approach: The Request step is where the client formally requests the specific IP that was proposed in the Offer step. Because it is broadcast, other servers see the Request and realize their own offers were rejected.
Which protocol eliminates the need for manual IP configuration by a network administrator?
DHCP
Approach: DHCP (Dynamic Host Configuration Protocol) automatically assigns IP addresses, subnet masks, default gateways, and DNS servers.