Technical reference · Networking

DHCP protocol

A device cannot use an IPv4 network until it knows its address, its local boundary, where to send remote traffic and usually where to ask DNS questions. DHCP supplies all of that automatically.

8 sectionsUDP 67 / 68DORA explained

What DHCP does

Dynamic Host Configuration Protocol is the network’s automatic receptionist. A new client arrives knowing almost nothing. DHCP lends it an address and gives it the facts needed to communicate.

  • IP address: the client’s temporary identity on this network.
  • Subnet mask or prefix: which destinations are local.
  • Default gateway: the router to use for everywhere else.
  • DNS servers: where to translate names into addresses.
  • Lease time: how long the client may use the address.

DHCP usually uses UDP: clients listen on port 68 and servers on port 67. Its first messages use broadcast because the client has neither a usable address nor knowledge of the server.

DHCP configures; it does not carry your trafficOnce configuration is complete, web pages and other data do not pass through DHCP. The client keeps using the values it was given.

IP addressing and subnets

An IPv4 address is 32 bits, normally written as four decimal numbers such as 192.168.10.42. A subnet prefix divides those bits into a network part shared by the local network and a host part identifying one interface.

For 192.168.10.42/24, the first 24 bits identify network 192.168.10.0; the final 8 identify the host. Addresses in that /24 are local, while an address such as 8.8.8.8 must go through the default gateway.

The first address is normally the network address; the last is the broadcast address. Neither is assigned to an ordinary host. In a /24, that usually leaves .1 through .254 available. Private IPv4 ranges—10.0.0.0/8, 172.16.0.0/12 and 192.168.0.0/16—are used inside networks and commonly share one public address through NAT.

CIDR made simple

Classless Inter-Domain Routing writes the count of network bits after a slash. A longer prefix means a smaller subnet because fewer bits remain for hosts.

Prefix Mask Total addresses Usual usable hosts
/16 255.255.0.0 65,536 65,534
/24 255.255.255.0 256 254
/25 255.255.255.128 128 126
/26 255.255.255.192 64 62
/27 255.255.255.224 32 30
/28 255.255.255.240 16 14
/30 255.255.255.252 4 2
addresses = 2(32 − prefix)

“Usable hosts” subtracts network and broadcast addresses under ordinary subnetting. /31 point-to-point links and /32 single-host routes are deliberate exceptions.

The DORA exchange

DORA is a memory aid for the normal four-message conversation. A transaction ID lets the client recognise replies belonging to its request.

  1. Discover. The client broadcasts: “Are there any DHCP servers, and what can you offer me?” Its source address is 0.0.0.0.
  2. Offer. A server proposes an available IP address, lease time and configuration. More than one server may answer.
  3. Request. The client broadcasts which offer it accepts. Naming the chosen server also tells the others to withdraw theirs.
  4. Acknowledge. The selected server commits the lease and sends the final settings. The client can now configure its interface.

A server can instead send DHCPNAK if the requested address is inappropriate, perhaps because the client moved to a different subnet. A client may send DHCPDECLINE if an address-conflict check finds the proposed address already in use.

Leases, renewal and rebinding

An address is borrowed, not owned. A client remembers the lease and normally asks to renew it halfway through its lifetime. This is timer T1, usually 50% of the lease. The renewal is sent directly to the original server.

If that fails, at T2—usually 87.5%—the client broadcasts a rebinding request that any server may answer. If the lease expires with no reply, the client must stop using the address and begin again.

Moment Client behaviour Why
Lease begins Uses the supplied address The server has reserved it
T1 (~50%) Unicast renew to original server Quietly extend the lease
T2 (~87.5%) Broadcast rebind Find any available server
Expiry Stops using address Avoid colliding with a new owner

Short leases return addresses quickly on busy guest networks but cause more DHCP traffic. Long leases reduce chatter and suit stable office or home networks.

DHCP servers, scopes and relays

A scope (or pool) is the range a server may lease on one subnet, plus its options and lease duration. Administrators can exclude infrastructure addresses and make a reservation that consistently gives one client the same address, usually based on its MAC address or client identifier.

Routers normally stop broadcasts, so a central server would not hear clients on another VLAN. A DHCP relay receives the local broadcast, adds the originating subnet information, and forwards it to the server as unicast. The server uses that information to choose the correct scope, then returns the reply through the relay.

One server can serve many networksThe relay—not a DHCP server on every VLAN—is what makes centralised address management practical.

DHCPv6 is related, not identical

IPv6 hosts can create addresses with SLAAC, use DHCPv6, or combine both. DHCPv6 messages and ports differ, and the IPv6 default gateway is learned from Router Advertisements rather than a DHCPv6 option.

Common DHCP options

Option Meaning Why it matters
1 Subnet mask Defines what is local
3 Router Supplies the default gateway
6 DNS servers Tells the client where to resolve names
15 Domain name Provides a local DNS suffix
42 NTP servers Points clients to time sources
51 Lease time Sets the lifetime in seconds
66 / 67 Boot server / filename Often used for network booting
121 Classless static routes Installs routes beyond the default

Not every client honours every option. Vendor-specific options also exist for phones, access points and other managed equipment.

Security and troubleshooting

Classic DHCP has no built-in proof that a server is legitimate. A rogue DHCP server can give clients a hostile gateway or DNS server. Managed switches can use DHCP snooping to trust replies only from approved ports and to build a binding table.

Symptom Likely explanation Check
Address like 169.254.x.x No IPv4 DHCP reply; host self-assigned a link-local address VLAN, cable/Wi-Fi, relay and server
Address but no internet Gateway, DNS or routing is wrong Lease options; ping gateway; test DNS
“Address already in use” Static address overlaps the pool or stale/conflicting lease ARP table, exclusions and reservations
Some clients fail Pool exhausted Free leases, scope size and lease duration
Wrong subnet settings Rogue server or incorrect relay/scope Server identifier in the lease

Useful evidence includes the client’s current lease, packet captures of Discover/Offer/Request/Acknowledge, the server logs, pool utilisation and relay configuration. “Connected to Wi-Fi” only proves the link layer works; DHCP can still be the missing next step.