The Internet Systems Consortium (ISC) DHCP server logs every client lease to a lease database. Being a text file, the database can be easily viewed but the contents can be cryptic and uncorrelated.
Fortunately for us, the Debian package which installs the server includes a Perl script titled dhcp-lease-list. The script’s function is to process the database records and present them in a more digestible way.
The script, however, does not work out of box. This post explains ways to make the script functional the way it was intended. Bear in mind there are no man pages although usage information is available from command line with the –help option.
Run the script for the first time and you’ll notice it aborts with two error messages. The first message implies that a certain file is missing while the second message tells us the database can not be opened.
root@dhcp-server~# /usr/sbin/dhcp-lease-list To get manufacturer names please download http://standards.ieee.org/regauth/oui/oui.txt to /usr/local/etc/oui.txt Cannot open /var/db/dhcpd.leases: No such file or directory at /usr/sbin/dhcp-lease-list line 69.
Let’s investigate the second message first. The default path, as set in the script and seen in the message, does not exist on Debian 8. Unless you specify the full path to the database, the script is unable to locate it.
root@dhcp-server:~# dhcp-lease-list --lease /var/lib/dhcp/dhcpd.leases MAC IP hostname valid until manufacturer =====================================================================
Provided there are active leases, the script displays one line of records for each MAC address. To view all the leases, including the expired ones, add the –all option. Note that the last column currently has no manufacturer to show.
Contrary to the rest of the output, the manufacturer name is extracted from a separate data file. Provided by the IEEE Registration Authority, oui.txt is basically a long list of OUIs and details of their registered vendors.
An OUI (Organisationally Unique Identifier) is an identifier for a particular networking equipment. In case of a network interface card, it forms the first half of its MAC address to identify its manufacturer.
Let’s download the file.
wget -O /usr/local/etc/oui.txt http://standards.ieee.org/regauth/oui/oui.txt
You should now be able to run the script error-free and see a full output. One thing worth remembering is that lease times normally are in Universal Coordinated Time (UTC).
Date: April 2017 Platform: Debian 8.7 Package: isc-dhcp-server 4.3.1-6+deb8u2