VMware ESXi and vSphere Cluster Management
What Is DHCP? Dynamic Host Configuration Protocol Explained
Learn what DHCP is, how clients receive IP settings, how the DORA lease process works, and when to use DHCP, static addresses, or reservations.
DHCP stands for Dynamic Host Configuration Protocol. It is a client-server protocol that automatically provides hosts with the network settings they need to communicate. Instead of configuring every laptop, phone, printer, or server by hand, an administrator can manage address allocation and network options centrally.
DHCP commonly supplies an IP address, subnet mask or prefix length, default gateway, DNS server addresses, a DNS search domain, and a lease duration. The result is faster deployment, fewer typing mistakes, and simpler changes when a network's addressing or DNS design changes.
DHCP Definition and Purpose
An IP address is a network-layer address assigned to a device interface. A host also needs to know which addresses are local, where to send traffic for other networks, and which DNS services to use. DHCP automatically delivers these settings when a device joins or starts on a network.
DHCP uses a client-server model:
- A DHCP client is a host or network interface requesting configuration. A laptop's Wi-Fi interface and a Linux workstation's Ethernet interface can each act as clients.
- A DHCP server is a service that manages available addresses and sends configuration options to clients.
Without DHCP, each host could require manual, static configuration. An administrator would enter an address, subnet mask, gateway, and DNS information on every device. Static configuration can be appropriate for selected systems, but it becomes difficult to maintain across a large or frequently changing network.
With DHCP, address pools and network options are managed in one or more server scopes. A change to the gateway or DNS servers can then be applied centrally rather than edited on every endpoint. Linux systems can operate as DHCP clients, as DHCP servers, or both on different interfaces.
DHCP Address Pools, Scopes, and Leases
An address pool is the range of IP addresses available for dynamic allocation. A DHCP scope defines the subnet, allocatable range, exclusions, lease policies, and options for that network.
For example, a scope for 192.168.10.0/24 might dynamically allocate 192.168.10.100 through 192.168.10.200. Addresses such as 192.168.10.1 for the router and selected addresses for infrastructure would remain outside the dynamic range.
A DHCP lease is a time-limited assignment of an IP address and related settings to a client. The lease has a duration and eventually expires. Before expiration, the client normally attempts lease renewal, which extends the assignment if the server still permits it.
- Lease-based allocation allows an address to be reused after a device disconnects or its lease expires.
- Temporary devices do not permanently consume addresses.
- The server can track which client currently holds each address.
- Lease duration can be adjusted for the network: shorter leases suit highly transient networks, while longer leases reduce renewal traffic for stable networks.
A DHCP reservation associates a recognized client identity, commonly its MAC address, with a predictable IP address. The client still receives its configuration from DHCP, but it normally receives the same address each time. Reservations are useful for printers, appliances, and other devices that need consistent addressing without duplicating settings manually on the device and server.
Settings Commonly Delivered by DHCP
DHCP can deliver much more than an IP address. Common settings include:
| Setting | What it controls | Example value |
|---|---|---|
| IPv4 address | The address assigned to the client interface | 192.168.10.125 |
| Subnet mask or prefix | Identifies the network and host portions of the address | 255.255.255.0 or /24 |
| Default gateway | The router used to reach destinations outside the local subnet | 192.168.10.1 |
| DNS servers | Resolvers that translate domain names into IP addresses and other DNS data | 192.168.10.53 |
| Domain/search suffix | Helps clients resolve local or organizational hostnames | example.internal |
| Lease duration | How long the assignment remains valid before renewal or expiration | 3600 seconds |
Networks can also use additional DHCP options for requirements such as boot services, time services, or specialized devices. The available options depend on the DHCP implementation and the network design.
The DHCP DORA Exchange
The usual initial exchange is known as DORA: Discover, Offer, Request, Acknowledgement. The client may not yet have an address or know the DHCP server's address, so its first message is normally broadcast on the local LAN.
| Step | Message | Sender | Typical delivery | Purpose |
|---|---|---|---|---|
| 1 | DHCP Discover | Client | Broadcast on the local broadcast domain | Looks for available DHCP servers and requests configuration |
| 2 | DHCP Offer | Server | Broadcast or directed to the client, depending on the exchange | Proposes an address, lease duration, and network options |
| 3 | DHCP Request | Client | Usually broadcast so servers can see which offer was selected | Selects one offer and requests that configuration |
| 4 | DHCPACK | Selected server | Broadcast or directed to the client, depending on the exchange | Confirms and activates the lease |
Step 1: Discover
When a client starts or connects, it sends a DHCP Discover. A broadcast is used because the client may have no usable IPv4 address and may not know the server's location.
Step 2: Offer
One or more DHCP servers can respond with a DHCP Offer. Each offer can contain a proposed address, subnet information, gateway, DNS servers, and lease duration. If multiple servers respond, the client chooses one offer according to its DHCP behavior.
Step 3: Request
The client sends a DHCP Request identifying the configuration it selected. This also lets other responding servers know that their offers were not chosen.
Step 4: Acknowledgement
The selected server sends a DHCP Acknowledgement, commonly called DHCPACK. The client can then configure the interface and use the lease.
A server can instead send a DHCPNAK, or Negative Acknowledgement, when the requested address or lease is invalid for the client's network or otherwise cannot be honored. The client may need to discard the invalid configuration and restart the DHCP process.
DHCP Across Network Boundaries
A broadcast is delivered to all hosts in a local broadcast domain. Routers ordinarily do not forward broadcasts between subnets. Therefore, a client and DHCP server on different IP subnets cannot usually complete the initial exchange without assistance.
A DHCP relay agent, also called IP helper functionality on some routers and Layer 3 switches, solves this problem. The relay receives the client's local broadcast, forwards the request toward the DHCP server, and relays the server's response back to the client. A central DHCP server can therefore serve several VLANs or subnets, with a separate scope for each network.
For example, clients in a staff VLAN might use a scope containing staff addresses and DNS settings, while clients in a guest VLAN use a different scope and gateway. The relay helps the server identify which client subnet made the request.
DHCP Compared with Static Addresses and Reservations
| Method | Address consistency | Management location | Best-fit use cases | Main caution |
|---|---|---|---|---|
| DHCP allocation | May change when leases change | DHCP server | Laptops, phones, workstations, and ordinary client endpoints | Do not depend on the address remaining constant |
| Static configuration | Intended to remain fixed | Configured directly on the device | Some infrastructure devices or systems that must operate independently of DHCP | Manual errors and duplicate addresses are possible |
| DHCP reservation | Predictable while the client identity remains recognized | DHCP server, usually using a MAC address | Printers, appliances, and servers managed through DHCP | Verify the correct interface identity, especially with randomized MAC addresses |
Client endpoints are usually good candidates for ordinary DHCP. Infrastructure devices and servers may use static configuration or reservations depending on operational requirements. If a device is manually configured with an address inside an unmanaged DHCP pool, the server might later allocate that same address to another client. The resulting duplicate IP address can cause intermittent or complete connectivity problems.
DHCP on Linux
A Linux host can obtain interface configuration through a DHCP client. The actual manager depends on the distribution and installation: common choices include NetworkManager, systemd-networkd, and standalone DHCP client programs such as dhclient.
After a lease is acquired, inspect the address and routing state with:
ip addr show
ip route
Where installed and appropriate for the system, a common DHCP client can request a lease verbosely or release an existing lease:
sudo dhclient -v eth0
sudo dhclient -r eth0
Interface names vary. A system may use names such as ens3, enp1s0, or wlan0 rather than eth0. Also, do not manually run a second DHCP client on an interface already managed by NetworkManager or systemd-networkd unless you understand the effect.
For NetworkManager, these commands show device and connection information:
nmcli device status
nmcli device show eth0
Illustrative Linux DHCP Server Scope
The following resembles a scope fragment used by a common Linux DHCP server implementation. It illustrates the essential settings; it is not a complete production configuration.
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.200;
option routers 192.168.10.1;
option domain-name-servers 192.168.10.53, 1.1.1.1;
default-lease-time 3600;
max-lease-time 7200;
}
The package name, configuration path, and service-management commands differ across Linux distributions. The subnet, range, gateway, and DNS values must match the real network design. Infrastructure addresses should be excluded from dynamic allocation, and the server should be authorized to serve the intended interface and subnet.
Practical DHCP Examples
A laptop joins office Wi-Fi
The laptop starts without a usable local IPv4 configuration and broadcasts a Discover message. The DHCP server offers an address, subnet information, gateway, DNS servers, and a lease duration. After the laptop sends Request and receives DHCPACK, it can communicate locally and use the supplied gateway to reach other networks.
Two servers answer
More than one DHCP server can send an Offer. The client selects one and signals that choice with a Request. The selected server finalizes the lease; the unselected offer is not used.
A printer needs a stable address
An administrator can create a reservation tied to the printer's MAC address. The printer continues to receive centrally managed gateway and DNS options, while its address remains predictable. This avoids configuring one address manually on the printer and separately tracking it on the server.
One central server serves several VLANs
Client broadcasts do not normally cross a router. A router or Layer 3 switch uses DHCP relay functionality to forward requests to the central server. Separate scopes provide the correct address range and options for each VLAN.
Operational and Security Considerations
Only trusted DHCP servers should be allowed on a network. A rogue DHCP server is an unauthorized service that can give clients incorrect or malicious settings. For example, it might provide an unsafe default gateway, an unwanted DNS server, or an address that conflicts with the intended network.
DHCP snooping is a managed-switch protection concept that distinguishes trusted ports, where legitimate DHCP responses are expected, from untrusted ports. It can help block unauthorized DHCP server responses. Exact configuration depends on the switch vendor and topology.
Administrators should also size pools realistically, leave enough addresses for expected clients, and exclude infrastructure addresses from dynamic allocation. Lease records, reservations, relay paths, and scope options should be reviewed when devices move between VLANs or when addressing changes.
DHCP Troubleshooting
No address, or an IPv4 link-local address
- Verify physical or Wi-Fi connectivity and the client's VLAN assignment.
- Check the interface and routes with
ip addrandip route. - Check DHCP server availability, scope capacity, and lease records.
- Confirm that a relay is configured when the server is on another subnet.
- Investigate firewall or switch policies that may block DHCP traffic.
An address is assigned, but the internet is unreachable
- Compare the assigned address and prefix with the intended scope.
- Verify that the DHCP-provided default gateway is correct and reachable.
- Test the local gateway before testing an external destination.
- If the gateway works, investigate routing beyond the local network.
Names do not resolve, but IP connectivity works
- Inspect the DNS server information delivered by DHCP.
- Test a lookup against the intended resolver.
- Check whether the DNS server is reachable.
- Review the scope's DNS and search-domain options.
A device receives an unexpected address
- Confirm whether a reservation exists and uses the correct MAC address.
- Check whether the device is using another interface or a randomized MAC address.
- Review the client's lease on the server.
- Release and renew the lease only when doing so is safe for the environment.
Clients receive an unexpected gateway or DNS server
- Identify which DHCP server issued the lease.
- Check for a rogue DHCP server.
- Validate the selected scope and relay target.
- Review switch protections, including DHCP snooping where supported.
Exam-Relevant Summary
- DHCP means Dynamic Host Configuration Protocol.
- A client requests configuration; a server allocates addresses and supplies options.
- A pool or scope defines which addresses can be dynamically assigned.
- A lease is temporary and can be renewed before expiration.
- DORA means Discover, Offer, Request, and Acknowledgement.
- The initial Discover is normally a broadcast within the local broadcast domain.
- DHCP relay is needed when the client and server are on different subnets.
- DHCP can supply the address, subnet mask or prefix, gateway, DNS servers, search domain, lease duration, and additional options.
- A reservation provides a predictable address while keeping management centralized.
- A manually configured address must not overlap with an unmanaged DHCP pool.
- Rogue DHCP servers can provide incorrect gateway or DNS settings; DHCP snooping is one managed-switch protection concept.