DHCP Basics: Leases, Address Pools, the Message Format and Options
What a host needs before it can use the Internet and how DHCP gives it all of that automatically: address pools and leases, the BOOTP-based message format field by field, the options and message types, captured from a real Kea server and dhclient in a lab.
kvi5hnuCode Sprout team member15 min readOn this page
Before a computer can send its first useful packet, it needs at least four pieces of information: an IP address, the subnet mask (or prefix length), the address of a default router, and the address of a DNS server. Typing those in by hand works for a few servers, but not for the laptops and phones that join a network every minute. The Dynamic Host Configuration Protocol (DHCP) hands them out automatically.
This part of the course covers how hosts configure themselves: DHCP for IPv4 (this article and article 30), DHCPv6 (article 31), stateless autoconfiguration (article 32), and how configuration ties into DNS, plus attacks on it (article 33).
What needs configuring
The essentials, for IPv4:
| Item | Why it's needed |
|---|---|
| IP address | To be addressed at all |
| Subnet mask | To know which destinations are on the local link (direct delivery, article 27) |
| Default router | To reach everything else |
| DNS server(s) | To turn names into addresses |
Plenty more can be useful: a domain name and search list, NTP (Network Time Protocol) servers for setting the clock, an MTU, extra static routes, a proxy configuration, or a boot server for a diskless machine. DHCP carries all of these as options.
There are two ways to configure a host automatically:
- Stateful: a server keeps track of which address it gave to whom. That's DHCP for IPv4, and DHCPv6 in its stateful mode.
- Stateless: the host builds its own address from information on the link, and no server keeps state. That's IPv6 SLAAC (stateless address autoconfiguration) and IPv4 link-local addressing (article 32).
Leases and address pools
A DHCP server is configured with one or more pools of addresses for each subnet it serves. When a client asks, the server picks a free address from the pool and grants it for a limited time, the lease. The client may use the address until the lease ends and must renew it to keep it. If the client goes away without saying goodbye, the address simply returns to the pool when the lease expires.
The lab's server is Kea, the current DHCP server from ISC (the Internet Systems Consortium, a non-profit that maintains open-source DNS and DHCP software) (its older ISC DHCP server reached end of life in 2022). Its configuration for the lab subnet:
subnet 192.0.2.0/24, pool 192.0.2.100 - 192.0.2.199
lease (valid-lifetime) 3600 s, renew-timer 1800 s, rebind-timer 3150 s
options: routers 192.0.2.1, domain-name-servers 198.51.100.53, domain-name example.com
Lease length is a trade-off:
- Short leases (minutes to an hour) free addresses quickly on busy networks such as cafés or conferences, where many devices come and go, but cause more renewal traffic and make the network more dependent on the server being up.
- Long leases (a day to a week) suit stable networks such as offices and homes. They mean less traffic and more tolerance for a server outage, but they hold addresses for devices that have left.
Besides dynamic pools, servers support reservations (often called static leases): a particular client, identified by its MAC address or client identifier, always gets the same address. That's how printers and servers on a home network often get fixed addresses without manual configuration.
Getting a lease: a first look
Here is a Linux client, with no IPv4 address, running the ISC dhclient against the lab's Kea server. dhclient reached end of life together with the ISC DHCP server and is no longer maintained, but its verbose log makes it a handy test client:
eth0: no IPv4 address
DHCPDISCOVER on eth0 to 255.255.255.255 port 67 interval 4
DHCPOFFER of 192.0.2.100 from 192.0.2.2
DHCPREQUEST for 192.0.2.100 on eth0 to 255.255.255.255 port 67
DHCPACK of 192.0.2.100 from 192.0.2.2
bound to 192.0.2.100 -- renewal in 1504 seconds.
In the log, interval 4 is how many seconds the client waits before repeating the DISCOVER if nobody answers, and 192.0.2.2 is the server. Four messages: DISCOVER (is there a server?), OFFER (here's an address), REQUEST (I'll take it), and ACK (it's yours). Article 30 follows this exchange step by step. The result:
inet 192.0.2.100/24 brd 192.0.2.255 scope global dynamic eth0
default via 192.0.2.1 dev eth0
search example.com
nameserver 198.51.100.53
The address is marked dynamic, because it came with a lease. The default route and DNS settings also came from the server. The renewal in ... seconds value in the log above is about half the lease, but varies from run to run because the client adds some randomness to avoid every client renewing at the same moment.
The message format
DHCP grew out of BOOTP, the Bootstrap Protocol (RFC 951, 1985), which let diskless machines learn their address and where to download their operating system. DHCP (RFC 2131, 1997) kept the BOOTP message format so that the same relays and servers could handle both, and put the new features into options.
Messages travel in UDP: clients use port 68 and servers port 67. Since a client without an address can't receive ordinary unicast, it sends from 0.0.0.0 to the broadcast address 255.255.255.255. The figure shows the message layout, four bytes per row, and the list after it explains each field.

The fields:
- op: 1 for messages from a client (BOOTREQUEST), 2 for replies from a server (BOOTREPLY). The real message type is in option 53.
- htype and hlen: the hardware type (1 = Ethernet) and address length (6 bytes).
- hops: incremented by each relay agent (article 30).
- xid: a random transaction ID chosen by the client, used to match replies to requests.
- secs: seconds since the client started trying. Servers can use it to give an answer only after the primary server has had a chance.
- flags: only the top bit is used, the broadcast flag. A client sets it if it can't receive unicast IP packets before it has an address, asking the server to broadcast its reply.
- ciaddr: the client's current address, filled in only when it already has one (when renewing).
- yiaddr: "your" address, the address the server is giving the client.
- siaddr: the next server in a boot process, such as a TFTP (Trivial File Transfer Protocol) server that a machine downloads its boot image from.
- giaddr: the address of the relay agent that forwarded the message, or 0 if none (article 30).
- chaddr: the client's hardware address, in a 16-byte field.
- sname and file: a server name and boot file name, left over from BOOTP. They're normally empty, and can be reused for extra options (option overload, option 52).
- magic cookie: the four bytes
0x63825363(99, 130, 83 and 99 in decimal), which mark the start of DHCP options.
Here is the lab server's OFFER, decoded by tshark:
Dynamic Host Configuration Protocol (Offer)
Message type: Boot Reply (2)
Hardware type: Ethernet (0x01)
Hardware address length: 6
Hops: 0
Transaction ID: 0x48546405
Seconds elapsed: 0
Bootp flags: 0x0000 (Unicast)
0... .... .... .... = Broadcast flag: Unicast
.000 0000 0000 0000 = Reserved flags: 0x0000
Client IP address: 0.0.0.0
Your (client) IP address: 192.0.2.100
Next server IP address: 0.0.0.0
Relay agent IP address: 0.0.0.0
Client MAC address: 02:00:00:00:0c:01 (02:00:00:00:0c:01)
Client hardware address padding: 00000000000000000000
Server host name not given
Boot file name not given
Magic cookie: DHCP
Option: (53) DHCP Message Type (Offer)
DHCP: Offer (2)
Option: (1) Subnet Mask (255.255.255.0)
Subnet Mask: 255.255.255.0
Option: (3) Router
Router: 192.0.2.1
Option: (6) Domain Name Server
Domain Name Server: 198.51.100.53
Option: (12) Host Name
Host Name: laptop1
Option: (15) Domain Name
Domain Name: example.com
Option: (51) IP Address Lease Time
IP Address Lease Time: 1 hour (3600)
Option: (54) DHCP Server Identifier (192.0.2.2)
DHCP Server Identifier: 192.0.2.2
Option: (58) Renewal Time Value
Renewal Time Value: 30 minutes (1800)
Option: (59) Rebinding Time Value
Rebinding Time Value: 52 minutes, 30 seconds (3150)
Option: (255) End
The fixed fields say who the message is for: chaddr is the client's MAC address, and yiaddr the offered address. Everything else, the router, DNS server, domain name and lease times, is in options.
The OFFER was sent to 192.0.2.100, the offered address, by unicast, even though the client doesn't have that address yet. The server can do this because the client didn't set the broadcast flag: the server sends the IP packet to yiaddr in an Ethernet frame addressed to chaddr, and Linux accepts it. A client that can't handle that sets the flag, and then servers broadcast their replies.
Options
Each option is a type-length-value: a 1-byte code, a 1-byte length and the data. Two codes have no length: 0 (Pad) and 255 (End). IANA's "BOOTP and DHCP Parameters" registry lists them all. These are the ones you'll see most:
| Code | Name | Contents |
|---|---|---|
| 1 | Subnet Mask | The subnet mask |
| 3 | Router | Default router address(es) |
| 6 | Domain Name Server | DNS server address(es) |
| 12 | Host Name | The client's host name |
| 15 | Domain Name | The DNS domain |
| 26 | Interface MTU | The MTU to use on the link |
| 42 | NTP Servers | Time servers |
| 50 | Requested IP Address | The address a client asks for (for example, its old one) |
| 51 | IP Address Lease Time | Lease length in seconds |
| 53 | DHCP Message Type | Which DHCP message this is (required in every message) |
| 54 | Server Identifier | The address of the server sending the message |
| 55 | Parameter Request List | The option codes the client wants |
| 58 / 59 | Renewal (T1) / Rebinding (T2) Time | When to renew and rebind |
| 60 | Vendor Class Identifier | The client's type, for example PXEClient (a machine booting over the network) or android-dhcp-14 |
| 61 | Client Identifier | A stable client ID used instead of the MAC address |
| 81 | Client FQDN | The client's fully qualified domain name (a complete name such as laptop1.example.com) for DNS updates (article 33) |
| 82 | Relay Agent Information | Added by relays: which switch port the client is on (article 30) |
| 108 | IPv6-Only Preferred | Tells clients that can run IPv6-only to skip IPv4 (RFC 8925) |
| 114 | Captive Portal | URL of a captive portal's API (RFC 8910) |
| 119 | Domain Search | The DNS search list |
| 121 | Classless Static Route | Extra routes, with prefix lengths (RFC 3442) |
A client lists the options it wants in option 55, the Parameter Request List. The lab client's DISCOVER asked for:
Parameter Request List Item: (1) Subnet Mask
Parameter Request List Item: (28) Broadcast Address
Parameter Request List Item: (3) Router
Parameter Request List Item: (15) Domain Name
Parameter Request List Item: (6) Domain Name Server
Parameter Request List Item: (119) Domain Search
Parameter Request List Item: (26) Interface MTU
Parameter Request List Item: (121) Classless Static Route
Parameter Request List Item: (42) Network Time Protocol Servers
The server sends the requested options it has values for, plus the ones it always sends, such as 51 and 54. Options a client asks for but the server doesn't have are simply left out.
Two options are worth highlighting:
- IPv6-Only Preferred (108). On a network where IPv6 works and NAT64, a translator between IPv6 and IPv4, gives access to the IPv4 Internet (article 38), the server can include this option. A client that supports it stops asking for IPv4 for the time given, and runs IPv6-only. Recent versions of iOS, macOS and Android support it, which saves IPv4 addresses on large networks.
- Classless Static Route (121). It carries routes with any prefix length, replacing the old classful option 33. If a server sends it, the client must ignore the Router option, so the default route has to be included as
0.0.0.0/0in the list.
Message types
Option 53 gives the real message type:
| Value | Message | Sent by | Purpose |
|---|---|---|---|
| 1 | DHCPDISCOVER | Client | Find servers |
| 2 | DHCPOFFER | Server | Offer an address and options |
| 3 | DHCPREQUEST | Client | Accept an offer, or renew or confirm a lease |
| 4 | DHCPDECLINE | Client | The offered address is already in use |
| 5 | DHCPACK | Server | Confirm the lease and its parameters |
| 6 | DHCPNAK | Server | Refuse: the client's address is wrong for this network |
| 7 | DHCPRELEASE | Client | Give the address back early |
| 8 | DHCPINFORM | Client | Ask for options only (it already has an address) |
Later RFCs added more types, such as FORCERENEW (9, RFC 3203), which lets a server tell a client to renew right away, and LEASEQUERY and related types (10 to 13 and beyond), which let a relay or another system ask a server about a lease. You'll rarely see these on a home network.
Where the lease is stored
Both sides record the lease. The client stores it so it can ask for the same address after a reboot (with option 50):
lease {
interface "eth0";
fixed-address 192.0.2.100;
option subnet-mask 255.255.255.0;
option dhcp-lease-time 3600;
option routers 192.0.2.1;
option dhcp-message-type 5;
option dhcp-server-identifier 192.0.2.2;
option domain-name-servers 198.51.100.53;
option dhcp-renewal-time 1800;
option dhcp-rebinding-time 3150;
option host-name "laptop1";
option domain-name "example.com";
renew 5 2026/11/20 20:43:35;
rebind 5 2026/11/20 21:11:01;
expire 5 2026/11/20 21:18:31;
}
The renew, rebind and expire lines are absolute times, computed from options 58, 59 and 51 when the ACK arrived. The server keeps its own record, here Kea's CSV lease file (with the expiry as a Unix timestamp):
address,hwaddr,valid_lifetime,expire,hostname
192.0.2.100,02:00:00:00:0c:01,3600,1795209511,laptop1
Lease timers
A lease comes with two timers. T1 (option 58) defaults to 50% of the lease, and T2 (option 59) to 87.5%:

- At T1, the client starts renewing: it sends a REQUEST by unicast to the server that granted the lease, which normally answers with an ACK and a new lease.
- If that server doesn't answer by T2, the client starts rebinding: it broadcasts its REQUEST so that any server that knows about the lease can extend it.
- If the lease expires with no answer, the client must stop using the address and start over with DISCOVER.
Article 30 shows renewal and rebinding happening in the lab, using a very short lease.
Common questions
Is my home router the DHCP server?
Almost always, yes. Home routers run a DHCP server for the LAN and give out their own LAN address as both the default router and the DNS server, then forward DNS queries upstream. They're also DHCP clients on the WAN (wide area network, the Internet-facing) side, getting their public address from the ISP, the internet service provider.
Why does DHCP use broadcasts?
A client starting up has no address and doesn't know any server's address, so it can't send unicast. Broadcasting to 255.255.255.255 from 0.0.0.0 reaches every server on the link. Servers can reply by unicast to the offered address (as in the lab) or by broadcast if the client asks.
What happens if two DHCP servers are on the same network?
The client gets two OFFERs and accepts one, usually the first. That's fine if both servers are coordinated, for example a Kea high-availability pair, but a stray server, such as a home router plugged into an office network, can hand out wrong addresses and gateways. Article 33 covers rogue servers, and article 30 shows DHCP snooping, the usual defense.
What is the difference between a reservation and a static address?
A reservation is set on the server: the client still uses DHCP, but always gets the same address. A static address is configured on the client itself, with no DHCP. Reservations keep configuration in one place, and the client still learns the router and DNS server from the server.
Can DHCP give out IPv6 addresses?
Not DHCP for IPv4. IPv6 uses a separate protocol, DHCPv6 (article 31), with different messages and ports, and many IPv6 networks use SLAAC (article 32) instead of or alongside it.
Why does my lease show a different renewal time than exactly half the lease?
Clients add random "jitter" so that a large group of clients that started together, for example after a power cut, don't all renew at the same moment. ISC dhclient picks a time somewhat before T1, so the lab's value differs from 1800 seconds and changes on every run.
Summary
- A host needs at least an address, a mask, a default router and a DNS server. DHCP delivers these and many other options automatically.
- Servers hand out addresses from pools as time-limited leases. Lease length trades address reuse against traffic and dependence on the server. Reservations give a client a fixed address.
- DHCP uses the BOOTP message format over UDP ports 67 and 68: op, hardware type, xid, flags, four address fields (ciaddr, yiaddr, siaddr, giaddr), chaddr, the magic cookie
0x63825363and TLV options. - Option 53 gives the message type (DISCOVER, OFFER, REQUEST, DECLINE, ACK, NAK, RELEASE, INFORM), and option 55 lists the options a client wants.
- T1 (50%) and T2 (87.5%) control when a client renews with its own server and when it rebinds with any server.
Practice questions
1. Which DHCP message field carries the address being assigned to the client: ciaddr, yiaddr, siaddr or giaddr?
Answer
yiaddr ("your" IP address). ciaddr is the client's current address, filled in only when it already has one; siaddr is the next boot server; and giaddr is the relay agent's address.
2. A DHCPOFFER grants a 2-hour lease without options 58 and 59. When does the client start renewing and when does it start rebinding?
Answer
With the defaults, T1 = 50% of 7,200 s = 3,600 s (1 hour) and T2 = 87.5% of 7,200 s = 6,300 s (1 hour 45 minutes).
3. Every DHCP message from a client has op = 1. How does a server tell a DISCOVER from a REQUEST?
Answer
By option 53, DHCP Message Type: 1 for DISCOVER, 3 for REQUEST. The op field only distinguishes client messages from server replies, as in BOOTP.
4. A server's ACK includes option 121 with routes for 198.51.100.0/24 and 0.0.0.0/0, and option 3 with a router address. Which default router does a client that supports option 121 use?
Answer
The one in option 121's 0.0.0.0/0 entry. RFC 3442 says that when option 121 is present the client must ignore option 3, which is why RFC 3442 tells administrators to put the default route in the classless list as well (and to keep option 3 for clients that don't support option 121).
5. A café network gives out a /24 (about 250 addresses) with 24-hour leases, and runs out of addresses every afternoon. Explain why and suggest a fix.
Answer
Every phone and laptop that visits holds its address for 24 hours, even after leaving, so 250 visitors a day exhaust the pool. Shortening the lease to something like 30 to 60 minutes lets departed devices' addresses return to the pool quickly. A larger subnet would also help.
6. What is the magic cookie, and why is it needed?
Answer
The four bytes 0x63825363 right after the fixed BOOTP fields. They mark the start of the options area, so a receiver can tell a message with DHCP options apart from an old BOOTP message whose vendor area held something else.
Previous: Host Models, Source Address Selection and Mobile IP
Next: How DHCP Works: Discover, Offer, Request, Renewals, Relays and Snooping

