Customizing pfSense KEA Leases

This content is licensed under The MIT License. See here for more details.
This is not supported by either Netgate or the pfSense project. It will probably break whenever KEA or pfSense is updated.

Overview

  • Strongly recommended to install nano for editing files.

Modification

Inside /etc/inc/services.inc, find an if statement marked /* render json */. Add the following around it:

/* Cleanup */
$keaconf['Dhcp4']['__custom_marker'] = '';

/*
    Unset any relevant properties here.
    You need to replace them in entirety.
*/
unset($keaconf['Dhcp4']['option-def']);
unset($keaconf['Dhcp4']['client-classes']);
foreach($keaconf['Dhcp4']['subnet4'] as &$subnet) {
    foreach($subnet['pools'] as &$pool) {
        unset($pool['client-class']);
    }
}

/* render json */
/* if... */

/* Injection */
$keaconf = str_replace('"__custom_marker": ""', file_get_contents('/path/to/injected.json'), $keaconf);

You are then free to specify your own additions in the referenced JSON file. They will be applied to the resulting KEA configuration whenever the DHCP interface configuration is saved in the web UI.