ndejong / pfsense_fauxapi

REST based API interface for pfSense 2.3.x and 2.4.x to facilitate devops
Apache License 2.0
354 stars 61 forks source link

How could I reach the DHCP Leases table? #24

Closed carldebilly closed 6 years ago

carldebilly commented 6 years ago

I'm currently trying to build a device presence detection (for integration with SmartThings) and I want to know if a device is present in the DHCP leases table (status="online").

At first it seems it's not available directly in fauxapi, but I'm wondering if it's something which can be easily added.

Since I'm definitely not familiar with PHP nor developping for pfSense (I'm a dotnet guy), I don't know where to start to add this in fauxapi.

carldebilly commented 6 years ago

After few thoughts, I think the ARP table could be a more reliable way to get the presence information I need instead of DHCP.

ndejong commented 6 years ago

Based on the detail you've provided "device presence detection" I'd suggest you simply need to watch the ARP tables which can be done at the pfSense console using arp -a

Adding a function to provide this would be rather easy but it is a step outside the original mission of providing a programmatic interface to pfSense to manage the config.xml file and the functions required to get that config adopted by the system.

This does not mean it's a dead-end, you should be able to use the function_call call and invoke the exec_command pfSense function to hence make an arp -a call and extract the data you need - read-the-docs, you will need to enable exec_command in the /etc/pfsense_function_calls.txt file to make this work.

Collecting the same data via a simple ssh remote-exec is your other option here.