More in TCP/IP Course
Quiz: TCP/IP Delicate Details
Twenty-five questions on the details that catch out experienced engineers: sequence numbers for SYN and FIN, TIME_WAIT versus tcp_fin_timeout, Karn's algorithm, socket buffer doubling, even and odd ephemeral ports, IPv6 checksums and fragmentation, negative DNS caching, and capture filter traps.
Quiz: TCP/IP Interview Questions
Thirty-three networking questions of the kind asked in developer, SRE and network engineering interviews: what happens when you load a URL, TCP versus UDP, handshakes, closing and TIME_WAIT, subnetting, NAT, DNS, MTU problems, congestion, TLS and QUIC, and debugging slow or failing connections.
Quiz: TCP/IP Course Final Exam (All Parts)
The final exam for the TCP/IP course: thirty questions across all fourteen parts, from packets and addressing through Ethernet, ARP, IP, DHCP, NAT, ICMP, UDP, DNS, TCP connections, reliability, congestion control, security, QUIC and troubleshooting.
Quiz: Modern Transports and Troubleshooting (TCP/IP Part 14)
Review modern transports and troubleshooting: QUIC packets, handshakes, 0-RTT, streams and connection migration, HTTP/3, Multipath TCP, SCTP multihoming, and a layered method for diagnosing real network faults.
Discussion
Sign in to ask a question or share what you learned.