Sub topic 1
DHCP: How Devices Get an IP Address Automatically
Prerequisites
This chapter assumes you understand IPv4 addresses, subnet masks, default gateways, DNS, LANs, routers, and broadcast traffic.
What a Host Needs Before It Can Talk
An IPv4 host usually needs four settings:
- An IP address that identifies it on the local network.
- A subnet mask that defines which addresses are local.
- A default gateway for traffic destined for other networks.
- A DNS server for converting names such as
example.cominto IP addresses.
Without these settings, a device may connect physically or wirelessly but still be unable to communicate normally.
Why Static Configuration Does Not Scale
A static configuration is an address entered manually on a device. It can work for a server or network appliance, but it becomes difficult to manage across many clients. An administrator must choose unused addresses, enter several settings, prevent duplicates, and update devices when the network changes.
DHCP, the Dynamic Host Configuration Protocol, automates this work. A DHCP server assigns settings temporarily through a lease, which is a time-limited permission to use an address.
DHCP at a Glance
A DHCP client is the device requesting configuration. A DHCP server owns a pool of available addresses and provides configuration options. The client keeps the lease while it is valid and later renews it.
How a Client Talks Before It Has an Address
At startup, the client may not have a usable source IP address. It sends DHCP messages using UDP, a connectionless transport protocol. The client uses UDP port 68, and the server listens on UDP port 67.
The first message commonly uses source address 0.0.0.0 and destination broadcast address 255.255.255.255. Broadcast delivery lets the client find a DHCP server on its local broadcast domain.
Discover, Offer, Request, Acknowledge
The exchange is often called DORA:
- Discover: The client broadcasts that it needs DHCP configuration.
- Offer: A server proposes an IP address, lease duration, subnet mask, gateway, and other options.
- Request: The client broadcasts which offer it accepts. This also tells other servers that their offers were not selected.
- Acknowledge: The selected server confirms the lease. The client configures its interface and can begin normal communication.
A server can reject the request with DHCPNAK, for example when the client moves to a different subnet.
Exercise
Why does the first DHCP message use broadcast instead of sending directly to a server?
Show answer
The client does not yet know its usable IP configuration or which DHCP server is available, so it broadcasts the request on the local network.