how to count IPs in use

Randall C Grimshaw rgrimsha at
Wed Oct 7 14:12:16 UTC 2009

I tend to look in the log for the lease balance entries

Oct  7 00:20:01 mumble/mumble dhcpd: [ID 702911] pool 804d50 8021x total 6210  free 490  backup 390  lts -50

there are some problems with this that make it difficult to automate, but a discerning eye can sort out the chaf. In this case the pool is 6210 with 880 available.... (5330 in use)

Feature request: With the ability to name pools added to the config options this could become very helpful.


From: dhcp-users-bounces at [dhcp-users-bounces at] On Behalf Of Peter Laws [plaws at]
Sent: Wednesday, October 07, 2009 9:39 AM
To: Users of ISC DHCP
Subject: Re: Re: how to count IPs in use

David W. Hankins wrote:

> dhcpstatus is cool but when I'm in CLI, I often just "Control-R" and
> find this in my bash history;
>   awk '/^lease / { curlease = $2; } /^  binding state/ { lstates[curlease] = $3; } END { for (curl in lstates) { tstates[lstates[curl]]++; } for (curs in tstates) { print curs, tstates[curs]; } }' /var/db/dhcpd.leases
> It prints output like;
>   active; 48
>   free; 81
>   backup; 158
> Which is useful to me as a spot-check.

Very nice!  One of my servers serves many networks and I'm really only
concerned about one of them.  Adding the first three octets of the IP
address to "^lease " didn't seem to do the trick ... pointers?

Other than to the O'Reilly sed and awk book, I mean.  :-)

Peter Laws / N5UWY
National Weather Center / Network Operations Center
University of Oklahoma Information Technology
plaws at
Feedback? Contact my director, Craig Cochell, craigc at Thank you!
dhcp-users mailing list
dhcp-users at

More information about the dhcp-users mailing list