Skip to content

Instantly share code, notes, and snippets.

@pletch
pletch / scrape_opnsense_dhcp_leases.py
Last active September 24, 2023 13:16
Scrape OpnSense DHCP Leases Status Page and Export Results as List
#!/usr/bin/env python3
#
# This python script provides a function to query the opnSense (v21.3 - v23.1.x) dhcp leases status page and
# return a list of tuples including ip, hostname, and mac address. This script will not work with version 23.7.x+
# due to changes in the DHCP lease page.
# See comment from dheldt on modified version that works using api searchLeases page.
# To use the original script, ensure LXML is installed via package manager or via pip.
#
# 27-Mar-2021 - Original release