Coder Social home page Coder Social logo

zorun / kea-hook-runscript Goto Github PK

View Code? Open in Web Editor NEW
52.0 6.0 23.0 1.74 MB

This a hook for the Kea DHCP server that allows to run an external script at various points in the processing of DHCP requests and responses.

License: Mozilla Public License 2.0

Makefile 3.21% C++ 95.14% Shell 1.65%

kea-hook-runscript's Introduction

CI status

About kea-hook-runscript

This a hook for the Kea DHCP server that allows to run an external script at various points in the processing of DHCP requests and responses.

The goal is to simplify integration with Kea: for many simple use-cases, it is overkill to have to write a full-blown Kea hook, where a simple shell script can do the job.

This hook is licensed under the Mozilla Public License version 2 (MPL2).

What it can and can't do

Integration is mostly done one-way: thanks to this hook, Kea passes information to the external script, but the script cannot easily modify Kea's behaviour.

The external script can be any kind of executable program, but often it will be a simple script (shell, Perl, Python...). Information about what Kea is doing is provided to the external script through environment variables: MAC address of the requesting DHCP client, IP address being handed out, etc.

Each time Kea encounters a hook point, it will (by default) call the script synchronously. That is, Kea will do absolutely nothing else while the script is running. Thus, it is a good idea to perform only lightweight processing in the script, and absolutely avoid blocking operations. Also, scripting languages that need to initialise a huge interpreter (such as Python or Ruby) will cause a large amount of CPU usage and a massive slowdown of Kea, because the script is run multiple times for each DHCP transaction.

If you know what you are doing, you can optionally call the script asynchronously by setting wait to false (see below).

This hook works for both DHCPv4 and DHCPv6, on Kea 1.1 and above.

In the future, the hook will possibly feed the return code of the external script back into Kea. This would allow the external script to cancel part of Kea's normal processing (for instance, it could be possible to easily implement a flexible host blacklist this way).

Alternative

Since Kea 1.9.5, a similar hook is provided by ISC: https://kea.readthedocs.io/en/latest/arm/hooks.html#run-script-support

It has similar functionalities: information is passed to the script through environment variables. However, only asynchronous execution is supported in ISC's hook, at least as of Kea 1.9.5.

Which hook to use is up to you: the ISC one will probably be better maintained when new versions of Kea come out, while this one supports synchronous execution which is safer. Also, environment variables are different between the two hooks, which can be an important factor if you need to process specific sub-options in your script.

Use-cases

Given the limitations exposed above, here are some example use-cases for which this hook is well-suited:

  • add/remove routing entries when DHCP clients arrive or leave. This can be useful when handing out IPv4 addressing in /32 subnets, or IPv6 Prefix Delegation with DHCPv6-PD. An example is included in examples/slash32_leases/;
  • update firewall rules to allow/refuse access to new DHCP clients;
  • log information about successful leases.

For more complex use-cases, including non-trivial changes to Kea's behaviour, it may be easier to just write a Kea hook yourself.

Examples

If you have more examples of usage, feel free to contribute your Kea config and your scripts!

Managing routes for IPv6 delegated prefixes

When delegating IPv6 prefixes with DHCPv6-PD, it is necessary to add the corresponding routes in the kernel.

This example script adds/removes static IPv6 routes whenever Kea delegates an IPv6 prefix through DHCPv6-PD or when the lease expires.

See the included README for more explanations and the source with the script and an example Kea configuration.

Handing out IPv4 addresses in /32 subnets

This example allows to lease IPv4 addresses individually (/32 subnets), by inserting routes in the kernel each time a DHCP client connects, and sending custom routes to clients using DHCP option 121. This is mostly useful to hand out public IPv4 addresses to customers.

See the included README for more explanations and the source with the script and an example Kea configuration.

Debug script

To experiment, a simple debug script is provided: examples/debug.sh. It simply prints the name of the hook point and all environment variables passed to it.

The output of the script is at /tmp/kea-hook-runscript-debug.log. A nice way to debug is to continously display the content of this file:

tail -F /tmp/kea-hook-runscript-debug.log

Pre-built binaries

Since version 1.4.0, we have a CI system to build the hook on various OS and for various versions of Kea. It's new, so there might be bugs.

The binaries are available from the release page or you can directly browse through the pipeline results.

How to build

If you want to build the hook yourself, you need the Kea libraries as well as the Kea and Boost development headers.

Using a packaged version of Kea

If you use a Kea package, you need the appropriate development packages:

  • boost development files: libboost-dev or equivalent
  • kea development files: isc-kea-dev from cloudsmith (official Kea package)

If you prefer using the Kea package from Debian, install kea-dev instead. However, it is currently unsupported and is only available in sid.

Then, to build the hook, simply run:

$ make -j4

Using Kea source

To build against a local Kea source tree, assumed to be in ~/kea:

  • build Kea (cd ~/kea && make -j)
  • install Kea to a local directory (cd ~/kea && make install DESTDIR=/tmp/kea)

Then build this hook with:

$ export KEA_INCLUDE=$HOME/kea/src/lib
$ export KEA_LIB=/tmp/kea/usr/local/lib
$ make

Supported Kea versions

