[Kea-users] kea-dhcp6-server not running hook scripts

Justin Thomas justin at emeraldbroadband.com
Fri Oct 25 22:23:01 UTC 2024


Hi folks,

I’m trying to get the libdhcp_run_script.so library to run a script on DHCPv6 address assignment and renewal, but I can’t seem to get any signs of life out of it. My configuration includes:

"hooks-libraries": [
        {
            "library": "/usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_run_script.so",
            "parameters": {
                "name": "/etc/kea/update-v6.sh",
                "sync": false
            }
        }
    ],

And my update-v6.sh script looks like:

#!/bin/bash

unknown_handle() {
    echo "Unhandled function call ${*}"
    exit 123
}


lease6_renew () {
    echo "lease6_renew" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

lease6_rebind () {
    echo "lease6_rebind" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

lease6_expire () {
    echo "lease6_expire" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

lease6_recover () {
    echo "lease6_recover" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

leases6_committed () {
    echo "lease6_committed" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

lease6_release () {
    echo "lease6_release" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

lease6_decline () {
    echo "lease6_decline" >> /tmp/ithappened.txt
    echo $(env) >> /tmp/ithappened.txt
    curl http://23.x.x.x:8383
    exit 0
}

case "$1" in
    "lease6_renew")
        lease6_renew
        ;;
    "lease6_rebind")
        lease6_rebind
        ;;
    "lease6_expire")
        lease6_expire
        ;;
    "lease6_recover")
        lease6_recover
        ;;
    "leases6_committed")
        leases6_committed
        ;;
    "lease6_release")
        lease6_release
        ;;
    "lease6_decline")
        lease6_decline
        ;;
    *)
        unknown_handle "${@}"
        ;;
esac

As you can see, I’m just trying to get some kind of response out of it so that I can iterate on it – either as output to a file or even just a curl command showing that my server was touched (I was thinking maybe there’s some kind of extra file permissions layer that I’m overlooking so I added the curl command to see if I could get any kind of response out of it at all).

I can see that the library is loaded:

Oct 25 22:08:13 b1f18944-0de2-4ac0-8a3d-81c5d81c4a0c kea-dhcp6[126798]: INFO  RUN_SCRIPT_LOAD Run Script hooks library has been loaded
Oct 25 22:08:13 b1f18944-0de2-4ac0-8a3d-81c5d81c4a0c kea-dhcp6[126798]: INFO  HOOKS_LIBRARY_LOADED hooks library /usr/lib/x86_64-linux-gnu/kea/hooks/libdhcp_run_script.so successfully loaded

…but even when I receive messages like this in the journal:

Oct 25 22:04:11 b1f18944-0de2-4ac0-8a3d-81c5d81c4a0c kea-dhcp6[126689]: INFO  DHCP6_LEASE_RENEW duid=[00:04:00:00:00:00:00:00:00:00:00:00:ac:1f:6b:49:66:18], tid=0x734250: lease for address 2604:2940:f1b0:9e7:0:1:1:0 and iaid=0 has been allocated
Oct 25 22:04:12 b1f18944-0de2-4ac0-8a3d-81c5d81c4a0c kea-dhcp6[126689]: INFO  DHCP6_PD_LEASE_RENEW duid=[00:04:00:00:00:00:00:00:00:00:00:00:ac:1f:6b:49:66:18], tid=0x75f834: lease for prefix 2604:2940:1::/56 and iaid=0 has been allocated

…I see no activity related to the script execution happening. I can run the script manually and it works fine. The permissions are explicitly set to the _kea user that is running the server:

root at b1f18944-0de2-4ac0-8a3d-81c5d81c4a0c:/etc/kea# ls -la
total 20
drwxr-xr-x  2 root root 4096 Oct 25 22:14 .
drwxr-xr-x 76 root root 4096 Oct 10 20:38 ..
-rw-r--r--  1 root root 1940 Oct 11 21:47 kea-dhcp4.conf
-rw-r--r--  1 root root 3022 Oct 25 21:51 kea-dhcp6.conf
-rwxr-xr-x  1 _kea root 1641 Oct 25 22:07 update-v6.sh
root at b1f18944-0de2-4ac0-8a3d-81c5d81c4a0c:/etc/kea# ps aux | grep kea-dhcp6
_kea      126798  0.0  0.5  67316 20948 ?        Ssl  22:08   0:00 /usr/sbin/kea-dhcp6 -c /etc/kea/kea-dhcp6.conf
root      126803  0.0  0.4 154112 19760 pts/1    S+   22:08   0:00 journalctl -xeu kea-dhcp6-server -f
root      126819  0.0  0.0   6652  2236 pts/0    S+   22:19   0:00 grep kea-dhcp6

I’m at a loss. What am I missing?

-Justin



-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.isc.org/pipermail/kea-users/attachments/20241025/45c1d556/attachment-0001.htm>


More information about the Kea-users mailing list