Troubleshooting DHCP issues

If for some reason you have a machine that refuses to obtain an IP address, then this section is for you. DHCP issues aren't incredibly common, and thankfully aren't too hard to troubleshoot.

One of the most common issues I've seen with DHCP servers is the date and time of either the server or the client being wrong. In the Linux world, NTP is crucial and should always be working. In the case of DHCP, it only waits so long before the service times out a request for an IP address. If the clock is off by an hour and the incoming request is timestamped an hour ago, that confuses the server and the client will not receive an address. Always ensure that NTP is working on all your clients and servers. DHCP isn't the only service that would suffer with incorrect time on either end. Lot's of strange things can happen in this situation.

A reason for failure is the lack of available IP addresses. This may sound obvious, but you'd be surprised how often this happens. Even a /24 network of 254 available IP addresses can become saturated quickly these days, as everything from mobile devices to refrigerators (yes, refrigerators) want to claim an IP address these days. It's not uncommon for the average person to use three IP addresses without even noticing. A problem such as this can become increasingly annoying if you set your DHCP lease time to something greater than a day. In most cases, a lease time of 24 hours is adequate for most networks. Devices that need access will renew their lease when the time comes, while temporary devices won't attempt to renew the IP they were issued, which will cause it return to the pool.

I wish that I had a magic command you could run that would give you a printout of just how many IP addresses you have available. Unfortunately, I've never been able to find one, aside from possibly constructing a cumbersome Bash or Python script. The best thing for you to do while experiencing any issues with DHCP is to watch the log file and have the client try to connect again.

Troubleshooting DHCP issues

The output of a working DHCP server

In Debian, you can investigate by running cat /var/log/syslog |grep dhcp for messages relating to your DHCP server. On CentOS, you can use journalctl -u dhcpd to view these messages. What's better is to follow these logs in real time as the client tries to connect, so you can see the output as it happens. To do this, use tail -f /var/log/syslog in Debian or journalctl -f -u dhcpd in CentOS. Errors from your DHCP server should be fairly easy to follow, as the server is usually specific regarding what it is doing. You'll likely see it offer addresses to the client, or complain that there aren't enough IP addresses available. If you see the server offer an IP address to the client but the client never seems to finish the connection, then definitely check your NTP server on the client.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset