DHCP: getting an address
A device that joins a network has no IP address, so how does it get one? Watch a laptop join a home network: it shouts for help, the router lends it an address from a pool, and four messages later (DORA) it is online. Then see how the loan, called a lease, is kept alive.
5 quick questions
Pick an answer to see why. Your score saves with your progress.
01Why does the laptop send its DHCPDISCOVER to 255.255.255.255?
With no IP address of its own and no idea where a DHCP server is, the only thing the laptop can do is shout to everyone on the local network. Only a DHCP server answers.
02What is the right order of the four DHCP messages?
DORA: the client discovers, the server offers, the client requests the offered address, and the server acknowledges.
03Besides an IP address, which of these does the DHCP offer give the laptop?
Options 1, 3 and 6 carry the mask, router and DNS server, and option 51 the lease time. The MAC address is built into the device; DHCP never assigns it.
04The DHCPREQUEST is still a broadcast. Why?
The request names the chosen server (option 54). Other servers see it and put their offered addresses back in their pools.
05With a 24-hour lease, when does the laptop first try to renew, and how?
T1 is half the lease. The laptop already has an address, so it asks the router directly (unicast). Only if that fails does it broadcast at T2 (21 h), and at 24 h it must give the address up.
Glossary
- DHCP
- Dynamic Host Configuration Protocol: the way a device borrows an IP address and its network settings from a server.
- DORA
- Discover, Offer, Request, Ack: the four messages that get a device its first address.
- Broadcast
- A message to every device on the local network. In IPv4 the address 255.255.255.255 means 'everyone here'.
- Unicast
- A message to exactly one device, sent to its own address.
- Lease
- The time a device may keep a DHCP address before it must renew it, for example 24 hours.
- Address pool
- The range of addresses a DHCP server may lend out, here 192.168.1.100 to 192.168.1.199.
- Default gateway
- The router a device sends packets to when the destination is outside the local network.
- T1 / T2
- Renewal time (50% of the lease, ask the same server) and rebinding time (87.5%, ask any server).
Notes and sources
- DHCP messages and timers follow RFC 2131; option numbers follow RFC 2132. Clients listen on UDP port 68, servers on 67.
- 192.168.1.0/24 is a private range (RFC 1918). The MAC addresses come from the documentation block 00:00:5e:00:53:xx (RFC 7042); ff:ff:ff:ff:ff:ff is the real Ethernet broadcast address. The transaction ID is illustrative.
- A 24 h lease is a common home-router default; T1 = 50% and T2 = 87.5% of the lease are the RFC 2131 defaults, and a server may send other values in options 58 and 59.
- Before using a new address, the client should check nobody else has it, for example with an ARP probe; if someone answers, it sends DHCPDECLINE and starts again.
- On big networks the DHCP server can sit on another subnet; a relay agent on the router forwards the broadcasts to it.
Quiz Unlocks after the last step.