DHCP

On this page 8

DHCP (Dynamic Host Configuration Protocol) is the client-server protocol that automatically assigns IP addresses and network settings to devices when they join a network. In networking, it is the standard method of address configuration for IPv4: a DHCP server hands each client an address from a pool together with the subnet mask, default gateway and DNS servers, for a limited period called a lease.

DHCP for IPv4 is defined in RFC 2131, with its options in RFC 2132, and it evolved from the older BOOTP protocol. It runs over UDP, with servers on port 67 and clients on port 68. IPv6 has a separate protocol, DHCPv6, which works alongside stateless autoconfiguration (SLAAC).

How a DHCP lease is obtained

A new client obtains its configuration in a four-message exchange known as DORA: Discover, Offer, Request and Acknowledge. Because the client has no address yet, it sends from 0.0.0.0 to the broadcast address 255.255.255.255, and every DHCP server on the local segment can hear it.

MessageSent byPurpose
DHCPDISCOVERClient, broadcastAsks any server on the segment for a configuration
DHCPOFFERServerProposes an address, lease time and options
DHCPREQUESTClient, broadcastAccepts one offer and implicitly declines the others
DHCPACKServerConfirms the lease and the final parameters
The DORA exchange step by step

Further messages handle exceptions. A server answers DHCPNAK when a requested address is no longer valid, for example after a laptop moves to another subnet. A client sends DHCPDECLINE if it finds through ARP that the offered address is already in use, and DHCPRELEASE when it gives an address back voluntarily.

Lease time, renewal and rebinding

Every address is leased, not owned, which lets the pool recover addresses from devices that leave. The client tries to extend the lease long before it expires, using two timers whose defaults are fixed fractions of the lease time.

TimerDefault fractionTime for a 24-hour leaseClient action
T1, renewal50% of the lease12 hoursUnicast request to the original server
T2, rebinding87.5% of the lease21 hoursBroadcast request to any server
Expiry100% of the lease24 hoursStop using the address and start over
Lease timers for a 24-hour lease

Lease length is a real design choice. Short leases of 1 to 4 hours suit guest networks and venues with high turnover, while leases of several days reduce DHCP traffic on stable office networks. When no server answers at all, many operating systems fall back to a link-local address in 169.254.0.0/16, which works only on the local segment and is a reliable sign of a DHCP failure.

DHCP options that configure the client

Beyond the address itself, DHCP delivers configuration through numbered options, which is why a single protocol can prepare a laptop, an IP phone or a server that boots from the network. The most common options are listed below.

OptionNameWhat it supplies
1Subnet maskSize of the local network
3RouterDefault gateway address
6Domain name serverDNS resolver addresses
15Domain nameDNS suffix of the local domain
42NTP serversTime servers
51Lease timeLength of the lease in seconds
66 and 67TFTP server and boot fileNetwork boot (PXE) parameters
82Relay agent informationSwitch and port that relayed the request
Frequently used DHCPv4 options

A DHCP reservation ties a fixed address to a specific client identifier or MAC address while keeping configuration centralized, which is the preferred approach for printers and servers over manual static settings.

DHCP relay across subnets

Since DHCP discovery relies on broadcasts and routers do not forward broadcasts, a central server cannot hear clients on other subnets by itself. A DHCP relay agent, usually configured on the router or Layer 3 switch that serves as the subnet’s gateway, receives the broadcast and forwards it as unicast to the DHCP server.

The relay writes its own interface address into the giaddr field, and the server uses that address to choose the matching address pool. This design lets one redundant pair of servers serve hundreds of VLANs in a campus or data center.

DHCP compared with other address configuration methods

Address configuration can be manual, stateful or stateless, and IPv6 changes the picture considerably. A key difference is that DHCPv6 does not provide a default gateway; IPv6 clients learn it from router advertisements.

MethodWho chooses the addressGateway sourceBest suited for
Static configurationAdministrator on the deviceManual entrySmall number of infrastructure devices
DHCPv4Server, from a poolDHCP option 3Almost every IPv4 client network
DHCPv6 (stateful)Server, from a poolRouter advertisementsIPv6 networks needing address tracking
SLAACClient, from the advertised prefixRouter advertisementsIPv6 networks without central address records
Methods of assigning IP configuration

Support also varies by platform: Android, for example, does not implement stateful DHCPv6 address assignment, so IPv6 networks usually keep SLAAC enabled even when DHCPv6 is present.

Security risks and common failures

DHCP has no built-in authentication, so clients accept the first plausible offer they receive. That openness creates both operational faults and attack opportunities.

  • Rogue DHCP servers: a consumer router plugged in backward hands out wrong gateways; DHCP snooping on switches blocks offers from untrusted ports.
  • Pool exhaustion: too few addresses or overly long leases leave new devices without an address.
  • Starvation attacks: forged requests with random MAC addresses drain the pool; port security and rate limits mitigate them.
  • Missing relay configuration: clients on a new VLAN fall back to 169.254.x.x addresses.

A plain-language summary

DHCP works like the front desk of a hotel. When a guest arrives, the desk assigns a free room, hands over a key card and explains where breakfast and the exits are. The guest does not need to know anything in advance.

In the same way, a phone or laptop joining a network asks the DHCP server for an address and gets everything it needs to reach the Internet. The room is booked only for a while and must be extended to keep it. The key point is that DHCP lets devices connect without any manual setup.

An example from practice

A conference center runs a three-day event with about 2,400 different devices each day on its guest Wi-Fi. The guest network uses a /22 subnet, which leaves 1,021 assignable addresses after the gateway, and a 24-hour lease. By midmorning of the first day the pool is exhausted, because every device that connected even briefly still holds its address.

The network team moves the guest network to a /21 subnet with 2,045 assignable addresses and shortens the lease to 1 hour, so clients renew after 30 minutes and departed devices release their addresses within the hour. Peak usage of about 1,500 concurrent devices now fits comfortably in the pool, and DHCP snooping on the access switches keeps a misconfigured exhibitor router from handing out its own addresses.