The use of dynamic address allocation in DHCP means a whole new way of thinking about addresses. A client no longer owns an address, but rather leases it. This means that when a client machine is set to use DHCP dynamic addressing, it can never assume that it has an address on a permanent basis. Each time it powers up, it must engage in communications with a DHCP server to begin or confirm the lease of an address. It also must perform other activities over time to manage this lease and possibly terminate it.
The DHCP Lease "Life Cycle"Calling dynamic address assignments leases is a good analogy, because a DHCP IP address lease is similar to a “real world” lease in a number of respects. For example, when you rent an apartment, you sign the lease. Then you use the apartment for a period of time. Typically, assuming you are happy with the place, you will renew the lease before it expires, so you can keep using it. If by the time you get near the end of the lease the owner of the apartment has not allowed you to renew it, you will probably lease a different apartment to ensure you have somewhere to live. And if you decide, say, to move out of the country, you may terminate the lease and not get another at all.
DHCP leases follow a similar lease “life cycle”, which generally consists of the following phases:
- Allocation: A client begins with no active lease, and hence, no DHCP-assigned address. It acquires a lease through a process ofallocation.
- Reallocation: If a client already has an address from an existing lease, then when it reboots or starts up after being shut down, it will contact the DHCP server that granted it the lease to confirm the lease and acquire operating parameters. This is sometimes calledreallocation; it is similar to the full allocation process but shorter.
- Normal Operation: Once a lease is active, the client functions normally, using its assigned IP address and other parameters during the “main part” of the lease. The client is said to be bound to the lease and the address.
- Renewal: After a certain portion of the lease time has expired, the client will attempt to contact the server that initially granted the lease, torenew the lease so it can keep using its IP address.
- Rebinding: If renewal with the original leasing server fails (because, for example, the server has been taken offline), then the client will try to rebind to any active DHCP server, trying to extend its current lease with any server that will allow it to do so.
- Release: The client may decide at any time that it no longer wishes to use the IP address it was assigned, and may terminate the lease,releasing the IP address. Like the apartment-renter moving out of the country, this may be done if a device is moving to a different network, for example. Of course, unlike DHCP servers, landlords usually don't let you cancel a lease at your leisure, but hey, no analogy is perfect.
Figure 259: DHCP “Life Cycle” Example
In this example, the initial lease has a duration of eight days and begins at Day 0. The T1 and T2 timers are set for 4 days and 7 days respectively. When the T1 timer expires the client enters the renewal period, and successfully renews at Day 5 with a new 8-day lease. When this second lease’s T1 timer expires, the client is unable to renew with the original server. It enters the rebinding period when its T2 timer goes off, and is granted a renewed 8-day lease with a different server. Three days into this lease it is moved to a different network and no longer needs its leased address, so it voluntarily releases it.
Renewal and Rebinding Timers
The processes of renewal and rebinding are designed to ensure that a client's lease can be extended before it is scheduled to end, so no loss of functionality or interruption occurs to the user of the client machine. Each time an address is allocated or reallocated, the client starts two timers that control the renewal and rebinding process:
- Renewal Timer (T1): This timer is set by default to 50% of the lease period. When it expires, the client will begin the process of renewing the lease. It is simply called “T1” in the DHCP standards.
- Rebinding Timer (T2): This timer is set by default to 87.5% of the length of the lease. When it expires, the client will try to rebind, as described above. It is given the snappy name “T2” in the DHCP standards.
Naturally, if the client successfully renews the lease when the T1 timer expires, this will result in a “fresh lease”, and both timers will be reset. T2only comes into play if the renewal is not successful. It is possible to change the amount of time to which these timers are set, but obviously T1must expire before T2, which must in turn expire before the lease itself ends. These usually are not changed from the default, but may be modified in certain circumstances.
Key Concept: DHCP leases follow a conceptual life cycle. The lease is first assigned to the client through a process of allocation; if the device later reboots it will reallocate the lease. After a period of time controlled by the renewal timer (T1), the device will attempt to renewits lease with the server that allocated it. If this fails, the rebinding timer (T2) will go off and the device will attempt to rebind the lease with any available server. The client may also release its IP address if it no longer needs it.
The lease life cycle is described in the DHCP standards in the form of states that the client moves through as it acquires a lease, uses it, and then either renews or ends it. The next section on DHCP configuration describes these states and the specific exchanges of messages between a client and server to accomplish different lease activities.