Some notes on Kea versions:

  • Kea 1.1 does not install all required headers (most notably dhcpsrv/), so you may need to build against Kea's source tree.
  • Kea 1.2 is missing a header file by mistake, so depending on your distribution, you may need to manually copy option6_pdexclude.h from the Kea git repository to /usr/include/kea/dhcp/.
  • Kea 1.3 to 1.7 should work out-of-the-box.
  • Kea 1.8 needs to run without multi-threading. Open a ticket if you need multi-threading support.

How to use this hook

If all goes well, you should obtain a kea-hook-runscript.so file. Then, here is how to tell Kea to use this hook, for DHCPv4:

{
"Dhcp4":
{
  "hooks-libraries": [
    {
      "library": "/path/to/hea-hook-runscript/kea-hook-runscript.so",
      "parameters": {
        "script": "/path/to/myscript.sh",
        "wait": true
      }
    }
  ],
  ...
}
}

The wait parameter indicates whether Kea waits for the script to exit. That is, if set to true, Kea will block while the script is running. If you need high-performance DHCP, you can set it to false, but you must be prepared to handle several instances of the script running in parallel.

You can use the same script for both DHCPv4 and DHCPv6, or use two different scripts.

The script will receive the name of the hook point as first argument, and all relevant information available at the current hook point will be passed as environment variables, documented below.

To debug, see the examples/debug.sh script described above.

Refer to the Kea documentation for more information about each hook point:

Frequently Asked Questions

I get "Operation not permitted" when trying to add route in my script

The script is run with the same user as Kea: if this is not root, then the script will not have permission to change the routing table.

Either run Kea as root, or use a passwordless sudo configuration, see issue 24.

Reference of variables passed to the external script

DHCPv4 variables

Here are all possible variables for DHCPv4, with their type, description and reference of the possible values. Booleans are simply expressed with 0 and 1.

Variable name Type Description Reference
KEA_QUERY4_TYPE string Type of DHCP message dhcp/dhcp4.h
KEA_QUERY4_INTERFACE string Interface on which query was received
KEA_QUERY4_IFINDEX int Index of the interface on which query was received
KEA_QUERY4_HWADDR string Hardware address of the client (its MAC address)
KEA_QUERY4_HWADDR_TYPE int Type of hardware address dhcp/dhcp4.h
KEA_QUERY4_HWADDR_SOURCE int How this MAC address was obtained dhcp/hwaddr.h
KEA_QUERY4_RELAYED bool Whether query was relayed dhcp/pkt4.h
KEA_QUERY4_RELAY_HOPS int Number of relay agents traversed
KEA_QUERY4_OPTION60 string Option 60 - vendor id
KEA_QUERY4_CIADDR string Client IP address dhcp/pkt4.h
KEA_QUERY4_SIADDR string Server IP address dhcp/pkt4.h
KEA_QUERY4_YIADDR string Your IP address dhcp/pkt4.h
KEA_QUERY4_GIADDR string Gateway IP address (inserted by DHCP relay) dhcp/pkt4.h
KEA_QUERY4_RAI string Relay Agent Information (RFC 3046) as hex string
KEA_QUERY4_RAI_CIRCUIT_ID string RAI sub-option 1 Circuit id (RFC 3046) as hex string
KEA_QUERY4_RAI_REMOTE_ID string RAI sub-option 2 Remote id (RFC 3046) as hex string
KEA_RESPONSE4_TYPE string Type of DHCP message dhcp/dhcp4.h
KEA_RESPONSE4_INTERFACE string Interface on which response is being sent
KEA_RESPONSE4_IFINDEX int Index of the interface on which response is being sent
KEA_RESPONSE4_HWADDR string Hardware address of the client (its MAC address)
KEA_RESPONSE4_HWADDR_TYPE int Type of hardware address dhcp/dhcp4.h
KEA_RESPONSE4_HWADDR_SOURCE int How this MAC address was obtained dhcp/hwaddr.h
KEA_RESPONSE4_RELAYED bool Whether response is relayed dhcp/pkt4.h
KEA_RESPONSE4_RELAY_HOPS int Number of relay agents traversed
KEA_RESPONSE4_CIADDR string Client IP address dhcp/pkt4.h
KEA_RESPONSE4_SIADDR string Server IP address dhcp/pkt4.h
KEA_RESPONSE4_YIADDR string Your IP address dhcp/pkt4.h
KEA_RESPONSE4_GIADDR string Gateway IP address dhcp/pkt4.h
KEA_SUBNET4_PREFIX IPv4 IP prefix of the subnet (without prefix length)
KEA_SUBNET4_PREFIXLEN int Prefix length of the subnet (0 to 32)
KEA_SUBNET4 string KEA_SUBNET4_PREFIX/KEA_SUBNET4_PREFIXLEN
KEA_LEASE4_ADDRESS IPv4 IPv4 address leased to client
KEA_LEASE4_TYPE string Type of lease, always equal to "V4"
KEA_LEASE4_HWADDR string Hardware address of the client
KEA_LEASE4_HOSTNAME string Hostname associated to the client
KEA_LEASE4_STATE string Current state of the lease dhcpsrv/lease.h
KEA_LEASE4_IS_EXPIRED bool Whether the lease is expired
KEA_LEASE4_CLIENT_LAST_TRANSMISSION int Unix timestamp of the last message received from the client dhcpsrv/lease.h
KEA_LEASE4_VALID_LIFETIME int Valid lifetime of the lease, in seconds dhcpsrv/lease.h
KEA_REMOVE_LEASE bool Whether the lease should be removed from the lease database DHCPv4 hook API
KEA_FAKE_ALLOCATION bool Whether the query is a DISCOVER or a REQUEST DHCPv4 hook API

