DHCP, ARP, and NDP
Timestamped host observations
To use get_host_observations(), enable automatic host discovery on OPNsense
and grant the API user Interfaces: Neighbors: Automatic discovery.
Group observations from either address family by MAC and apply your own presence
window. Raw NDP entries alone do not prove current reachability.
API reference
- async OPNsenseClient.get_arp_table(resolve_hostnames=False)
Return active ARP table entries.
- Parameters:
resolve_hostnames (bool) – Whether reverse DNS lookups should be requested.
- Returns:
- ARP rows from OPNsense, optionally with resolved hostnames,
including fields such as IP address, MAC address, interface, expiration, and entry type when provided by the endpoint. An unavailable endpoint, or an absent or malformed rows field, returns None rather than an authoritative empty table.
- Return type:
list | None
- async OPNsenseClient.get_ndp_table()
Return IPv6 neighbors from the OPNsense NDP table.
- Returns:
- Unmodified neighbor rows containing
ip,mac, intf,intf_description, andmanufacturerwhen supplied. IPv6 addresses may include an interface scope suffix. Multiple addresses for the same MAC are preserved, including SLAAC and privacy addresses; DHCPv6 is not required. An empty list means a successful lookup found no neighbors. An unavailable endpoint or absent or malformed rows field returnsNone.
- Unmodified neighbor rows containing
- Return type:
list | None
- async OPNsenseClient.get_host_observations()
Return timestamped MAC observations without changing neighbor inventories.
- Returns:
- Source and normalized rows containing
mac,ip, and UTC
last_seendatetimes.discoveryidentifies packet observations;arp-ndpidentifies the timestamp-free fallback when hostwatch is disabled. An unavailable endpoint, incomplete response, empty source, or malformed discovery row returnsNonerather than an authoritative empty inventory.
- Source and normalized rows containing
- Return type:
- async OPNsenseClient.get_dhcp_leases(opnsense_tz=None)
Return active DHCP leases grouped by interface.
- Parameters:
opnsense_tz (tzinfo | None, optional) – Timezone used to localize ISC lease expiration timestamps. Fetched from OPNsense when omitted.
- Returns:
- Mapping with
lease_interfaceskeyed by interface name and
leaseskeyed by interface name. Lease entries are normalized across Kea, ISC, and dnsmasq and include address, hostname, interface, type, MAC, and expiration when available.
- Mapping with
- Return type: