dhcp: way to check the online status of the device

14,044

The DHCP protocol does not make any accommodations so that you can query an actual DHCP server and inquire about the contents of it's dhcpd.leases file.

So you essentially have 2 options.

  1. SSH into the DHCP server and parse the contents of the dhcpd.leases file manually.

  2. Install software such as DHCPStatus, which provides a interface so that you can get info about the contents of a DHCP server's leases.

excerpt

DHCPStatus is a query tool for browsing information stored in DHCPD's configuration and leases files, dhcpd.conf and dhcpd.leases. It correlates the subnet details that you configure in the conf file with the lease records that DHCPD maintains in its lease file. You can thus obtain an overall picture of your DHCP environment, as well as view details of individual leases for each IP.

DHCPStatus can be run either as a CGI script and viewed via a web browser, or as a command-line tool that generates simple text output. The CGI/web interface requires that you run a CGI-capable web server on your DHCPD server machine. The command-line tool merely requires that you have a shell login on the server.

DHCPStatus provides 2 reports.

Examples

  1. Here's DHCPStatus's summary report.

    as text

    [localhost]$ dhcpstatus
    DHCP Subnet Information
    
    Location: IFC - Glenorchy    Subnet: 10.1.4.64    Netmask: 255.255.255.192
    IP range: 10.1.4.65 - 10.1.4.126    Router: 10.1.4.126    IPs defined: 47
    IPs used: 33    IPs free: 14
    
    Location: TGIO    Subnet: 10.1.4.128    Netmask: 255.255.255.192
    IP range: 10.1.4.129 - 10.1.4.190    Router: 10.1.4.190    IPs defined: 30
    IPs used: 4    IPs free: 26
    
    Location: Servtas - Devonport    Subnet: 10.1.5.64    Netmask: 255.255.255.224
    IP range: 10.1.5.65 - 10.1.5.94    Router: 10.1.5.94    IPs defined: 10
    IPs used: 8    IPs free: 2
    
    Location: Servtas - Burnie - Reece House    Subnet: 10.1.5.96
    Netmask: 255.255.255.224    IP range: 10.1.5.97 - 10.1.5.126
    Router: 10.1.5.126    IPs defined: 15    IPs used: 5    IPs free: 10
    
    Location: Servtas - Glenorchy    Subnet: 10.1.5.160    Netmask: 255.255.255.224
    IP range: 10.1.5.161 - 10.1.5.190    Router: 10.1.5.190    IPs defined: 15
    IPs used: 1    IPs free: 14
    

    As HTML

        ss #1

  2. And here's DHCPStatus's detailed report.

    As text

    [localhost]$ dhcpstatus -s 192.62.4.64
    DHCP Subnet Information: IFC - Glenorchy
    
    Subnet:         192.62.4.64
    Netmask:        255.255.255.192
    Broadcast:      192.62.4.127
    Router:         192.62.4.126
    DNS servers:    192.62.11.156, 192.62.130.13
    WINS servers:   192.62.10.39, 192.62.10.40
    IP range:       192.62.4.65 - 192.62.4.126
    
    IP address: 192.62.4.65    
    IP address: 192.62.4.66    
    IP address: 192.62.4.67    
    IP address: 192.62.4.68    
    IP address: 192.62.4.69    
    IP address: 192.62.4.70    
    IP address: 192.62.4.71
    
    IP address: 192.62.4.72    Lease status: Active
    Lease start: 07/11/2000 07:43:12    Lease end: 21/11/2000 07:43:12
    Mac address: 00:80:5f:f7:d9:52    DNS name: infna72.ifc.tas.gov.au
    WINS name: 9906000IFC9006
    

    As HTML

        ss #2

Share:
14,044

Related videos on Youtube

ollazarev
Author by

ollazarev

Updated on September 18, 2022

Comments

  • ollazarev
    ollazarev almost 2 years

    On Linux there is the file /var/lib/dhcpd/dhcpd.leases.

    I need to determine, for the devices for which information contained in this file, whether the device is online at a given moment. Is there any way other than to parse the file and ping addresses contained in it?

    • Admin
      Admin about 10 years
      The system might be connected to the network but that does not always mean a user is logged in. Check manpages and other documentation about rwho and rwhod or tell us more about what you really need...
    • slm
      slm about 10 years
      Yes we need more information as to what you're trying to accomplish. As it stands looking in the leases file will just tell you what systems have leases. From that info you could ping the systems to confirm that they're online. But this wouldn't tell you anything about if a user was actually on that system. For that you'd have to go to each individual system and see who's logged in.
    • ollazarev
      ollazarev about 10 years
      @slm, sorry for my English. I want to determine whether the device is online, not the user.