My company produces IoT devices attached via USB, which contain a cell modem module, which contains a DHCP server. We have a production testing server running Ubuntu 14.04 and another server running Ubuntu 16.04. When the IoT device's cell modem is powered on, the server's dhclient obtains an IP address from the DHCP server embedded in the cell modem module.

Yesterday the 14.04 server ran out of inodes because there were 6.6 million dhclient-<uuid>-usbXX.lease files in /var/lib/NetworkManager/.

I wasn't able to fully examine the system due to needing to get it running for production purposes, but, it looked like these lease files dated all the way back to the server commissioning about 14 months ago. That is, it appears that NetworkManager and/or dhclient (from package isc-dhcp-client) have never removed any of the client lease files.

Compounding the problem is that it appears that there is a new lease file created every time the cell modem device is powered on. (The IoT device keeps the cell modem powered off to save battery power, turning it on only when needed. Testing includes powering the modem on and off a number of times.)

I sudo apt-get source isc-dhcp-client and checked the source, and it doesn't appear that there is code to remove lease files, ever. Indeed, my laptop (Ubuntu 14.04) has lease files going back to its commissioning. (I've had some of our IoT devices attached, as well as various other ethernet-USB adapters.)

The lease files have a very reasonable 24 hour expiry.

I am investigating how to deconfigure dhclient against our IoT devices, but, I'd rather not do that in case we decide to do testing of the cell data connection.

Is there a way to get dhclient and/or NetworkManager to remove old client lease files?

I could set up a cron job to handle this, but it seems like the sort of thing that should be part of the system. I just can't find it. I googled, searched here/StackOverflow, and read the dhclient and NetworkManager documentation.

NOTE: I don't have enough reputation to create the tag dhclient, so I've substituted dhcp instead.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy