In this free course from ITFreeTraining, we’ll take a look at Dynamic Host Configuration Protocol, better known as DHCP.
In this video from ITFreeTraining, I will look at what is a DHCP lease. When a DHCP server allocates an IP Address to a device, the lease determines how long that device can use that IP Address. This video looks at what is a lease and the important time periods associated with that lease.Show lesson content
Just like when you take out a lease on a house, you don’t own the house, but you get the right to use the house while the lease is in place. If the lease expires, you need to find a new place to live. Let’s have a closer look at how a DHCP lease works.
0:56 Consider that you have a device on the network that needs an IP Address to communicate. In this case a desktop computer. The device will communicate on the network and locate a DHCP server. The DHCP server will allocate the device an IP Address and a lease time. Essentially the device is free to use that IP Address for the lease time.
The lease time is configured on the DHCP server. On Windows, the default lease time is eight days. On Linux the default lease time differs depending on the distribution.
The device can also request a certain lease time, but ultimately it is up to the server to decide what lease time it wants to allocate to the device. Windows will always allocate the lease time that is configured on the server. On Linux, the administrator can configure a default value that will be used if the device does not request a certain time. If the device does request a certain lease time, Linux supports a maximum value that it will allocate up to.
It is also possible to configure the lease time to unlimited; however, this is not recommended. As we will see in later videos, renewing a lease also allows network configuration to be changed. Setting the lease time to unlimited makes it harder for the administrator to make changes to network configuration at a later date.
DHCP Lease Renewal
2:18 Let’s consider what happens when the client has been given a lease. The lease in this example is set for eight days which is the default for Windows. For the first half of the lease, which is four days in this example, the client will not attempt to renew the lease. This is referred to as Timer 1 or T1. The administrator is free during this time period to perform a manual renewal if they wish. However, the device will not attempt to renew the lease during this period.
The next timer is Timer 2 or T2. This is 87.5% of the lease time or seven eighths. In this example, this will be the time period of five to seven days. During this time, the device will attempt to renew its lease. It does this by attempting to contact the original DHCP server that it obtained the lease from.
Once the lease time becomes greater than T2, the device goes into what is referred to as rebinding. Rebinding means that the device will attempt to obtain an IP Address from any DHCP server. If the device is able to contact the original DHCP server, it will be able to renew its IP Address. If it contacts a different DHCP server it will obtain a different IP Address.
DHCP Lease Renewal Example
3:37 Now let’s consider an example. On this network, there are two DHCP servers and one desktop computer. The desktop computer requires an IP Address so it requests one from a DHCP server. In later videos I will go into this process in more detail.
The desktop computer now has a lease which allows it to use an IP Address on the network. In this example, I will once again use an eight-day lease, so for the first four days it uses the lease without trying to renew it.
On the fifth day, it will attempt to renew it. The desktop will keep doing this up to the seventh day. If the desktop is able to contact the DHCP Server within these three days, the lease will be renewed. When this occurs, the lease time goes back to zero.
The process now repeats. For the first half of the lease time, the desktop does not attempt to renew its lease. For this example, let’s consider that the first DHCP server has failed. The desktop will not be able to renew its lease. However, it will attempt to keep contacting the DHCP server and will not attempt to contact any other DHCP servers.
On the last day, the desktop will attempt to contact any DHCP server on the network to renew or obtain a new IP Address. In this case, the second DHCP server is contacted. The second DHCP server cannot renew the IP Address; however, it can give the desktop a new IP Address. The desktop is now able to communicate on the network using the new IP Address. Since a new IP Address has been allocated to the desktop, the lease time starts again from zero.
You can see the process keeps repeating itself. If the DHCP server is always available, the device will generally always use the same IP Address. However, in some cases the administrator may want to change the IP Addresses that are given to devices. When this occurs, it is possible during the renewal phase that the device is given another IP Address. Having the IP Address change can cause problems with open connections to the computer; let’s have a look at how IPv6 handles that issue.
DHCP IPv6 Leases
5:49 DHCP for IPv6 adds an additional time value. This is the valid lifetime value. In Windows, the default value is 12 days. Let’s have a look at how this works.
For the first 50% of the lease time, the device won’t make an attempt to renew the lease. Up to Timer 2, the device will attempt to renew the IP Address with the DHCP server. In this example, let’s say the DHCP server is not available.
After Timer 2, the device will attempt to contact any DHCP server. In this example, let’s say that the device was successful and was given a new IP Address. In IPv4, the IP Address will change which can be disruptive to some applications. IPv6 prevents this from happening by having the IP Address changed to a deprecated state. When in this state, the IP Address can still be used, but its use is discouraged. New connections should use the new IP Address.
Using this method, if an application sensitive to IP Address changes was currently transferring data using that IP Address, the application could keep using the old IP Address until it completed transferring its data. Thus preventing disruption to the application.
7:08 Before I end this video, I will perform a quick summary of the main points covered. The lease time is a period during which the device can use an IP Address for. On Windows the default is eight days. Non-Windows systems may also add the option of a device being able to request a different lease time than the default.
Timer 1 or T1 is 50% of the lease time. Timer 2 or T2 is 87.5% of the lease time. A device will attempt to renew its IP Address after T1. The device will only do this with the DHCP server that it obtained the original lease from. It is also possible for the DHCP server not to renew the lease. When this occurs, the device will obtain a new IP Address rather than using the old one.
Generally, DHCP servers will always allow the device to continue using the same IP Address unless the administrator makes changes to the DHCP server. For example, the administrator removes the IP Address from the pool of allocable IP Addresses.
If the device is not able to renew its IP Address after Timer 2 has expired, the device will attempt to rebind. In this state, the device will contact any DHCP server to obtain a lease. This essentially means, that the IP Address of the device may change. DHCP servers tend to be pretty reliable, so it should be rare that a device will need to change its IP Address.
That’s it for DHCP leases. I hope you have found this video informative. For the other free videos in our DHCP course and others, please see our web site or YouTube channel. Until next time, I would like to thank you for watching.
“Dynamic Host Configuration Protocol” https://www.ietf.org/rfc/rfc2131.txt