The DHCP server has changed the lives of all administrator forever. It has given them the commodity of automatic IP assignment. After the introduction of DHCP, there was no need for some IT specialists to spend countless hours providing IPs for every device connected to the network device. But how exactly does DHCP work? Let’s find out!
What is DHCP and DHCP server?
DHCP – Dynamic Host Configuration Protocol is a network management protocol that we use on TCP/IP network. The DHCP server, automatically assigns IP addresses and other network configurations like subnet mask, default gateway, DNS server, and more to the connected devices so they can exchange information. DHCP let the hosts get the necessary TCP/IP configuration data from the DHCP server.
Using this protocol, the network administrators, don’t need to set a static IP for each device, and later reassign it to another and keep an eye on all the available IPs. They will just set up the DHCP server with all the additional network information, and it will do its work dynamically.
Why is DHCP important?
DHCP is important because it makes it really easy for network administrators to provide IP addresses to client devices on the network. It manages the pool of IP addresses automatically.
The client also does not need to do anything at all. The newly connected device will automatically ask for an IP address and get it. The person behind the device does not need to make any configurations.
Every device on a network needs the address as identification. And two devices can’t have the same IP because this will make them both unusable.
Components of DHCP
- DHCP server. The server device is in charge of answering an IP address request, provide an available IP address, store it for the time of the lease and renew it later. It will handle the communication with all the client devices. The server could be a computer or a part of the router.
- DHCP client. It must be present on the client devices (computer, mobile, IoT device, etc.). It will request an IP address and communicate with the DHCP server to get it with the rest of the data and confirm the process.
- DHCP scope. This is the range of IP addresses that the DHCP server can offer to the DHCP clients. Usually, the server will auto-assign addresses, starting from the smallest number, and going to the highest.
- Subnet. If the network is divided into pieces, there will be so-called subnets.
Lease. That is the time period that indicates how long a client can use the assigned IP address before it expires.
- DHCP relay. The relay is in charge of communication between the DHCP server and the client. It will listen for messages and pass them to the right place.
IP address allocation mechanisms of DHCP
There are three ways that you can configure the DHCP server:
- Automatic allocation. This one will automatically assign an IP per client permanently. The IP address will be designated for just one device, so if, in the future, many new devices get connected, the server could run out of IP addresses to give.
- Dynamic allocation. This is the most common configuration. The server auto-assigns IP addresses to clients, but there is a time period. After the time expires, the client needs to ask for a new IP address again. This will prevent the running out of IPs.
- Manual allocation. Manually the network administrator will assign the IP address to the client.
How does DHCP work?
Imagine we have a network of connected devices and a DHCP server that manages the IP addresses.
Step 1: DHCP Discover
When you connect a new device, it still does not have an IP address. It will search for an IP address. It will call over the network for a DHCP server. This request will arrive to all of the devices, and the server will also get it.
Step 2 DHCP Offer
The DHCP hears the call, and answer with an IP address, that it offers it to the newly connected device.
Step 3 DHCP Request
The IP address arrives to the device. The device will accept it and will send a request to use it.
Step 4 DHCP Pack
The server gets the accepting message from the device. It will provide the IP address to the device, together with the subnet mask and the DNS server. It will write a record with the information of the newly connected device that usually includes the MAC address of the connected device, the IP address that was assigned, and the expiration date of that IP address. The DHCP leases the IP address for a limited time only. After the time passes, the IP address will go back to the IP pool of available IP addresses and can be assigned to a new device again.
The UDP port for the communications is usually port 68 for clients and port 67 for servers. There might be some differences, depending on the vendors of network equipment, but this is how it functions in general.
Benefits of DHCP
IP address configuration on which you can rely
DHCP makes very few errors regarding the IP address configuration. There might be some occasional errors related to the network typographic and IP conflicts when the DHCP server assigns the same IP to different devices.
Less work for the network administrators
There are few features that admins really like about it because it makes their job easier.
You can automate the TCP/IP configuration. This can be done from one central location, without the need to move to different devices.
Additional options. It can change various additional network settings.
DHCP handles IP address changes for some users, like the laptop owners. They need to connect and disconnect more often than a desktop PC. This is not a problem for the protocol.
Disadvantages of DHCP
The DHCP server doesn’t require authentication when providing a lease. That way, if there is not a firewall working, someone can get the data from the network.
Rogue DHCP server. If such a server gets connected to the network, it can start assigning IPs to the devices. These devices will share data with it, and their information can be seen by the server. It means that hackers can steal the data that way.
Now and then, there comes a technology that makes our lives easier. Maybe it is not so visible, and just a few people know that it exists, but the DHCP deserves our “thank you.”
It has its downsides, but the time it saves is far more valuable.
Hi, I’m Martin Pramatarov. I have two degrees, a Technician of Computer Networks and an MBA (Master of Business Administration). My passion is storytelling, but I can’t hide my nerdish side too. I never forgot my interest in the Hi-tech world. I have 10 years and thousands of articles written about DNS, cloud services, hosting, domain names, cryptocurrencies, hardware, software, AI, and everything in between. I have seen the Digital revolution, the Big migration to the cloud, and I am eager to write about all the exciting new tech trends in the following years. AI and Big Data are here already, and they will completely change the world!
I hope you enjoy my articles and the excellent services of ClouDNS!