DHCP
DHCP stands for Dynamic Host Configuration Protocol. It is a network protocol that lets devices on a network get an IP address automatically. Clients can obtain other key network settings too. These include the subnet mask. They also cover the default gateway. DNS servers come into play as well. This whole automatic process cuts out the hassle of setting things up by hand. It makes sure addresses stay unique. Devices end up communicating smoothly across the network.
In today's networks, DHCP plays a big role. You see it in homes just as much as in big enterprise setups. The reason is simple. It streamlines how you manage the network. IP conflicts get avoided pretty much entirely. Mobile devices connect without any real effort.
DHCP works through a client server setup. The server handles a pool of available IP addresses. It leases them out to clients as needed. The way it assigns IPs follows what people call the DORA handshake. That process breaks down into four main steps.
1. Discover (DHCP Discover)
A client joins the network without an IP address yet. It sends out a broadcast message called DHCP Discover. This goes to find any available DHCP servers around. The message includes the client's MAC address. That helps identify it uniquely.
2. Offer (DHCP Offer)
Next is the offer stage. The DHCP server picks up on the discover and replies with a DHCP Offer. Inside that offer, you find a proposed IP address. It lists the subnet mask too. The default gateway gets included. DNS servers show up in there. Lease duration tells how long the IP stays valid.
Sometimes multiple servers might send offers. The client typically goes with the first one that looks good.
3. Request (DHCP Request)
Then the client makes a request. It sends back a DHCP Request message. This confirms it wants to use the offered IP. The server notes that IP as taken now. This stops any conflicts with other devices trying to grab it.
4. Acknowledge (DHCP ACK)
Finally, acknowledgment wraps it up. The server transmits a DHCP ACK message. That confirms the whole assignment is set. The client then sets up its network interface. It uses the IP and all the parameters provided.
Example DORA Handshake
Laptop joins network → broadcasts DHCP Discover.
DHCP server replies with Offer: 192.168.1.105, subnet 255.255.255.0, gateway 192.168.1.1, DNS 8.8.8.8.
Laptop sends Request → requesting to use 192.168.1.105.
Server sends ACK → Laptop configures its interface and can communicate.
This example illustrates automatic IP assignment, avoiding manual errors and conflicts.
IP Assignment Methods
DHCP can assign IP addresses in three main ways:
Automatic allocation
IP is permanently assigned from the server’s pool when the client first connects. The same IP is reused on future connections.
Devices that rarely move between networks but don’t require manual static configuration.
Dynamic allocation
IP is temporarily assigned for a lease period. After expiration, it can be reassigned.
Laptops, smartphones, mobile devices.
Static allocation (reservation)
The server always assigns the same IP based on the client’s MAC address.
Servers, printers, network infrastructure devices requiring a fixed IP.
DHCP Lease
A DHCP lease sets the length of time that a client device holds onto an IP address before it has to give it back. The server decides on that lease duration, and it could be something like 24 hours or as long as seven days depending on the setup. Renewal kicks in when the client reaches out to the server to stretch out the lease a bit more right before the original time runs down.
Clients also have the option to release the IP address early if they want, and that means running a command like ipconfig /release on Windows or dhclient -r over on Linux systems.
Example:
A laptop gets dynamic IP 192.168.1.105 for 24 hours.
After 12 hours, it automatically renews the lease.
After 24 hours, if disconnected, the IP may be reassigned to another device.
Static vs Dynamic IP
Assignment
Automatic via DHCP
Manual or reserved in DHCP
Changeable
Yes, after lease expiration
No
Ideal for
Laptops, smartphones, IoT
Servers, printers, firewalls
Configuration
Easy to manage
Requires manual setup or reservation
DHCP Scope and Pools
A DHCP scope defines the IP address range a server can assign and other configuration options.
Example Scope Configuration:
IP Range
192.168.1.50 – 192.168.1.200
Subnet Mask
255.255.255.0
Default Gateway
192.168.1.1
DNS Servers
8.8.8.8, 8.8.4.4
Lease Duration
24 hours
DHCP in Practice: Windows and Linux
Windows:
Linux:
DHCPv4 vs DHCPv6
DHCPv4 mainly works with IPv4 addresses that are 32-bit long. It remains widely used in most places right now.
DHCPv6 handles IPv6 addresses, which stretch to 128 bits. It brings in extra features that suit large-scale networks pretty well. Those include stateless address assignment along with automatic DNS configuration.
Last updated