Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    Command to count active DHCP leases

    DHCP and DNS
    2
    3
    4.9k
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • M
      Mypfsense2016
      last edited by

      Hi all,
      I want to get the number of active DHCP leases. E.g: The DHCP IPs that clients are using and the DHCP server can't not reclaim yet.

      I use the following command. But it seems not accurate yet.
      grep active /var/dhcpd/var/db/dhcpd.leases | wc -l

      Any idea?
      Thanks a lot.

      1 Reply Last reply Reply Quote 0
      • johnpozJ
        johnpoz LAYER 8 Global Moderator
        last edited by

        If your wanting to keep an eye on the number of leases your using and such.. I would think you would want to turn on the graphing feature for dhcp.

        Or if you just go to status leases, at the bottom you can get a count from each dhcp pool - is that what your looking for?

        leases.jpg
        leases.jpg_thumb

        An intelligent man is sometimes forced to be drunk to spend time with his fools
        If you get confused: Listen to the Music Play
        Please don't Chat/PM me for help, unless mod related
        SG-4860 24.11 | Lab VMs 2.7.2, 24.11

        1 Reply Last reply Reply Quote 0
        • M
          Mypfsense2016
          last edited by

          Normally, I only access pfsense remotely.
          Nevermind, I will see the code in the page you suggest and figure out how to count in batch shell.
          Thanks a lot.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.