In this article, we’ll take a look at what DHCP is, what it’s used for and particularly, why it’s so popular with businesses and service providers around the world.
What Is DHCP and What Is It Used For?
What is DHCP?
The DHCP (Dynamic Host Configuration Protocol) is one of the most basic services that all home and business networks rely on. In fact, it’s so important that it’s even worth us dedicating an entire article to it!
Normally, when managing a TCP/IP network, the network administrator needs to at least assign an IP address to each device connected to the network. In the early days, this was done manually, and the administrator had to plan how to distribute all the required IP addresses and set up each computer one by one.
Now, this way of working may not be a big deal if you only have a few devices to connect and they’re unlikely to change very often, but what happens when you have to connect 100 computers, or even 1,000? And what happens if different machines are continually joining and leaving the network? In these kinds of scenarios, the manual approach is clearly inefficient, unsustainable and simply requires far too much effort from the administrator.
Furthermore, doing everything manually just means there’s a greater risk of making a mistake, leading to connection errors, IP overlapping and other problems besides. And that’s just when dealing with IP addresses. A computer needs to know many more details to connect to a network, such as:
- Subnet mask
- Gateway
- DNS server
- And other details that we won’t go into just yet. We’ll get to them shortly.
Now, if a technician makes a mistake when entering any of these details, this could lead to duplicate IP addresses, prevent the computer from accessing the gateway and many other issues besides.
And that’s not the worst that could happen. So far, we’ve only considered what would happen if we make a mistake on one computer. What happens if you need to replace the DNS server for some reason? Then you would have to change this setting on every single machine. That would mean going around all the computers connected to the network just to change this one parameter. That would be tedious enough if you have 10 users, but imagine how crazy it would be to have to do it for 100 or 1,000.
What are the origins of DHCP?
To try and resolve the issues involved in managing IP addresses, particularly in large organisations, a group of businesses and experts worked together on defining a protocol that would allow these tasks to be carried out dynamically, and this protocol ended up being the open standard defined in RFC 2132 by the IETF (Internet Engineering Task Force) which defines the basic principles of DHCP.
As we mentioned, DHCP solves the problem of assigning and managing IP addresses by taking care of automatically assigning them, renewing them and releasing them without the administrator having to get involved.
In reality, if you look at RFC 2132, you can see that DHCP has its origins in BOOTP. BOOTP was a protocol designed to work on dumb terminals (computers that have no disk) and sent network parameters to computers based on their physical address (MAC address), which is a unique address assigned to each device on the network.
BOOTP passed the network parameters to clients that requested them using a TFTP (Trivial File Transfer Protocol) server. Once they received this information, they were ready to start using the network.
So, BOOTP made it possible to automatically configure the client device, making the network administrator’s life much easier.
But this was actually only part of the solution. While the protocol sent network parameters automatically, the administrator was still responsible for assigning IP addresses and storing the configuration for each machine on the TFTP server.
Another issue with BOOTP was that it wasn’t able to detect errors like duplicate IP addresses. This meant that two clients could accidentally be assigned the same address and the server would make no effort to resolve the issue.
DHCP was created to solve these problems. It not only sends out the network parameters but also assigns IP addresses automatically and all the administrator has to do is assign a range of valid IP addresses to choose from. DHCP also takes care of ensuring that there are no overlaps, which will only occur if the administrator configures an account manually and makes a mistake.
What does DHCP actually do?
So far, we’ve talked about how wonderful DHCP is and how it can automatically configure network parameters. But now, we’re going to go into more detail about how it actually works.
Firstly, we need to mention that, when we say that it assigns IP addresses automatically, we’re not being completely truthful. Actually, DHCP can assign IP addresses in three different ways:
- Manual Allocation: This involves linking an IP address from the server’s IP pool to the computer’s physical (MAC) address. This IP address is only available for this computer and cannot be used for any other client. It works in a similar way to BOOTP.
- Dynamic Allocation: The server assigns an IP address to the client for a specific period of time. Once this time has elapsed, if the client is still connected, the IP address is renewed. As long as the client remains connected, it will be as if it had a fixed IP address. The address won’t change unless the computer disconnects or the administrator wishes to change it.
- Automatic Allocation: The server assigns an IP address to the client and the address remains assigned to this computer indefinitely, becoming a permanent value.
At this point, you might be asking yourself whether you need to choose one of these modes for your DHCP server, and the answer is no. You don’t need to pick on. In fact, in general, all three modes co-exist in a business’s DHCP ecosystem.
For example, you might want to use manual allocation for devices used by your IT technicians, dynamic allocation for customers who occasionally visit your facilities and automatic allocation for employee computers are always on site.
You might also be asking yourself what parameters DHCP takes care of. We briefly mentioned some of them earlier on, but let’s go into a bit more detail so you have a clearer idea of exactly what DHCP does.
A DHCP server basically provides the following details to a client device:
- IP Address: A unique identifier assigned to the computer.
- Subnet Mask: This is used for network operations and to identify the network that the device is connected to.
- Default gateway: This is a predetermined port that the computer sends packets to so they can travel outside the network.
- DNS Servers: These are the Domain Name Servers that the machine queries in order to know which IP address corresponds to which server or vice versa.
- Domain Name: This is basically the organisation’s complete domain name, also known as the FQDN (Fully Qualified Domain Name), or in other words, the name plus the extension, such as “jotelulu.com”.
- WINS Address: IP address of the WINS servers that the client will query for the resolution of NetBIOS names.
There may also be other less common parameters involved, but we won’t cover them in this article.
How is an IP address allocated?
Below, we are going to briefly illustrate how a request is made by a client machine and how the lease is made by the server.
First, a client connected to the network needs to be allocated an IP address. So, it sends a DHCPDISCOVER packet. However, since the client does not know the address of the DHCP server, it sends the packet to the address 255.255.255.255 (a broadcast address that routes the packet to all addresses on the network) with the source address 0.0.0.0. This request is made without an allocated IP address and the computer is identified using the physical (MAC) address on its network card.
At this point, the DHCP server listening responds by sending a DHCPOFFER packet. This shows that the server is available and offers an IP address and other network parameters to the client machine. There could be potentially more than one server listening, and each one will launch its own DHCPOFFER.
Now, both the client and server have identified each other and the client sends a DHCPREQUEST packet. At this point, the client’s address remains 0.0.0.0 because it still has not received a lease from the server. When it launches this request, it is directed at a specific DHCP server, so all the others are no longer involved and free up the address they had reserved for the client.
The server responds to the DHCPREQUEST with a DHCPACK packet (Acknowledgement). This ends the process by providing the required information, i.e., the IP address, subnet mask, default gateway, DNS servers, etc. The client is now able to operate on the network.
Below, you can see an illustration of the entire process with all flows of communication.
When the client wants to disconnect from the network, free up the IP address or decline the lease, etc., it sends either a DHCPDECLINE or DHCPRELEASE packet.
It’s important to remember that the lease is only valid for a certain period of time. Once this time has elapsed, the client will have to send a request to renew the lease. This process is normally triggered when 50% of the lease period has passed.
Once the client machine sees that the lease period has run out, it sends a DHCPREQUEST packet to tell the server that it wants to renew the lease. In principle, the server should respond with a DHCPACK packet as before, but if this doesn’t happen, the client will send another request once 87.5% of the lease period has elapsed. If it still doesn’t receive a response, it will send another DHCPDISCOVER packet to find another DHCP server.
If you would like to find out more about this process, check out the page titled DHCP (Dynamic Host Configuration Protocol) Basics on Microsoft Learn.
Typical Problems with DHCP
DHCP isn’t perfect and can suffer problems sometimes. Even if you might be using the service correctly, you might still find the occasional mistake or setting that needs changing on the server.
Typical problems for the client machine
With respect to the client machine, it’s possible for a registration error to occur. If this happens, it might be necessary to send the commands again to allow the client machine to register on the server.
The two commands used to solve this problem are:
- ipconfig /release: If using the IPv4 protocol, this command manually releases the allocated IP address from the specified network card or from all of them if none is specified. This sends a DHCPRELEASE packet to the DHCP server. If using IPv6, the command is “ipconfig /release6”.
- ipconfig /renew: This command sends a request to renew the IP lease when using IPv4. It will apply to all network interfaces if none is specified. If using IPv6, the command is “ipconfig /renew6”.
Releasing the allocated IP address from the Windows client
Another typical problem that can occur is that the client makes a DHCP request but, for some reason, does not receive a lease. In this case, the system will assign an APIPA address (Automatic Private Internet Protocol Addressing), which consists of an address reserved on the address space 169.254.x.x (169.254.0.0 – 169.254.255.255).
This problem is normally resolved by resending the commands to force a new request. However, in this situation, we highly recommend checking the physical connection to the network first.
Typical problems for the server
It’s also possible to encounter problems on the server side, and these are normally caused by small configuration errors or server uptime issues.
Most DHCP server issues encountered in the Microsoft world are caused by time-out issues where the server stops responding and will need restarting.
The same thing can happen with the DHCP service itself, and this may also need restarting.
As a result, it is generally good practice to have more than one DHCP server on the network in case one fails. If you have just one and it goes offline, no new IP addresses will be allocated, which could be a serious problem depending on your infrastructure.
Let’s take the example of a DHCP server allocating IP addresses in a hotel. If the server goes offline, any customers trying to connect to the hotel Wi-Fi will not receive an IP address and won’t be able to connect to the internet, check their e-mail or enjoy a video call with their families.
Therefore, the best solution is to have a DHCP cluster in which there is more than one server. All clients then point to a VIP address (a unique address for the cluster) and if a server fails, another one will simply take over.
Another problem can be the lease period given to client machines. This particularly tends to happen on Microsoft DHCP servers because the default lease period is 8 days and this is not ideal for all situations. It’s important to remember that the IP address space is finite and there are 254 leases to distribute on the network. If a lease is assigned to a client, it won’t become free again until the lease period has passed, unless it is freed up manually by the client.
For example, at a company with several workstations connected to the network, such a long lease period might not pose much of an issue because the devices connected to the network will probably not change very often. However, if we think of the previous example in the hotel, leasing IP addresses for 8 days is a very bad idea if customers usually only stay for one night. Once they’ve left the hotel, the IP address will remain assigned for another 7 days!
Conclusion
In this article, we’ve seen that DHCP (Dynamic Host Configuration Protocol) is one of the basic services involved used by all business or home networks with a large number of hosts or that need flexibility regarding connected machines.
The way it works is fairly simple, configuration for client machines is very easy and server configuration is quite straightforward. Furthermore, it saves a lot of time for the network administrator compared to manually assigning fixed IP addresses.
The protocol isn’t perfect and can sometimes run into problems, but most of the time, they can be easily fixed.
We hope that you’ve found this article useful. If you’d like to continue reading about this topic, check out some of the other articles on our blog, such as What to Do When the DNS Server Does Not Respond.
Thanks for reading!