When network troubles arise, it is important to have knowledge of the protocols used for basic network services. System administrators are often the first to notice and triage network issues. Because of this it is imperative that you have a wide range of tools at your disposal. The most common network tools are ping, traceroute, and dig. With a working knowledge of these utilities you can quickly identify network related issues and therefore keep your services available. In this article we will discuss a less common utility called dhcping (dhcp - ping). This utility that allows you to send DHCPREQUEST or DHCPINFORM packets to a DHCP server to test if it is functioning or not.
DHCPing is available to most modern Linux systems.
To install it on a RPM based system like Red Hat or CentOS:
sudo yum install dhcping -y
Or Fedora (which now uses DNF):
sudo dnf install dhcping -y
To install DHCPING on Ubuntu or Debian based systems:
sudo apt-get install dhcping -y
Basic Usage of dhcping
It is important to understand that dhcping does not run through the whole D.O.R.A. process (Discovery, Offer, Request, Acknowledge - More information in the Resources section below). Because of this you will need to troubleshoot from a system that already has an IP address on the network.
To get started, we need some information. We will need at minimum, our IP address, our hardware/MAC address, and the IP of the DHCP server we want to test.
If you don't know how to find this information read:
Test the DHCP Server
Now that we have the necessary information, we can construct the command to test the DHCP server.
[[email protected] ~]$ sudo dhcping -c 10.0.0.2 -s 10.0.0.1 -h "34:e6:d7:0f:a9:83" Got answer from: 10.0.0.1
In the example above, we received "Got answer from: 10.0.0.1". This tells us that the DHCP server is working correctly and able to respond.
If the DHCP server did not respond, you would see "no answer" output to the terminal. Here is an example of the test failing:
[[email protected] ~]$ sudo dhcping -c 192.168.1.4 -s 192.168.1.1 -h "34:e6:d7:0f:a9:83" no answer
Although there isn't much to this utility, it does provide a few options. Here we will outline the most popular and how to use them.
Send DHCPINFORM instead of DHCPREQUEST
By default, dhcping sends a DHCPREQUEST packet. You can force it to use the DHCPINFORM packet by using the -i option.
$ sudo dhcping -i -c 192.168.1.4 -s 192.168.1.1 -h "34:e6:d7:0f:a9:83"
Quiet Mode, Print no Output
This option comes in handy if using it in scripts. Using the -q option will cause the command to NOT return any output.
$ sudo dhcping -q -c 10.0.0.2 -s 10.0.0.6 -h "34:e6:d7:0f:a9:83"
Set Maximum Wait Time
You can use the -t option to set the maximum time to wait in seconds. The default is 3.
$ sudo dhcping -t 8 -c 10.0.0.2 -s 10.0.0.6 -h "34:e6:d7:0f:a9:83"
For a full list of all options, see the dhcping man page.
The DHCPING utlity is a nice little utility that helps in checking if a DHCP server is still functioning as expected. Once you understand how it works, it is fairly simple to use and available on most Linux systems. It has come in handy for me more than once over the years, but it is definitely not something I use on a daily.
Resource and Links
This site uses Akismet to reduce spam. Learn how your comment data is processed.