[Kea-users] Kea run_script hook client class identification

Louis Declerfayt louis.declerfayt at ovhcloud.com
Mon Aug 5 10:14:05 UTC 2024


Hello,

I'm currently in the process of migrating our DHCP servers from ISC-DHCP 
to Kea, there is an use-case regarding script execution I can't seems to 
replicate.

To add a bit of context, I am using DHCP to power network device 
deployment using ZTP. The process is a bit different for each network 
operating system, while most of the customization can be done via the 
DHCP Response options, some operating systems need preliminary setup on 
our side. This setup process is launched from the ISC-DHCP server using 
the `execute` instruction, after the device is identified:

```
     set clip = binary-to-ascii(10, 8, ".", leased-address);
     set clhw = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));

     if substring ( option dhcp-client-identifier, 1,7 ) = "deviceA" {
         default-lease-time 60;
         max-lease-time 90;
         option bootfile-name "myConfig";
         on commit {
             execute("preparation_script.sh", "commit", clip, clhw, 
"deviceA");
         }
     }
     elsif substring ( option dhcp-client-identifier, 1,7 ) = "deviceB" {
         option bootfile-name "anotherConfig";
         option tftp-server-name "myIp";
     }
```

In this example, the preparation script only needs to be executed for 
`deviceA`.

However, on Kea, execution of scripts is done using the run_script [1] 
hook, which launch the script basically every time something happens.

This means that the decision to choose which operating system needs to 
launch the preparation process is moved from the DHCP config to the 
script itself. However, this seems complicated with the information 
available to the script (via environment variables) as the DHCP options 
used to identify the devices are not available (mainly options 60 and 61).


I have seen the issue #2622 [2] which could help, another alternative 
could be to just expose the DHCP options 60 and 61.

Do you have any other idea on how to resolve this issue ?


Thanks.


Louis Declerfayt


[1] 
https://kea.readthedocs.io/en/kea-2.0.1/arm/hooks.html#run-script-support
[2] https://gitlab.isc.org/isc-projects/kea/-/issues/2622



More information about the Kea-users mailing list