Trouble understanding DHCP (Dynamic Host Configuration Protocol), Learn it in under 5 mins

If you are into computer networks or using internet, somewhere, somehow you must have stumbled across DHCP, it is used everywhere on a computer network and the internet. If you use a smartphone, which 3G or even 2G, you unknowingly, use DHCP

dhcp what how dhcp server messages logo

What is DHCP?

In Layman’s terms, When a computer comes online on a network, it requires and IP (unique identification number) address, saving an IP specific computer even when it is not online is infeasible, what we can do is, dynamically assign it IP from a Pool of IPs available when it requires, or when it comes online.

The Job of Dynamic Host configuration Protocol, is just that.

Firstly you may enquire how can a client find a DHCP Server, which assigns it an IP

When a computer boots up and has no static IP address set, it will “look up” for an IP-Address.
The computer will try to discover a DHCP Server on the local subnet (DHCPDISCOVER) via broadcast message.

What Broadcast-IP Address will the computer use for that? the last available host IP on the network) NOT AT ALL! 

Come on, the Computer Just came online, how has it to know that, it is where the DHCP server resides or what the networks or the subnet is like, on the local network,  hence the computer would not know what is the Broadcast-IP of that network!

The computer will send out DHCP Discover packets via broadcast to the address (or in hex FF-FF-FF-FF-FF-FF).
This will cause the Broadcast to reach ALL devices in the local network.

If there is a DHCP server on the local network, It may answer with a DHCP Reply and offer an free and valid IP-Address to the client.
But the DHCP Server can do much more than it, come on it’s a Server and as we say, with great power comes great responsibilities — it will offer the whole network configuration to the client if configured – incl. DNS-Server IPs, WINS-Server IPs, DHCP Lease Time, Default Gateway – and (if configured and needed) also several other options, depending on the GOAL and NEED.

DHCP is very powerful, you can also use vendor classes and / or user classes to configure some special attributes needed for any purpose.
With user classes you can give a command on a client computer and according to that command the DHCP Server will provide “special configuration” to all clients which have this command set as they will send special request attributes to the DHCP Server in the DHCP discover packets.

Okay so, What Ports does DHCP use?

DHCP Server “listens” on UDP Port 67.
DHCP client receives DHCP offers on Port UDP 68. 

User Datagram Protocol, hence the transfer is quick and light, but may have some errors, losses and duplication, there are no handshaking as well, like in TCP

So, source port of the DHCP DISCOVER is UDP68 (Client), and destination Port is UDP 67 (DHCP Server Listener Port).
The DHCP answers to the discover with source port UDP 67 (DHCP Server) and destination Port UDP 68 (Client).

What are the various DHCP Messages that exist


Client sends DHCP discover packets into the local subnet to ask ANYONE on the local subnet for an IP-address.
The DHCP Server “offers” an IP and some other configurations to requesting clients.

The client – after it has received a valid IP-address from a DHCP server – sends DHCPREQUEST as a broadcast to the local subnet to “inform” eventually other existing DHCP servers that it has an IP and it does not need another IP, they are very self satisfied at it 😉. The DHCPREQUEST contains the IP of the DHCP server which provided a IP to the client.
These other DHCP Servers will withdraw any offers that they might have made to the client.

Finally, the DHCP server which provided an IP to the client will provide some additional information to the client, if configured, for example lease time etc.


But, What if there are more than one DHCP Servers on a local network?

Okay, now what if there is ANOTHER DHCP Server in the local network?
How does our Client know the RIGHT and legitimate DHCP Server?

Well – the Client will take ANY DHCP offer it gets! So if you have 3 DHCP Servers in your local LAN, the FIRST DHCP (or the fastest..) will be the one which will give an IP Address to the client.

So it could  seriously disturb a network if there are “illegal” DHCP Servers

To prevent “illegal” DHCP servers from disturbing the network, there are several techniques.

1. configure DHCP Snooping on the switches to allow DHCP offers ONLY on configured and allowed uplink ports
2. use DHCP classes (user class or vendor class) so that only DHCP offers which fit to the class and configuration will be accepted by the client
3. If you find a user which provides illegal DHCP services, nail him on a cross so that the other users are warned!! well, not literally


What if the DHCP Server is located on another subnetwork?

OOPS,  As clients use broadcasts to get a IP from DHCP Server – and broadcasts are NOT forwarded by routers normally, how can the client get an IP from DHCP server?
Well, thats what “DHCP Relay Agents” are designed for.

A DHCP Relay Agent is a device on the local subnet, which “collects” DHCP discover broadcasts, and encapsulates them in a unicast message which can be forwarded to the DHCP Server in another subnet.
We can also use so called “IP helpers” on CISCO devices, that has similar function to a DHCP relay agent.


What if the DHCP Server is unreachable?

All the clients which did get a IP-Address from the DHCP Server when it was reachable, will still be able to communicate with other devices.
When the HALF DHCP Lease Time is over, a client contacts again DHCP Server to renew the lease. If the DHCP Server is not reachable, the client will hold the given IP till the lease time is over.

When the DHCP Lease Time on the Client expires – then its FINITO!, world come to an End, The client loses its IP configuration.
Windows PCs have a feature called APIPA (Automatic private IP Address).
When a Windows Client can not get an IP from a DHCP Server, the OS provides the client with an IP from the Microsoft-IP Range 169.254.X.X

The windows clients on the network “negotiate” with each others so that no other computer on the local subnet gets the same IP of this 169.254.X.X range.

So the windows clients will still be able to communicate – but only with other clients in the local subnet, which also did get automatically a ip from the 169.254.X.X range.


How to configure redundant DHCP Service on the LAN?

Nothing in life is simpler than this!
Install and configure your DHCP Server. When its ready – just duplicate the DHCP Server.
You only have to “split” the DHCP Scope Ranges so that both DHCP Servers can not offer the SAME IP-Address to different clients, otherwise you wil get IP conflicts!

So, take for example, first DHCP could provide IP Range –
and the second DHCP could provide IP Range – to the clients.


We hope you’ve understood DHCP for lifetime, if you, please comment below and like our Fan page for more such simplified tutorials

If you still have any queries about DHCP or anything related to CCNA and CCNP, feel free to revert us, or send us an email on [email protected]


The DNetWorks Team