DHCPv4 hook points

For each Kea hook point, here are all variables usable in the external script.

  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_OPTION60
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_OPTION60
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_RESPONSE4_TYPE
  • KEA_RESPONSE4_INTERFACE
  • KEA_RESPONSE4_IFINDEX
  • KEA_RESPONSE4_HWADDR
  • KEA_RESPONSE4_HWADDR_SOURCE
  • KEA_RESPONSE4_HWADDR_TYPE
  • KEA_RESPONSE4_RELAYED
  • KEA_RESPONSE4_RELAY_HOPS
  • KEA_RESPONSE4_CIADDR
  • KEA_RESPONSE4_SIADDR
  • KEA_RESPONSE4_YIADDR
  • KEA_RESPONSE4_GIADDR
  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_SUBNET4_PREFIX
  • KEA_SUBNET4_PREFIXLEN
  • KEA_SUBNET4
  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_SUBNET4_PREFIX
  • KEA_SUBNET4_PREFIXLEN
  • KEA_SUBNET4
  • KEA_FAKE_ALLOCATION
  • KEA_LEASE4_ADDRESS
  • KEA_LEASE4_TYPE
  • KEA_LEASE4_STATE
  • KEA_LEASE4_IS_EXPIRED
  • KEA_LEASE4_HWADDR
  • KEA_LEASE4_HOSTNAME
  • KEA_LEASE4_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE4_VALID_LIFETIME
  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_SUBNET4_PREFIX
  • KEA_SUBNET4_PREFIXLEN
  • KEA_SUBNET4
  • KEA_LEASE4_ADDRESS
  • KEA_LEASE4_TYPE
  • KEA_LEASE4_STATE
  • KEA_LEASE4_IS_EXPIRED
  • KEA_LEASE4_HWADDR
  • KEA_LEASE4_HOSTNAME
  • KEA_LEASE4_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE4_VALID_LIFETIME
  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_LEASE4_ADDRESS
  • KEA_LEASE4_TYPE
  • KEA_LEASE4_STATE
  • KEA_LEASE4_IS_EXPIRED
  • KEA_LEASE4_HWADDR
  • KEA_LEASE4_HOSTNAME
  • KEA_LEASE4_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE4_VALID_LIFETIME
  • KEA_QUERY4_TYPE
  • KEA_QUERY4_INTERFACE
  • KEA_QUERY4_IFINDEX
  • KEA_QUERY4_HWADDR
  • KEA_QUERY4_HWADDR_SOURCE
  • KEA_QUERY4_HWADDR_TYPE
  • KEA_QUERY4_RELAYED
  • KEA_QUERY4_RELAY_HOPS
  • KEA_QUERY4_CIADDR
  • KEA_QUERY4_SIADDR
  • KEA_QUERY4_YIADDR
  • KEA_QUERY4_GIADDR
  • KEA_QUERY4_RAI
  • KEA_QUERY4_RAI_CIRCUIT_ID
  • KEA_QUERY4_RAI_REMOTE_ID
  • KEA_LEASE4_ADDRESS
  • KEA_LEASE4_TYPE
  • KEA_LEASE4_STATE
  • KEA_LEASE4_IS_EXPIRED
  • KEA_LEASE4_HWADDR
  • KEA_LEASE4_HOSTNAME
  • KEA_LEASE4_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE4_VALID_LIFETIME
  • KEA_LEASE4_ADDRESS
  • KEA_LEASE4_TYPE
  • KEA_LEASE4_STATE
  • KEA_LEASE4_IS_EXPIRED
  • KEA_LEASE4_HWADDR
  • KEA_LEASE4_HOSTNAME
  • KEA_LEASE4_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE4_VALID_LIFETIME
  • KEA_REMOVE_LEASE
  • KEA_LEASE4_ADDRESS
  • KEA_LEASE4_TYPE
  • KEA_LEASE4_STATE
  • KEA_LEASE4_IS_EXPIRED
  • KEA_LEASE4_HWADDR
  • KEA_LEASE4_HOSTNAME
  • KEA_LEASE4_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE4_VALID_LIFETIME

DHCPv6 variables

Here are all possible variables for DHCPv6, with their type, description and reference of the possible values. Booleans are simply expressed with 0 and 1.

