list leases for isc-dhcp-server

tOsYZYny

Member

Reaction score: 3
Messages: 66

I would like to interactively look at the leases from my DHCP server just for auditing purposes. There is a post here:
https://forums.freebsd.org/threads/how-to-get-a-list-of-connected-clients-from-my-dhcp-server.33240/

However, it doesn't appear to be answered or answer my question.

I see the lease file here:
/var/db/dhcpd.leases
/var/db/dhcpd/dhcpd.leases

However, both contain just a header indicating the server-duid.

Is there an option that would prevent the server from writing the leases? I was also using this as a reference:
https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcpdconf
https://kb.isc.org/docs/isc-dhcp-44-manual-pages-dhcp-options

It basically seems to say that a long as the file exists, the DHCP server will update it. But in my case, I don't see any updates to it.
 

pboehmer

Active Member

Reaction score: 32
Messages: 144

I ended up writing a small shell script that uses net/fping. I grep out the range(s) from dhcpd.conf and run fping -a -g $RANGE. I get the MAC address of each response via arp and then cross reference the MAC against the last entries in /var/db/dhcpd/dhcpd.leases. Script spits out IP, MAC, and hostname for each IP range. The caveat is that the device responds to ICMP, so your mileage may vary.
 
OP
T

tOsYZYny

Member

Reaction score: 3
Messages: 66

Thanks for your reply, the problem is that my /var/db/dhcpd/dhcpd.leases is empty (other than the header). Is it possible to get the leases written to that file?
 

pboehmer

Active Member

Reaction score: 32
Messages: 144

Apologies, misunderstood your issue. If you are using net/isc-dhcp44-server, make sure that "-lf /var/db/dhcpd/dhcpd.leases" is set (should be by default in the rc.d startup script).
 
OP
T

tOsYZYny

Member

Reaction score: 3
Messages: 66

I deleted the /var/db/dhcpd.leases and restarted isc-dhcpd and I can see that /var/db/dhcpd/dhcpd.leases is the one being used. I would guess that I must have had the other dhcpd server installed when I first set up the router, then started that, removed it, and finally installed isc-dhcp44-server (which remains what I use today).

I will tail that lease file to see if it does grow.
 

SirDice

Administrator
Staff member
Administrator
Moderator

Reaction score: 9,117
Messages: 33,671

It's going to depend on the DHCP clients if it's going to include more information. As far as I know the dhclient(8) on FreeBSD sends the client's hostname with the DHCP request, so that information should show up in the leases. But I honestly can't remember what it shows by default (I have BIND and DHCP linked to get dynamic DNS registrations).
 
Top