DEV Community

Achraf Affes
Achraf Affes

Posted on

DHCP and static IPs ??

I'm not gonna talk about how does a DHCP server work exactly,
this Post is destined for those who understands that already but still got some dark spots with their knowledge about the topic,
this is simply an explanation for the famous problem :

If one of the devices in the network is configured with a static IP address, when the DHCP server starts distributing the IP addresses to other machines, what happens exactly ? does it skip it ? or does it duplicate it and therefore there would be a conflict ?

So the answer is, NOPE the DHCP server will not distribute that IP address, you may be wondering, but how ?

Remember that the DHCP server sends an ARP Broadcast asking about the IP address about to be distributed

"Who has x.x.x.x"

At that moment the machine with that static IP address will respond with an ARP saying that it got that IP and that its MAC address is X:X:X:X:X:X so the DHCP server will continue to the next IP address asking "Who has y.y.y.y"
and therefore there will be no duplication.

But here comes another problem,

what if the local network is placed behind a router, and we all know that the routers doesn't allow broadcasting, then what happens ?

well simply instead of ARP Broadcasting, it uses ICMP Packet type 8 code 0 which is the ECHO request ( ping ) and if it gets no answer than it distributes it, else it simply continues to the next IP address.

And here comes the last question,

And what if a device that is configured with a static IP address was shutdown, and the DHCP distributed its IP address, what happens if the machine is up again?

well there are two solutions for this, some DHCP servers are advanced enough and caches the static IP address and therefore this conflict will never occurs, but if the DHCP server doesn't provide this feature, than it should be configured to exclude these IP addresses or else there will be an IP Duplication.

And this pretty much sums up the main problems of dealing with a DHCP server.

Top comments (0)