Variable name Type Description Reference
KEA_QUERY6_TYPE string Type of DHCPv6 message dhcp/dhcp6.h
KEA_QUERY6_INTERFACE string Interface on which query was received
KEA_QUERY6_IFINDEX int Index of the interface on which query was received
KEA_QUERY6_DUID string TODO
KEA_QUERY6_HWADDR string Hardware address of the client (its MAC address)
KEA_QUERY6_HWADDR_TYPE int Type of hardware address dhcp/dhcp4.h
KEA_QUERY6_HWADDR_SOURCE int How this MAC address was obtained dhcp/hwaddr.h
KEA_QUERY6_LOCAL_ADDRESS string Local IPv6 address on which the query was received (link-local or multicast) dhcp/pkt.h
KEA_QUERY6_LOCAL_PORT int Local UDP or TCP port
KEA_QUERY6_REMOTE_ADDRESS string Remote IPv6 address, from which the query was received (link-local) dhcp/pkt.h
KEA_QUERY6_REMOTE_PORT int Remote UDP or TCP port
KEA_QUERY6_LABEL string Unique identifier of the query, to be used e.g. in log messages dhcp/pkt.h
KEA_QUERY6_TRANSACTION_ID int Transaction ID of the query dhcp/pkt.h
KEA_RESPONSE6_TYPE string Type of DHCPv6 message dhcp/dhcp6.h
KEA_RESPONSE6_INTERFACE string Interface on which response is being sent
KEA_RESPONSE6_IFINDEX int Index of the interface on which response is being sent
KEA_RESPONSE6_DUID string TODO
KEA_RESPONSE6_HWADDR string Hardware address of the client (its MAC address)
KEA_RESPONSE6_HWADDR_TYPE int Type of hardware address dhcp/dhcp4.h
KEA_RESPONSE6_HWADDR_SOURCE int How this MAC address was obtained dhcp/hwaddr.h
KEA_RESPONSE6_LOCAL_ADDRESS string Local IPv6 address, from which the response is being sent (link-local or multicast) dhcp/pkt.h
KEA_RESPONSE6_LOCAL_PORT int Local UDP or TCP port
KEA_RESPONSE6_REMOTE_ADDRESS string Remote IPv6 address, to which the response is being sent (link-local) dhcp/pkt.h
KEA_RESPONSE6_REMOTE_PORT int Remote UDP or TCP port
KEA_RESPONSE6_LABEL string Unique identifier of the response, to be used e.g. in log messages dhcp/pkt.h
KEA_RESPONSE6_TRANSACTION_ID int Transaction ID of the response dhcp/pkt.h
KEA_SUBNET6_PREFIX IPv6 IP prefix of the subnet (without prefix length)
KEA_SUBNET6_PREFIXLEN int Prefix length of the subnet (0 to 128)
KEA_SUBNET6 string KEA_SUBNET6_PREFIX/KEA_SUBNET6_PREFIXLEN
KEA_LEASE6_TYPE string Type of lease, either "NA", "TA", or "PD" dhcp/lease.h
KEA_LEASE6_ADDRESS IPv6 IPv6 address leased to client
KEA_LEASE6_DELEGATED_PREFIX string For TYPE="PD", prefix delegated to client (in prefix/prefixlen form)
KEA_LEASE6_DELEGATED_PREFIXLEN int For TYPE="PD", length of the prefix delegated to client
KEA_LEASE6_CLIENT_DUID string DUID of the client
KEA_LEASE6_HWADDR string Hardware address of the client
KEA_LEASE6_HOSTNAME string Hostname associated to the client
KEA_LEASE6_STATE string Current state of the lease dhcpsrv/lease.h
KEA_LEASE6_IS_EXPIRED bool Whether the lease is expired
KEA_LEASE6_CLIENT_LAST_TRANSMISSION int Unix timestamp of the last message received from the client dhcpsrv/lease.h
KEA_LEASE6_VALID_LIFETIME int Valid lifetime of the lease, in seconds dhcpsrv/lease.h
KEA_LEASE6_PREFERRED_LIFETIME int Preferred lifetime of the lease, in seconds dhcpsrv/lease.h
KEA_LEASE6_IAID string Identity Association Identifier, to differentiate between IA containers dhcpsrv/lease.h
KEA_REMOVE_LEASE bool Whether the lease should be removed from the lease database DHCPv6 hook API
KEA_FAKE_ALLOCATION bool Whether the query is a SOLICIT or a REQUEST DHCPv6 hook API

DHCPv6 hook points

For each Kea hook point, here are all variables usable in the external script.

  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_RESPONSE6_TYPE
  • KEA_RESPONSE6_INTERFACE
  • KEA_RESPONSE6_IFINDEX
  • KEA_RESPONSE6_DUID
  • KEA_RESPONSE6_HWADDR
  • KEA_RESPONSE6_HWADDR_TYPE
  • KEA_RESPONSE6_HWADDR_SOURCE
  • KEA_RESPONSE6_LOCAL_ADDRESS
  • KEA_RESPONSE6_LOCAL_PORT
  • KEA_RESPONSE6_REMOTE_ADDRESS
  • KEA_RESPONSE6_REMOTE_PORT
  • KEA_RESPONSE6_LABEL
  • KEA_RESPONSE6_TRANSACTION_ID
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_SUBNET6_PREFIX
  • KEA_SUBNET6_PREFIXLEN
  • KEA_SUBNET6
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_SUBNET6_PREFIX
  • KEA_SUBNET6_PREFIXLEN
  • KEA_SUBNET6
  • KEA_FAKE_ALLOCATION
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID
  • KEA_QUERY6_TYPE
  • KEA_QUERY6_INTERFACE
  • KEA_QUERY6_IFINDEX
  • KEA_QUERY6_DUID
  • KEA_QUERY6_HWADDR
  • KEA_QUERY6_HWADDR_TYPE
  • KEA_QUERY6_HWADDR_SOURCE
  • KEA_QUERY6_LOCAL_ADDRESS
  • KEA_QUERY6_LOCAL_PORT
  • KEA_QUERY6_REMOTE_ADDRESS
  • KEA_QUERY6_REMOTE_PORT
  • KEA_QUERY6_LABEL
  • KEA_QUERY6_TRANSACTION_ID
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID
  • KEA_REMOVE_LEASE
  • KEA_LEASE6_TYPE
  • KEA_LEASE6_ADDRESS
  • KEA_LEASE6_DELEGATED_PREFIX
  • KEA_LEASE6_DELEGATED_PREFIXLEN
  • KEA_LEASE6_CLIENT_DUID
  • KEA_LEASE6_HWADDR
  • KEA_LEASE6_HOSTNAME
  • KEA_LEASE6_STATE
  • KEA_LEASE6_IS_EXPIRED
  • KEA_LEASE6_CLIENT_LAST_TRANSMISSION
  • KEA_LEASE6_VALID_LIFETIME
  • KEA_LEASE6_PREFERRED_LIFETIME
  • KEA_LEASE6_IAID

