Ip address leases table

Hi, question:

My ip address lease table is getting seriously long, and filled with expired leases that are crossed out. On itself this isn’t an actual problem, but it’s not easy to get an overview of the active leases, you have to “see trough” all of the crossed out lines to get all the active ones.

Is there a way to clear out all the stale ones? At the end of the line there’s only the “add” button, to add this IP to the reservations.

Thanks!

Network > DHCP Server

You can sort your list by clicking on any of those headers. Click on IP address and the list is sorted by ip numerically. Click on Lease expired and you get the active leases first, the crossed-out lines follow.

I’ve requested time ago for the crossed-out lines not to be shown but did not hear back.

Yeah, that’s the way I do it now, but it won’t remember this setting, so you have to sort them each time…

Oh well maybe it gets fixed sometime…

The inactive leases carry some information, because dhcpd tries to reuse expired relations MAC<->IP. Thus the expired leases give a clue, which IP a device identified by the MAC will get at a reconnect.

Bernhard,
Let dhcpd keep that relation mac<->ip but I would like not to be shown on screen. Looking at a screen of 100+ hosts gets a bit difficult with the crossed-out lines. It is more of a usability issue.

Indeed, they don’t need to be remove from the database, just hidden from view. That way, they can still be used if needed, but don’t cluuter the view. I have leases in this list from 2015! That’s absoluletly not relevant anymore :slight_smile:

1 Like

The size of the list is related to the size of set of dynamic leases.
My table has four entries only ( the size of the dynamic pool ). In my system all devices are well-known and thus have a fixed lease in dhcp. The dynamic pool is reserved for possible new clients.

I’ve edited 2 files manually, changed a little bit of code and now I get the results I want, only the not expired leases :slight_smile:

Sad part is, that when an update comes and overwrites these files, I can do it again…

2 files are dhcp.cgi & header.pl

Dirk … can you share the changes your did?

I’ll try. Please do make a backup of each file before making changes, so if it fails, you can easily revert back tot the situation before :slight_smile:

first file is the wireless.cgi file, that is found in /srv/web/ipfire/cgi-bin

In that file, do a search for the line

foreach my $key (sort blueleasesort keys %entries) {

Right after that line, add the following:

if ($entries{$key}->{ENDTIME} > time() ){

Then scroll down a bit untill you find $id++; Right above that rule, add a closing curly bracket }, so it will look like this

END
;
} # <— CHANGE MADE
$id++;
}

This part above will now show only the active leases in the wireless clients page (blue access) For the dhcp settings page, things get a bit strange, because you should expect it to be the dhcp.cgi file, that needs the other changes, but after a lot of searching I found the header.pl file, located in the /var/ipfire/ folder.

In this file, it’s a bit of a repeat of what to do as in the previous file, except for the first searchstring

foreach my $key (sort leasesort keys %entries) { (previous file had 'blueleasesort ’ instead of ''leasesort)

The rest of the info is the same, search for the $id++ line and add the same before as with the other file…

No restart of ipfire is needed, just rfreshing the page is enough.

Hope this works, here it does without problem (maybe untill the next softwareupdate)

Hi,

could you please file a patch containing this and send it to the development mailing list? That way, all IPFire users will benefit from your work. :slight_smile:

Please refer to https://wiki.ipfire.org/devel for further information regarding development of IPFire. You can subscribe to the development mailing list at https://lists.ipfire.org/mailman/listinfo/development.

Thanks, and best regards,
Peter Müller

I’d like to see this patch taken one step further. Add a checkbox to filter or not the expired leases.

Hi,

as mentioned you guys are most welcome to submit patches. :wink:

Let me know if there are any problems.

Thanks, and best regards,
Peter Müller

1 Like

In both source files, it is easier not to add the record into the %entries hash if ENDTIME is less then time.

In /var/ipfire/header.pl, line 528, replace the line

$entries{record->{‘IPADDR’}} = $record;

with

$entries{record->{‘IPADDR’}} = $record unless $record->{‘ENDTIME’} < time();

Same change to be applied in /srv/web/ipfire/cgi-bin/wireless.cgi, line 523 for the blue interface.

Any suggestion, where to place this checkbox?

Hi @ganymed,

Welcome to the IPFire Community.

It’s great to see that you are working on a patch for this. Regarding where to place the checkbox my thought would be to see how checkboxes are used generally in the WUI and follow a similar approach with something that looks right for the IPFire layout.

It is easier for the devs to review a patch with a concrete proposal. They are a small group of people and have a lot to focus on with the core programs. They will be more than happy to get your proposal and will provide feedback if they believe it needs any modification or tuning.

I can vouch personally for the warm welcome I have been given in getting involved.

1 Like