Sub topic 6
Leases: renewal at T1, rebinding at T2, and expiry
This chapter assumes you know IPv4 addresses and subnet masks, what a default gateway and a DNS server do, and the Discover, Offer, Request, Acknowledge (DORA) exchange from the previous chapter. It covers what a lease is, how the client keeps it alive with the T1 and T2 timers, and what happens when it expires.
What a lease is
A DHCP server does not give an address away permanently. It lends the address for a fixed time called the lease time. The server sends the lease time in option 51 (IP Address Lease Time), usually in the Offer and again in the Acknowledge. The value is a 32-bit number of seconds. The special value 0xFFFFFFFF means "infinite".
Leases solve a practical problem. Laptops, phones and guests join a network and leave without telling anyone. If addresses were permanent, the pool would fill with addresses nobody uses. With a lease, the server takes an address back when the client stops renewing it.
During the lease, the client may use the address. The server keeps a record that ties the address to the client's identifier (usually the MAC address or a client-identifier option) and to an expiry time. The server must not offer that address to anyone else until the lease ends or the client gives it up.
The three timers
After the Acknowledge, the client starts a clock at the moment the lease began. Three points on that clock matter.
| Point | Name | Default | Client action |
|---|---|---|---|
| T1 | Renewal time (option 58) | 50% of the lease | Unicast a Request to the server that granted the lease |
| T2 | Rebinding time (option 59) | 87.5% of the lease | Broadcast a Request to any server |
| Expiry | Lease time (option 51) | 100% | Stop using the address and start over |
The server can send T1 and T2 explicitly as options 58 and 59. If it does not, the client uses the defaults above. The values must satisfy T1 < T2 < lease time. A client that receives inconsistent values should fall back to the defaults.
The following Python snippet computes the defaults for a 24-hour lease.
lease_seconds = 86400 # 24-hour lease
t1 = lease_seconds * 0.5 # default renewal time: 50% of the lease
t2 = lease_seconds * 0.875 # default rebinding time: 87.5% of the lease
print(f"Renew (unicast to the original server) at {t1:.0f} s")
print(f"Rebind (broadcast to any server) at {t2:.0f} s")
print(f"Lease expires at {lease_seconds} s")The output is 43200 s for T1 and 75600 s for T2. In hours, that is 12 and 21.
The lease state machine
A client moves through named states as time passes. The RFC 2131 names are BOUND, RENEWING, REBINDING and INIT.
In BOUND the client does nothing about DHCP. It uses the address normally. Existing connections keep working and no DHCP traffic flows.
Renewal at T1
When T1 passes, the client enters RENEWING. It sends a DHCPREQUEST by unicast straight to the server that granted the lease. It already knows that server's IP address (from option 54, Server Identifier), and it already has its own IP address, so no broadcast is needed.
Two details differ from the first Request in DORA:
- The
ciaddrfield (client IP address) holds the client's current address. In the initial Request,ciaddris0.0.0.0and the wanted address travels in option 50. - The message does not include option 54. The server learns the client's address from
ciaddr.
If the server agrees, it replies with a DHCPACK carrying a new lease time. The client goes back to BOUND, and the clock restarts from that moment. The address does not change, so nothing the user is running is disturbed.
If the server does not answer, the client retries. RFC 2131 says the client should wait half of the remaining time until T2 between attempts, with a minimum of 60 seconds. For a 24-hour lease with T1 at 12 hours, the first retry is about 4.5 hours later, at roughly 16.5 hours. If the server is down for maintenance but comes back before T2, the client renews and never notices.
Rebinding at T2
If no ACK arrives by T2, the client assumes the original server is gone or unreachable. It enters REBINDING and broadcasts the same DHCPREQUEST to 255.255.255.255. Any server that has a record of this lease may answer. This helps in networks with two DHCP servers that share lease information, or with a replacement server that restored the lease database.
A server that answers with an ACK extends the lease. A server that has no record of the client, or knows the address is no longer valid, may answer with a DHCPNAK. A NAK tells the client to give up the address immediately.
Retries during rebinding follow the same rule: half of the remaining time until expiry, again with a 60-second minimum.
Expiry and starting over
If the lease runs out with no ACK, the client must stop using the address. It removes the IP configuration from the interface, closes the connections that used it, and goes back to INIT. From there it runs DORA again as a new client. It may ask for its old address in option 50, but the server is free to give a different one.
A NAK received during RENEWING or REBINDING has the same effect, but earlier. It means the server has decided the address is not valid for this client. A common cause is that the client moved to a different subnet while it was asleep and woke up still believing it had a lease.
If DORA fails too, many clients fall back to a link-local address in 169.254.0.0/16. The next chapters cover that fallback.
Worked example: a server outage
Take a 24-hour lease granted at 08:00. The client has these deadlines:
- T1 at 20:00 (12 h).
- T2 at 05:00 the next day (21 h).
- Expiry at 08:00 the next day (24 h).
Consider three cases.
- The server is up at 20:00. The client renews with a unicast Request and gets an ACK. The new lease runs from 20:00 to 20:00 the next day. Nobody notices.
- The server crashes at 19:00 and is repaired at 23:00. The T1 attempt at 20:00 gets no reply. A retry about 2 hours later (half of the remaining time to T2, which is about 9 hours) also fails or succeeds depending on timing, and later retries reach the server once it is back. The client renews before T2.
- The server is down for two days. The client never gets an ACK. At 05:00 it starts broadcasting. If no other server answers, the lease expires at 08:00 and the client loses its address.
The lesson for administrators: a lease time sets how long you have to repair a DHCP server before clients start losing connectivity. With a 24-hour lease, you have at least 12 hours before the first clients even try to rebind, and up to 24 hours before the first loss of service.
Choosing a lease time
There is no universal best value. The trade-offs are below.
| Lease length | Benefit | Cost |
|---|---|---|
| Short (minutes to a few hours) | Addresses return to the pool quickly. Good for guest Wi-Fi, conference networks and small pools | More DHCP traffic. Less time to fix a server outage. Logs and name records change often |
| Medium (about 8 to 24 hours) | Balanced. Common default for office LANs | Pool may hold stale leases for a day |
| Long (days or weeks) | Very little DHCP traffic. Survives long outages | Departed devices keep their addresses. Pool exhaustion is possible when many transient devices join |
A rule of thumb: make the lease at least twice as long as the longest outage you want clients to survive, and short enough that the pool does not run out. A pool of 100 addresses with a visitor network that sees 400 different devices per day needs a lease of an hour or two, not a week.
Early release and server-side behavior
A client that is shutting down cleanly may send a DHCPRELEASE. The server then marks the address free at once. Many clients do not send it, particularly phones that simply leave Wi-Fi range. For those, the lease expiry is the only way the address comes back.
Servers often keep an expired lease in a "recently used" state for a short while before reallocating. This lets a returning client get the same address, which keeps DNS records and firewall rules stable. Some servers also probe an address with ping or ARP before offering it, to catch a device that uses it without a lease.
Clients commonly remember their last lease on disk. After a reboot, a client may try to confirm that old address with a Request (the INIT-REBOOT state) instead of a full Discover. If the server agrees, the client is up in two messages instead of four.
Watching renewal happen
You can see the timers in the client's own lease information. On Windows, ipconfig /all shows when the lease was obtained and when it expires. On Linux with dhclient, the lease file lists renew, rebind and expire times.
# Linux (ISC dhclient)
sudo dhclient -r eth0 # release the current lease
sudo dhclient -v eth0 # request a new lease, verbose output
ip -4 addr show eth0 # check the address that was assigned
:: Windows (Command Prompt)
ipconfig /release
ipconfig /renew
ipconfig /allThe ipconfig /renew command forces the client to send a Request now, without waiting for T1. To see the packets, capture on the client or on the server:
sudo tcpdump -n -i eth0 -vv 'udp and (port 67 or port 68)'A normal renewal shows one Request from the client's own address to the server's address (unicast, source port 68, destination port 67) and one Acknowledge back. If you see Requests going to 255.255.255.255 instead, the client has reached T2 and is rebinding, which means the original server did not answer.
Common errors
- Setting a lease too long on a busy guest network. The pool fills with addresses from devices that left hours ago, and new clients get no address.
- Setting a lease too short on a large network. Thousands of clients renew every few minutes, which loads the server and fills the logs.
- Assuming a rebind broadcast reaches the server. Broadcasts stop at the router. Without a relay agent or a server on the same subnet, a client in REBINDING has nobody to ask.
- Changing the subnet or pool while leases are active. Clients keep trying to renew old addresses until they get a NAK. Plan a change by shortening the lease time ahead of it, then waiting one full old lease length.
- Expecting the address to change at renewal. A successful renewal keeps the same address. Only a new DORA after expiry or a NAK can change it.
- Clock errors on the server. Leases are stored as absolute times. A server whose clock jumps may expire leases early or hold them too long.
Exercises
Exercise
A DHCP server grants a 6-hour lease and does not send options 58 or 59. At what times after the lease started does the client first try to renew, and when does it start rebinding? What kind of packet does it send in each case?
Show answer
The lease is 21600 seconds. T1 is 50%, so 10800 s (3 hours). At T1 the client sends a unicast DHCPREQUEST to the server that granted the lease. T2 is 87.5%, so 18900 s (5 hours 15 minutes). If no ACK has arrived by then, the client broadcasts the DHCPREQUEST to 255.255.255.255 so any server can answer. The lease expires at 21600 s (6 hours).
Exercise
A client is in the REBINDING state and the lease expires with no reply from any server. What does the client do, and what could the administrator have done to avoid the loss of service?
Show answer
The client must stop using the address, remove it from the interface and return to INIT, where it runs DORA again. If that also fails, it may fall back to a 169.254.x.x link-local address. The administrator could have used a longer lease so that more time passed before expiry, restored or replaced the server earlier, or run a second server (or failover pair) so that a broadcast at T2 would be answered.
Exercise
You capture traffic and see a client sending DHCPREQUEST packets to 255.255.255.255 with its current address in ciaddr. Which state is it in, and what does that say about the original server?
Show answer
The client is in REBINDING, so T2 has passed. The original server did not answer the unicast renewals sent after T1. It may be down, unreachable, or removed from the network. The client is now asking any server to extend the lease.