TODO

  • take stdout/stderr of script and turn it into proper Kea logs
  • agree on a consistent terminology:
    • should a "prefix" variable contain the prefixlen (2001:db8::/48) or just the base address (2001:db8::)?
  • also call the script at load/unload
  • figure out how to call several scripts (loading the hook multiple times doesn't seem to work)
  • allow to configure which hook points will trigger the script
  • take into account the return code of the script to set the status of the callout (this should be configurable to avoid surprises...).

Some bugs to investigate/fix in Kea:

  • lease6_select is called twice (once with IA_NA and once with IA_PD), but other functions (lease6_renew, lease6_release, lease6_expire) are only called with IA_PD.
  • when an address reservation is changed for a given client, lease6_expire is never called for the old address.

kea-hook-runscript's People

Contributors

chadcatlett avatar jgroom33 avatar joostbekkers avatar ollb avatar p6wg7 avatar salanki avatar zorun avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar

kea-hook-runscript's Issues

hooks libraries failed to validate

Hi,
I'm running

kea-dhcp4 -V
2.0.2
tarball
linked with:
log4cplus 2.0.5
OpenSSL 3.0.2 15 Mar 2022
database:
MySQL backend 12.0, library 8.0.35
PostgreSQL backend 6.2, library 140010
Memfile backend 2.1

on ubuntu server 22.04

@update
After updating to kea 2.4 every think just start working

Compilation error

System description:
Ubuntu 16.04.5 LTS
kea 1.5.0
gcc version 5.4.0 20160609 (Ubuntu 5.4.0-6ubuntu1~16.04.11)

Error:
kea-msg-compiler -d src/ src/messages.mes
touch s-messages
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -o src/messages.o src/messages.cc
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -o src/logger.o src/logger.cc
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -o src/load.o src/load.cc
src/load.cc:8:22: error: ‘data’ is not a namespace-name
using namespace isc::data;
^
src/load.cc:8:26: error: expected namespace-name before ‘;’ token
using namespace isc::data;
^
src/load.cc: In function ‘int load(isc::hooks::LibraryHandle&)’:
src/load.cc:21:5: error: ‘ConstElementPtr’ was not declared in this scope
ConstElementPtr script = handle.getParameter("script");
^
src/load.cc:22:10: error: ‘script’ was not declared in this scope
if (!script) {
^
src/load.cc:26:9: error: ‘script’ was not declared in this scope
if (script->getType() != Element::string) {
^
src/load.cc:26:30: error: ‘Element’ has not been declared
if (script->getType() != Element::string) {
^
src/load.cc:30:19: error: ‘script’ was not declared in this scope
script_path = script->stringValue();
^
src/load.cc:33:21: error: expected ‘;’ before ‘wait’
ConstElementPtr wait = handle.getParameter("wait");
^
src/load.cc:34:14: error: expected primary-expression before ‘)’ token
if (!wait) {
^
src/load.cc:36:20: error: expected primary-expression before ‘->’ token
} else if (wait->getType() != Element::boolean) {
^
src/load.cc:36:35: error: ‘Element’ has not been declared
} else if (wait->getType() != Element::boolean) {
^
src/load.cc:40:26: error: expected primary-expression before ‘->’ token
script_wait = wait->boolValue();
^
Solution:
In Makefile need to add option "-std=c++11"

CXXFLAGS = -I $(KEA_INCLUDE) -fPIC -Wno-deprecated -std=c++11

Also need to change env

"export KEA_MSG_COMPILER=/home/user/kea/src/lib/log/compiler/kea-msg-compiler"
"export KEA_INCLUDE=/home/user/kea/src/lib"
"export KEA_LIB=/usr/local/lib"

I hope it can be helpful for somebody.

Compatibility with Kea 2.2.0+

This hook fails to build since Kea 2.2.0 (or maybe 2.1.x, I don’t development versions):

In file included from /usr/include/kea/dhcpsrv/subnet.h:15,
                 from src/callouts.cc:13:
/usr/include/kea/dhcpsrv/network.h:17:10: fatal error: dhcpsrv/cfg_globals.h: No such file or directory
   17 | #include <dhcpsrv/cfg_globals.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:14: src/callouts.o] Error 1

Kea doesn’t provide dhcpsrv/cfg_globals.h anymore.

I’m not sure if this hook is still relevant since the official Run Script hook though. I don’t use it myself anymore, just maintain kea-hook-runscript package in Alpine Linux. Well, until now, I’m about to remove it due to incompatibility with the latest Kea.

Question

How do I install this on Centos 7? I have already installed Kea. Do I place this inside the source directory where Kea hooks are and then re-install Kea again?

kea-dhcp6: RTNETLINK answers: Operation not permitted

Please anyone have a tip on how I can solve this problem?

kea-dhcp6: RTNETLINK answers: Operation not permitted

I am using:
https://github.com/zorun/kea-hook-runscript/blob/master/examples/ipv6_prefix_delegation/ipv6-routes.sh
+
https://code.ffdn.org/zorun/kea-hook-runscript/-/jobs/243/artifacts/file/kea-hook-runscript-kea-1-8-debian-buster.so
+
isc-kea-dhcp6-server 1.8.2-isc0001520201206093433 amd64 ISC Kea IPv6 DHCP server

My setup: Debian 11 + kernel 5.10.0-3-amd64

many thanks

Kea crashes on lease6_expire callout

Hi! Very useful hook, but it crash kea after some uptime =( Kea goes infinity loop of crash/restart. Do not depends on script, crashes even if it contains just exit 0.

Some info:

  • Kea versions affected: tested 1.6 and 1.7 (prebuilds from cloudsmith.io)
  • runscript hook version: 1.3.2 (release tar version with messages preincluded)
  • compiler: g++ 9.2.1 with -static-libstdc++ linker flag
  • os: debian stable

Hook config:

    "hooks-libraries": [
      {
        "library": "/home/xxx/kea/kea-hook-runscript/kea-hook-runscript.so",
        "parameters": {
          "script": "/home/xxx/kea/hookscript.sh",
          "wait": true
        }
      }
    ],

Crash log:

Feb 26 20:12:53 gate kea-dhcp6[19734]: INFO  DHCP6_STARTED Kea DHCPv6 server version 1.6.2 started
Feb 26 20:13:03 gate kea-dhcp6[19734]: DEBUG DHCPSRV_TIMERMGR_RUN_TIMER_OPERATION running operation for timer: reclaim-expired-leases
Feb 26 20:13:03 gate kea-dhcp6[19734]: DEBUG ALLOC_ENGINE_V6_LEASES_RECLAMATION_START starting reclamation of expired leases (limit = 100 leases or 250 milliseconds)
Feb 26 20:13:03 gate kea-dhcp6[19734]: DEBUG DHCPSRV_MEMFILE_GET_EXPIRED6 obtaining maximum 101 of expired IPv6 leases
Feb 26 20:13:03 gate kea-dhcp6[19734]: DEBUG ALLOC_ENGINE_V6_LEASE_RECLAIM duid=[00]: reclaiming expired lease for prefix 2a0d:xxxx:xxx:aaab::/128
Feb 26 20:13:03 gate kea-dhcp6[19734]: DEBUG HOOKS_CALLOUTS_BEGIN begin all callouts for hook lease6_expire
Feb 26 20:13:03 gate kea-dhcp6[19734]: kea-dhcp6: /usr/include/boost/smart_ptr/shared_ptr.hpp:734: typename boost::detail::sp_member_access<T>::type boost::shared_ptr<T>::operator->() const [with T = isc::dhcp::HWAddr; typename boost::detail::sp_member_access<T>::type = isc::dhcp::HWAddr*]: Assertion `px != 0' failed.
Feb 26 20:13:03 gate systemd[1]: isc-kea-dhcp6-server.service: Main process exited, code=killed, status=6/ABRT

Kea 1.6.3 - the status-get backport

Not so much an issue, as an advisory. Kea 1.6.3 will require rebuilding this hook library. In dev testing, kea-dhcp4 will not load the library (compiled based off the 1.6.2 reference tree). Also I never seem to end up with kea-msg-compiler from the ISC Cloudsmith repos (requiring the extra step of compiling that part of the kea source).

Solution: Grab 1.6.3 source, build as required, then follow existing instructions to build this hook library. Kea 1.6.3 will at least now start with the library referenced in the config. Further testing is ongoing (we use for DDNS -> Active Directory updates), but it should Just Work.

Doesn't build against Kea 1.6

Good Day,

Installed Kea from the package repo at cloudsmith.

Attempted to compile this hook and got "kea-msg-compiler: command not found", seems this is no longer included in 1.6 to get it I had to download the 1.5 tarball and compile to get the command (after trying the 1.6 tarball and compiling that).

Attempting to compile against the 1.6 headers yields the following:

airlink@dhcp001:~/kea-hook-runscript$ make
/home/airlink/kea-1.5.0/src/lib/log/compiler/kea-msg-compiler -d src/ src/messages.mes
touch s-messages
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -std=c++11 -o src/messages.o src/messages.cc
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -std=c++11 -o src/logger.o src/logger.cc
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -std=c++11 -o src/load.o src/load.cc
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -std=c++11 -o src/runscript.o src/runscript.cc
g++ -MMD -MP -c -I /usr/include/kea -fPIC -Wno-deprecated -std=c++11 -o src/callouts.o src/callouts.cc
src/callouts.cc: In function ‘void extract_lease4(std::vector<std::cxx11::basic_string >&, isc::dhcp::Lease4Ptr)’:
src/callouts.cc:158:69: error: ‘struct isc::dhcp::Lease4’ has no member named ‘t1

env.push_back("KEA_LEASE4_RENEW_TIMER=" + std::to_string(lease->t1
));
^~~
src/callouts.cc:159:70: error: ‘struct isc::dhcp::Lease4’ has no member named ‘t2_’
env.push_back("KEA_LEASE4_REBIND_TIMER=" + std::to_string(lease->t2_));
^~~
src/callouts.cc: In function ‘void extract_lease6(std::vector<std::cxx11::basic_string >&, isc::dhcp::Lease6Ptr)’:
src/callouts.cc:178:69: error: ‘struct isc::dhcp::Lease6’ has no member named ‘t1

env.push_back("KEA_LEASE6_RENEW_TIMER=" + std::to_string(lease->t1
));
^~~
src/callouts.cc:179:70: error: ‘struct isc::dhcp::Lease6’ has no member named ‘t2_’
env.push_back("KEA_LEASE6_REBIND_TIMER=" + std::to_string(lease->t2_));
^~~
Makefile:15: recipe for target 'src/callouts.o' failed
make: *** [src/callouts.o] Error 1

Compiling against the 1.5 code works and generates the kea-hook-runscript.so file but it doesn't load into the 1.6 server. Error is as follows:

DHCP4_CONFIG_LOAD_FAIL configuration error using file: /etc/kea/kea-dhcp4.conf, reason: hooks libraries failed to validate

RUNSCRIPT_WAITPID_FAILED

Got error in log:
2021-07-23 12:53:53.685 ERROR [kea-dhcp4.hook-runscript/56362.0x801adb000] RUNSCRIPT_WAITPID_FAILED waitpid() failed with error: Interrupted system call

"library": "/usr/local/lib/kea/hooks/kea-hook-runscript.so",
"parameters": {
"script": "/usr/local/etc/kea/dhcpv4.pl",
"wait": true
}

FreeBSD srv2 12.2-RELEASE-p4 FreeBSD 12.2-RELEASE-p4 GENERIC amd64
kea-1.8.2_1

How to solve this?

Add License

Please add a license file

Preferably MIT or Apache

Zombi processes

When parameter "wait" set to false, kea-hook-runscript don't read return code of script,
and leave script in zombie state.

Any chance to get this working on kea-dhcp 1.8.0?

Hi,

I am using this hook in my environment and on 1.6.2 it was working great. Unfortunately I am not able to get it run on 1.8.0. I am getting an error that "hook library cannot be validated". Further details in the log:

17:19:56.112 kea-dhcp4.hooks HOOKS_OPEN_ERROR failed to open hook library /usr/local/lib/kea/hooks/kea-hook-runscript.so: /usr/local/lib/kea/hooks/kea-hook-runscript.so: undefined symbol: _ZN3isc3log23checkExcessPlaceholdersEPNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEEj 17:19:56.112 kea-dhcp4.dhcp4 DHCP4_PARSER_FAIL failed to create or run parser for configuration element hooks-libraries: hooks libraries failed to validate - library or libraries in error are: /usr/local/lib/kea/hooks/kea-hook-runscript.so(/usr/local/etc/kea/kea-dhcp4.conf:179:3)

Any idea why it does not work although compiles fine?

Thanks!

Bye

g++ not found on all `nix systems

In trying to compile under FreeBSD 11.1, the gnu toolchain is not installed and g++ as a compiler invocation fails. c++ should work on most current `nix, especially those that use an "alternatives" approach.

Holding off on a patch, as it's trivial and I'm working through other make issues.

Unable to run the hook with debian stretch

hello I tried to assemble according to the instructions. The build will be fine, but when I run a kea server it reports an error.

root@ipv6-dhcp-test:~/kea-hook-runscript-master# make g++ -o kea-hook-runscript.so -I ~/kea/src/lib -fPIC -Wno-deprecated -L /usr/local/lib -shared -lkea-dhcpsrv -lkea-dhcp++ -lkea-hooks -lkea-log -lkea-util -lkea-exceptions src/messages.o src/logger.o src/load.o src/runscript.o src/callouts.o src/version.o

root@ipv6-dhcp-test:~/kea-hook-runscript-master# /usr/local/sbin/kea-dhcp6 -c /root/kea-config/kea-test2.conf
2017-10-30 15:29:34.717 INFO  [kea-dhcp6.dhcp6/1665] DHCP6_STARTING Kea DHCPv6 server version 1.2.0 starting
2017-10-30 15:29:34.718 ERROR [kea-dhcp6.hooks/1665] HOOKS_OPEN_ERROR failed to open hook library /usr/local/lib/kea-hook-runscript.so: /usr/local/lib/kea-hook-runscript.so: undefined symbol: _ZN3isc3log6Logger6outputERKNS0_8SeverityERKNSt7__cxx1112basic_stringIcSt11char_traitsIcESaIcEEE
2017-10-30 15:29:34.719 ERROR [kea-dhcp6.dhcp6/1665] DHCP6_PARSER_FAIL failed to create or run parser for configuration element hooks-libraries: hooks libraries failed to validate - library or libraries in error are: /usr/local/lib/kea-hook-runscript.so(/root/kea-config/kea-test2.conf:9:3)
2017-10-30 15:29:34.719 ERROR [kea-dhcp6.dhcp6/1665] DHCP6_CONFIG_LOAD_FAIL configuration error using file: /root/kea-config/kea-test2.conf, reason: hooks libraries failed to validate - library or libraries in error are: /usr/local/lib/kea-hook-runscript.so(/root/kea-config/kea-test2.conf:9:3)
2017-10-30 15:29:34.719 ERROR [kea-dhcp6.dhcp6/1665] DHCP6_INIT_FAIL failed to initialize Kea server: configuration error using file '/root/kea-config/kea-test2.conf': hooks libraries failed to validate - library or libraries in error are: /usr/local/lib/kea-hook-runscript.so(/root/kea-config/kea-test2.conf:9:3)


root@ipv6-dhcp-test:~/kea-hook-runscript-master# uname -a
Linux ipv6-dhcp-test 4.9.0-4-amd64 #1 SMP Debian 4.9.51-1 (2017-09-28) x86_64 GNU/Linux

root@ipv6-dhcp-test:~/kea-hook-runscript-master# g++ -v
Using built-in specs.
COLLECT_GCC=g++
COLLECT_LTO_WRAPPER=/usr/lib/gcc/x86_64-linux-gnu/6/lto-wrapper
Target: x86_64-linux-gnu
Configured with: ../src/configure -v --with-pkgversion='Debian 6.3.0-18' --with-bugurl=file:///usr/share/doc/gcc-6/README.Bugs --enable-languages=c,ada,c++,java,go,d,fortran,objc,obj-c++ --prefix=/usr --program-suffix=-6 --program-prefix=x86_64-linux-gnu- --enable-shared --enable-linker-build-id --libexecdir=/usr/lib --without-included-gettext --enable-threads=posix --libdir=/usr/lib --enable-nls --with-sysroot=/ --enable-clocale=gnu --enable-libstdcxx-debug --enable-libstdcxx-time=yes --with-default-libstdcxx-abi=new --enable-gnu-unique-object --disable-vtable-verify --enable-libmpx --enable-plugin --enable-default-pie --with-system-zlib --disable-browser-plugin --enable-java-awt=gtk --enable-gtk-cairo --with-java-home=/usr/lib/jvm/java-1.5.0-gcj-6-amd64/jre --enable-java-home --with-jvm-root-dir=/usr/lib/jvm/java-1.5.0-gcj-6-amd64 --with-jvm-jar-dir=/usr/lib/jvm-exports/java-1.5.0-gcj-6-amd64 --with-arch-directory=amd64 --with-ecj-jar=/usr/share/java/eclipse-ecj.jar --with-target-system-zlib --enable-objc-gc=auto --enable-multiarch --with-arch-32=i686 --with-abi=m64 --with-multilib-list=m32,m64,mx32 --enable-multilib --with-tune=generic --enable-checking=release --build=x86_64-linux-gnu --host=x86_64-linux-gnu --target=x86_64-linux-gnu
Thread model: posix
gcc version 6.3.0 20170516 (Debian 6.3.0-18)

root@ipv6-dhcp-test:~/kea-hook-runscript-master# /usr/local/sbin/kea-dhcp6 -v
1.2.0

Option 50 not showing

Option 50 (Requestd IP) is not propery passed to the script on relayed request packet.
Here is debug of script compared against tcpdump (some info are masked)

debug script output

pkt4_receive
KEA_QUERY4_TYPE : DHCPREQUEST
KEA_QUERY4_INTERFACE : ens192
KEA_QUERY4_IFINDEX : 2
KEA_QUERY4_HWADDR : ec:4f:82:11:09:86
KEA_QUERY4_HWADDR_TYPE : 1
KEA_QUERY4_HWADDR_SOURCE : 0
KEA_QUERY4_CIADDR : 0.0.0.0
KEA_QUERY4_SIADDR : 0.0.0.0
KEA_QUERY4_YIADDR : 0.0.0.0
KEA_QUERY4_GIADDR : xxx.71.223.1
KEA_QUERY4_RELAYED : 1
KEA_QUERY4_RELAY_HOPS : 0
KEA_QUERY4_OPTION60 : 844E-1.ENT.dslforum.org

tcpdump

09:54:05.494581 IP (tos 0x0, ttl 30, id 47192, offset 0, flags [none], proto UDP (17), length 356)
xxx.71.223.1 > xxx.19.180.2: [udp sum ok] BOOTP/DHCP, Request from ec:4f:82:11:09:86 (oui Unknown), length 328, xid 0x31e4c05, Flags [none] (0x0000)
Gateway-IP xxx.71.223.1
Client-Ethernet-Address ec:4f:82:11:09:86 (oui Unknown)
Vendor-rfc1048 Extensions
Magic Cookie 0x63825363
DHCP-Message Option 53, length 1: Request
Vendor-Class Option 60, length 23: "844E-1.ENT.dslforum.org"
T125 Option 125, length 32: -------removed string------------
Requested-IP Option 50, length 4: xxx.71.223.28
Server-ID Option 54, length 4: xxx.19.180.2
Parameter-Request Option 55, length 10:
Subnet-Mask, Classless-Static-Route, Vendor-Option, FQDN
Option 120, Default-Gateway, Domain-Name-Server, Hostname
Domain-Name, BR
END Option 255, length 0
PAD Option 0, length 0

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.