What it means
A device that joins a network needs an IP address, a subnet mask, a gateway and a DNS server. DHCP supplies them in four messages. The device broadcasts DISCOVER. A server replies with OFFER, proposing an address. The device sends REQUEST for that offer. The server commits the lease and sends ACK with the settings. The lease lasts a set time and the device renews it part way through.
The offer is only a proposal. The address belongs to the device once the server acknowledges. DHCP does not check what a device is, and the device cannot tell whether the server that answered is a legitimate one. A lease table is useful evidence of which MAC address was promised which IP address and when. It is not evidence of what the device was or what it did.
See the idea / Networks
An offered address is not a lease until the server says ACK.
Follow the four DHCP messages that give a laptop its address and settings. See which one makes the lease real.
Nyx's test bench. A laptop with no IPv4 address is plugged into the switch. One DHCP server is on the same network. A lease is the server's promise of an address for a set time. DHCP messages travel in UDP: the client uses port 68 and the server port 67. This example sets the broadcast flag, so the server's replies are broadcast too.
01 / 04
DISCOVER
The laptop broadcasts DHCPDISCOVER from 0.0.0.0. It is asking whether any DHCP server is there.
More about this step
The laptop has no address, so the IP source is 0.0.0.0 and the destination is the broadcast address 255.255.255.255. The message carries the laptop MAC address, 02:00:00:00:00:10, so a server can answer it.
Step through at your own pace.
Keep in mindOne server, one network, no relay. Ordinary DHCP does not authenticate either side: the server does not learn what the device is, and a rogue server could answer first. A lease shows that something asked and the server agreed. The check a careful client makes before using the address, and the later renewal, are described but not drawn.
Read the visual, step by step
- DISCOVER. The laptop broadcasts DHCPDISCOVER from 0.0.0.0. It is asking whether any DHCP server is there. The laptop has no address, so the IP source is 0.0.0.0 and the destination is the broadcast address 255.255.255.255. The message carries the laptop MAC address, 02:00:00:00:00:10, so a server can answer it.
- OFFER. The server proposes 192.0.2.23 in a DHCPOFFER. This is only a proposal. The laptop does not use the address yet. The offer names an address and settings the server is willing to give. The server has not committed a lease. If several servers answered, the laptop would receive several offers and choose one.
- REQUEST. The laptop selects that offer and broadcasts DHCPREQUEST. Its source address is still 0.0.0.0. The request names the chosen server and the offered address. It is broadcast so that any other server learns its offer was not taken. The laptop still has no address of its own.
- ACK. The server commits the lease and sends DHCPACK with the settings. The laptop can now configure 192.0.2.23. The server records the lease before it sends the ACK, so the lease table shows what the server promised, not what the laptop did next. The ACK carries a /24 mask, gateway 192.0.2.1, DNS server 192.0.2.53 and a 3600-second lease. Receiving them does not prove the gateway or the DNS server can be reached. By default the laptop asks to renew after half of that, 1800 seconds. A careful client first checks with ARP that nothing else uses the address, and declines the lease if something answers.
One server, one network, no relay. Ordinary DHCP does not authenticate either side: the server does not learn what the device is, and a rogue server could answer first. A lease shows that something asked and the server agreed. The check a careful client makes before using the address, and the later renewal, are described but not drawn.
Flow references: RFC 2131: Dynamic Host Configuration Protocol · RFC 5227: IPv4 Address Conflict Detection
AN ILLUSTRATIVE SCENARIO
A university residence hall
Students in one residence hall lose internet access every evening. The network team finds devices with a gateway address that is not the university's. A student has plugged in a home router the wrong way round, and its DHCP server is answering faster than the real one. The team removes it and turns on DHCP snooping, which lets only named switch ports send DHCP server messages.
Put it to work
- Know which servers are allowed to hand out addresses on each network, and record them.
- Turn on DHCP snooping on managed switches so offers from any other port are dropped.
- Keep lease logs with accurate time. They are often the only link between an IP address in an alert and a physical device.
How to check your work
Join a test device and compare the address, gateway and DNS server it received with what the real server should give. Confirm the lease appears in the server log with the right MAC address.
Connect the ideas
- IP address
A numeric locator used to deliver packets to a host on a network.
- ARP
The protocol a device uses on its local network to ask which hardware (MAC) address holds a given IPv4 address.
- DNS
The lookup system that maps a name people type to an address a computer can contact.
- NAC
Controls that check a device, and often its health, before the network lets it join, usually at the switch port or wireless access point.