Skip to content

Instantly share code, notes, and snippets.

@nick-lupien
nick-lupien / generate-kea-hosts.sh
Created July 4, 2024 15:42
pfSense script that parses Kea DHCP conf and lease files and generates an /etc/hosts-like file
#!/bin/sh
# Paths to the necessary files
LEASE_FILE="/var/lib/kea/dhcp4.leases"
KEA_CONF_FILE="/usr/local/etc/kea/kea-dhcp4.conf"
DHCP_HOSTS_FILE="/etc/dhcp-hosts"
TEMP_DHCP_HOSTS_FILE="/tmp/dhcp-hosts.new"
TEMP_DHCP_HOSTS_FILE_SORTED="/tmp/dhcp-hosts.new.sorted"
LOG_DIR="/var/log/dhcp-hosts"