Menu

#5225 Improvement suggestion to DHCP Leases page

1.900
open
nobody
improvement (1)
4
2019-01-07
2018-12-20
No

I've just started using DHCP module in Webmin 1.900 and noticed a quirk in DHCP - List Active Leases page: it shows are a lot of "duplicate" records that made me suspect something was wrong in my DHCP server configuration (see attached screenshot).

It tooks sometime to me to find that this is a "normal" behavior of ISC-DHCP (further info in second paragraph under Format topic here: https://linux.die.net/man/5/dhcpd.leases).
Leases file is like a log-file, so it's acceptable that a lease is "overwritten" by a newer one to the same ClientID / IP.
Since my DHCP server was just installed, I've set it to 1 hour default lease time, and this made the effect much more noticeable.

That said I suggest Webmin should "filter out" those duplicate records and show only last lease for each ClientID. Full list should only appear when clicking "List all active and expired leases" button.

Thanks for your work
Claudio

1 Attachments

Discussion

  • Jamie Cameron

    Jamie Cameron - 2018-12-22

    Are these duplicate leases marked as expired in the UI, or have end times earlier than the current time? Webmin by default should already filter those out (unless you click the link to show all old leases).

     
  • Claudio Nicora

    Claudio Nicora - 2018-12-26

    What do you mean with "marked as expired"?
    That screenshot was taken on the default view (not the "show all" one) on 2018-12-20 12:16:52, so within the third lease time period on the sale MAC/IP.

    Sadly I've not made a copy of the dhcpd.leases file at that same moment.
    If needed will do it when I get back from holidays.

     
  • Jamie Cameron

    Jamie Cameron - 2018-12-28

    Sorry, by "marked as expired" I meant that the end date/time had already passed. It seems odd that DHCPd is issuing multiple overlapping leases for the same host and IP?

     
  • Claudio Nicora

    Claudio Nicora - 2018-12-28

    Sorry, by "marked as expired" I meant that the end date/time had already passed.

    Ok, got it.

    It seems odd that DHCPd is issuing multiple overlapping leases for the same host and IP?

    No it's not.
    As I said above (and I discovered myself a few days ago) dhcpd updates its leases database in a "rolling mode", meaning that it doesn't rewrite the whole file each time but it only appends new records at the end. At some time it does a batch-cleanup of all expired records.

    Now the interesting part: see the attached screenshot took at 2018-12-28 10:17 (local time).
    I've set a short (60 min) lease time to let the bug appear more frequently; the clients renews its lease after 50% of the lease time (30 min).
    It shows two leases for the same MAC and IP, but only one is actually expired.

    This is the relevant part of dhcp.leases file at that time:

    lease 10.0.0.69 {
      starts 5 2018/12/28 08:14:42;
      ends 5 2018/12/28 09:14:42;
      cltt 5 2018/12/28 08:14:42;
      binding state active;
      next binding state free;
      rewind binding state free;
      hardware ethernet aa:bb:cc:48:c4:ea;
      uid "\001\002\003\004\005\006";
      set ClientName = "MYPC195";
      set ClientDHCID = "1:aa:bb:cc:48:c4:ea";
      set noname = "dhcp-10-0-0-69";
      set vendor-class-identifier = "MSFT 5.0";
      set ClientIP = "10.0.0.69";
      client-hostname "MYPC195";
    }
    lease 10.0.0.69 {
      starts 5 2018/12/28 08:44:42;
      ends 5 2018/12/28 09:44:42;
      cltt 5 2018/12/28 08:44:42;
      binding state active;
      next binding state free;
      rewind binding state free;
      hardware ethernet aa:bb:cc:48:c4:ea;
      uid "\001\002\003\004\005\006";
      set ClientName = "MYPC195";
      set ClientDHCID = "1:aa:bb:cc:48:c4:ea";
      set noname = "dhcp-10-0-0-69";
      set vendor-class-identifier = "MSFT 5.0";
      set ClientIP = "10.0.0.69";
      client-hostname "MYPC195";
    }
    lease 10.0.0.69 {
      starts 5 2018/12/28 09:14:42;
      ends 5 2018/12/28 10:14:42;
      cltt 5 2018/12/28 09:14:42;
      binding state active;
      next binding state free;
      rewind binding state free;
      hardware ethernet aa:bb:cc:48:c4:ea;
      uid "\001\002\003\004\005\006";
      set ClientName = "MYPC195";
      set ClientDHCID = "1:aa:bb:cc:48:c4:ea";
      set noname = "dhcp-10-0-0-69";
      set vendor-class-identifier = "MSFT 5.0";
      set ClientIP = "10.0.0.69";
      client-hostname "MYPC195";
    }
    

    As you can see there are 3 leases for that client, but only the last 2 are shown by Webmin.
    This means that filter is working but it does not filter out all expired records.

    Could it be something related to GMT/Local time?
    I'm on GMT+1 here, so I've tried switching the Webmin module option "Display leases times in" from "Local time" to "GMT" but it only changed the item times and not the filter content.

     

    Last edit: Claudio Nicora 2018-12-28
  • Jamie Cameron

    Jamie Cameron - 2018-12-29

    Ok, I see the cause now (I think). Those last two leases overlap in time, so there can be a time at which they are both valid.

    Try this Webmin patch, which should fix it : https://github.com/webmin/webmin/commit/3c2be83ea036f28d3d3d08e2f8326c62b1e42a78

     
  • Claudio Nicora

    Claudio Nicora - 2018-12-29

    Will check it as soon as I get back to the office.
    Thanks for it ;)

     

    Last edit: Claudio Nicora 2018-12-29
  • Claudio Nicora

    Claudio Nicora - 2019-01-07

    The patch works perfectly, well done 😉.
    Thanks for it.

     

Log in to post a comment.