Hi,
I'm running OPNsense 23.7.10_1.
I'm trying to execute a custom bash script when a client connects to the DHCP server.
First I've changed the file
/usr/local/etc/inc/plugins.inc.d/dhcpd.inc
by adding:
$dhcpdconf .= 'on commit { execute("/etc/dhcpd/usr/local/sbin/oncommit", "commit"); }';
After DHCP restart from the GUI, the file
/var/dhcpd/etc/dhcpd.conf
is well modified with the new line.
Then I create a file
/var/dhcpd/etc/dhcpd/usr/local/sbin/oncommit
with 777 permission and dhcpd/dhcpd as user/group.
The result in the dhcpd log is :
QuoteUnable to execute /run/oncommit: No such file or directory
I've also try with a path that do not depend on the chroot dhcpd path with the same result.
Any help would be appreciate!
I do something similar in my own setup.
Try placing your script in /var/dhcpd/usr/local/sbin/oncommit instead, and then updating your on commit hook to use the path /usr/local/sbin/oncommit
Also, instead of editing the .inc files, which will get overwritten on an update, you should create a separate .conf file in the folder /usr/local/etc/dhcpd.opnsense.d/ (for v4) or /usr/local/etc/dhcpd6.opnsense.d/ (for v6) as suggested by the documentation here: https://docs.opnsense.org/manual/dhcp.html#advanced-settings