EMZETT.
Login

DHCP

In short: Dynamic Host Configuration Protocol — automatically assigns IP addresses and network settings to devices that newly join a network.

In more detail: Without DHCP, every device would have to be manually given an IP address, subnet mask, the default gateway and the DNS server. A DHCP server instead manages an address pool and assigns (usually time-limited) addresses automatically following a discover-offer-request-acknowledge sequence.

In Depth

The DORA sequence

The complete sequence is known as “DORA”, after the four messages involved:

1. Discover  - client (via broadcast): "Is there a DHCP server here? I need an IP."
2. Offer     - server (via broadcast): "I offer you 192.168.1.50 for 24h."
3. Request   - client (via broadcast): "I'll take 192.168.1.50, please confirm."
4. Ack       - server (via broadcast): "Confirmed, the IP is yours now."

All four steps run as broadcasts, because at the beginning the client doesn’t have an IP address yet and therefore can’t address anyone specifically (via unicast) — it doesn’t even know the DHCP server’s own address. The intermediate request step (instead of silently accepting the offer straight away) exists because in larger networks several DHCP servers can answer at the same time — the client selects one of the offers received and tells ALL servers via broadcast which one it chose, so that the others can release their reserved addresses immediately instead of blocking them unnecessarily.

Lease times and renewal

Assigned addresses aren’t permanent, but time-limited via a “lease” (often 24 hours, in smaller home networks sometimes much longer). Before the lease expires, the client automatically tries to extend the same address directly with the original server via renewal (T1 timer, usually at 50% of the lease time), instead of starting a completely new DORA sequence — this then runs as a pure unicast request without another broadcast, because by now the client knows its DHCP server. If that fails, there’s a second rebinding attempt (T2 timer, usually at 87.5% of the lease time) as a broadcast to ANY available DHCP server. If the lease expires completely without the client having been able to extend it, it has to start DORA all over again.

Additional configuration transferred

Besides the IP address, DHCP usually also delivers the subnet mask, default gateway and DNS server in the same message, so that a new device is fully network-capable immediately without any manual configuration. So-called DHCP options can additionally transfer any further parameters — e.g. the host name of a server for network boot environments (PXE boot), NTP servers for time synchronisation, or vendor-specific settings for VoIP phones that are supposed to register automatically with a phone system.

DHCP reservations and security

For devices that should always keep the same address (e.g. printers or servers whose IP is stored in a fixed way elsewhere), static reservations based on the MAC address can be set up on the DHCP server — the client then still goes through the normal DORA sequence, but is guaranteed to be assigned the same address every time. A well-known security risk is unauthorised “rogue DHCP servers” — if a second DHCP server accidentally or maliciously joins the network (e.g. a misconfigured private router), it can supply clients with wrong network settings, such as a manipulated DNS server for phishing purposes. Managed switches often offer “DHCP snooping” as a protective measure against this, which only allows replies from explicitly trusted ports.

See also: IP addresses, Subnet, MAC addresses, Broadcast