What is DHCP, and how does it work?
Assigning IP addresses is not an easy task, and a human admin might get confused in the process. This confusion would result in the loss of an internet connection for someone. But the DHCP comes to the rescue in this case.
What is the DHCP?
DHCP (or Dynamic Host Configuration Protocol) is a network management protocol that automatically assigns IP addresses and other communication parameters to devices connected to a network. For example, a router usually acts as a DHCP server in most home networks. It assigns IP addresses to your devices. Implementing this protocol saves time and prevents human errors.
The DHCP (Dynamic Host Configuration Protocol) automatically allocates IP addresses to devices and provides other related configuration information, such as subnet masks and default gateways. If it didn’t exist, the addresses would have to be input manually, which would be inefficient, time-consuming, and error prone.
How does DHCP work?
When a device joins a network, it requests an IP address. The request travels to a DHCP server. A server assigns an address, monitors its usage, and takes it back after the device is shut down. The same IP address can now be reassigned to another device. A device can use this address to communicate with internal and public networks.
DHCP networking functionality
Dynamic Host Configuration Protocol servers provide parameters, also known as DHCP options. They describe various factors of IP addresses — for example, how long they can be used. DHCP options usually define:
Default gateway
A default gateway that routes data back and forth between the local network and the internet.
Subnet mask
A subnet mask that separates host addresses and network addresses within an IP address.
DNS server
A DNS server that translates the names of IP addresses into the ones we remember.
DHCP has three methods of IP address allocation:
- Dynamic allocation. Dynamic allocation takes place when an admin reserves IP addresses for DHCP. Then each DHCP client on the local network requests an IP from the DHCP server during the network initialization phase. The whole process takes place during a controllable amount of time that allows a DHCP server to reclaim and reallocate an unused IP address.
- Automatic allocation. A DHCP server permanently allocates an IP address to a client under the rules set by an administrator. It differs from dynamic allocation because a DHCP server has the data of the previous IP assignment and can reassign the same IP to the same client.
- Manual allocation. In this case, an administrator manually assigns a unique identifier for each client to an IP address. A DHCP server is usually configured to switch to another method if manual allocation fails.
DHCP components
A functioning DHCP system only needs two components: the server and the client. The DHCP clients are whatever device is connected to the server. The DHCP server allocates IP addresses accordingly to each device.
DHCP pros and cons
DHCP servers are incredibly useful in the right environment. However, DHCP servers have some drawbacks that need to be considered before you decide to utilize them fully.
Here are the pros of using DHCP servers:
- Reliable IP address configuration. DHCP helps to prevent conflict between two users with the same IP address. Such conflict would block both users from connecting to the internet. DHCP resolves such conflicts automatically without the possibility of human error.
- Mobility. DHCP also ensures mobility. Users can use their mobile devices anywhere within the range of their network.
- More efficient network administration. DHCP centralizes the whole IP configuration, and separate IP-assigning servers are not needed.
- Flexibility of IP schemes. DHCP makes changes of IP address schemes easier and without disruptions to end users.
Here are the cons of using DHCP servers:
- DHCP servers are a single point of failure. If only one DHCP server is in use and it goes down, clients won’t be able to renew any leases.
- Incorrect information has to be manually configured. If a DHCP server delivers incorrect information to all the connected clients, you will have to attend to each device individually to reconfigure the mistake.
DHCP vs Static IP
A device with a static IP will retain the same IP address. Network admins have to record all static IP addresses to guarantee they aren’t reused. DHCP servers forgo the manual allocation of IP addresses, saving admins a lot of time. Setting up a static IP address is more expensive than leasing a DHCP server.
Most VPN services will use static IP addresses because it’s easier to connect to an online service when an IP address doesn’t change. Static IP addresses are typically reserved for setting up VPN servers, web or home servers, or enabling a user to access a home computer remotely.
The static IP address means routers will always remember that the server is on the network. If the IP address dynamically changes, it adds more work for the network admin. When it comes to allocating IP addresses for a large number of internet of things devices, a DHCP server is the better choice.
Controlling DHCP lease times
When it comes to DHCP servers, lease times refer to how long a device retains an IP address allocated by the server. The default lease time is typically 24 hours. However, you can configure the lease time to be shorter or longer.
Beware of setting a lease time too short, however, as it could cause disruption across the network.
DHCP security concerns
DHCP doesn’t have any authentication, so it is vulnerable to cyberattacks. DHCP can be exploited in the following ways:
- Unauthorized DHCP servers can provide false information to clients.
- Unauthorized clients can also intercept DHCP servers and obtain access to resources.
- Malicious clients can also exhaust DHCP resources.
All these issues can result in DDoS and man-in-the-middle attacks. However, admins can reduce the risk by using the relay agent information option and tagging DHCP messages when they arrive. They can also use network access control to protect DHCP.
Want to read more like this?
Get the latest news and tips from NordVPN.