[Kea-users] How do I list current IPv4 leases? (OPEN)

Weisteen Per per.weisteen at telenor.no
Wed Jun 7 08:11:21 UTC 2023


Hi,

As far as I can see I've got the socket statements ok, different socket names though.

Trying the direct socket approach using socat works ok. 

~$ cat list-lease.json |socat UNIX:/tmp/kea4-ctrl-socket -,ignoreeof | jq
{
  "arguments": {
    "leases": [
      {
        "client-id": "01:00:17:5f:a5:43:1a",
        "cltt": 1686119440,
        "fqdn-fwd": true,
        "fqdn-rev": true,
        "hostname": "tfbu-ra003.cctv.telenor.net",
        "hw-address": "00:17:5f:a5:43:1a",
        "ip-address": "10.140.31.43",
        "state": 0,
        "subnet-id": 19,
        "valid-lft": 3600
      },
...etc

I'm running kea-shell on the same server where kea-ctrl-agent is running so there is no firewall involved. I've also tried to telnet to the 8001 port and that connects ok.   

./PerW

> -----Original Message-----
> From: Kea-users <kea-users-bounces at lists.isc.org> On Behalf Of Darren
> Ankney
> Sent: tirsdag 6. juni 2023 22:04
> To: kea-users at lists.isc.org
> Subject: Re: [Kea-users] How do I list current IPv4 leases? (OPEN)
> 
> Hi,
> 
> First, have a look in your DHCP4 Kea configuration and locate the socket
> statement which should look something like this:
> 
>     "control-socket": {
>       "socket-type": "unix",
>       "socket-name": "/tmp/kea-dhcp4-socket"
>     },
> 
> Make sure your kea-ctrl-agent is connecting to that socket which would look
> something like this if following the example above:
> 
>         "control-sockets": {
>             "dhcp4": {
>                 "socket-type": "unix",
>                 "socket-name": "/tmp/kea-dhcp4-socket"
>             },
> 
> Make sure you have the correct ip and port set in your kea-ctrl-agent also.
> Something like this:
> 
> {
>     "Control-agent": {
>         "http-host": "10.123.97.212",
>         "http-port": 8001,
> 
> 
> If all that checks out, then try sending your commands directly to the socket...
> Put your command in a .json file.  I'll call mine command.json.  I'll put the
> command in the command.json file like
> this:
> 
> {
>     "command": "config-get"
> }
> 
> And then I'll execute the command:
> 
>  cat command.json | sudo socat UNIX:/tmp/kea-dhcp4-socket -,ignoreeof | jq
> .
> 
> You may need to install socat or jq or both.  They are both useful.
> socat lets you talk to a unix socket.  jq formats (among other things) json
> output.
> 
> If you are still not able to connect using kea-shell to the IP, then it might be a
> firewall problem?
> 
> Thank you,
> 
> Darren Ankney
> 
> On Tue, Jun 6, 2023 at 8:59 AM Weisteen Per <per.weisteen at telenor.no>
> wrote:
> >
> > Hi
> >
> > Thanks, I'll try to keep this conversation OPEN 😉
> >
> > I'm running HA setup and has kea-ctrl-agent on port 8001 on my primary
> server (10.123.97.212) and tried kea-shell :
> > kea-shell --host 10.123.97.212 --port 8001 --service dhcp4
> > lease4-get-all but I'm just receiving a Connection Timeout after several
> minutes.
> >
> > Did the same using curl and got same reply packed in HTML code.
> > curl -X POST -H "Content-Type: application/json" -d '{ "command":
> > "lease4-get-all", "service": [ "dhcp4" ] }' http://10.123.97.212:8081
> > <I didn't bother pasting the HTML encoded reply>
> >
> > I've got approx. 80 leases so this shouldn't take much time.
> >
> >
> > ./PerW
> >
> > > -----Original Message-----
> > > From: Kea-users <kea-users-bounces at lists.isc.org> On Behalf Of Kevin P.
> > > Fleming
> > > Sent: tirsdag 6. juni 2023 13:32
> > > To: kea-users at lists.isc.org
> > > Subject: Re: [Kea-users] How do I list current IPv4 leases?
> > > (INTERNAL)
> > >
> > > On Tue, Jun 6, 2023, at 07:28, Weisteen Per wrote:
> > > > Hi
> > >
> > > I'm replying even though this was apparently an "INTERNAL" message
> > > :-)
> > >
> > > >
> > > > Simple question, how do I get a list of all current leases when
> > > > using memfile as database backend?
> > >
> > > Regardless of the backend, the 'lease_cmds' hook library is what you want:
> > >
> > > https://kea.readthedocs.io/en/kea-2.2.0/arm/hooks.html#lease-cmds-le
> > > ase- commands-for-easier-lease-management
> > > --
> > > ISC funds the development of this software with paid support
> subscriptions.
> > > Contact us at https://www.isc.org/contact/ for more information.
> > >
> > > To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
> > >
> > > Kea-users mailing list
> > > Kea-users at lists.isc.org
> > > https://lists.isc.org/mailman/listinfo/kea-users
> > --
> > ISC funds the development of this software with paid support subscriptions.
> Contact us at https://www.isc.org/contact/ for more information.
> >
> > To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
> >
> > Kea-users mailing list
> > Kea-users at lists.isc.org
> > https://lists.isc.org/mailman/listinfo/kea-users
> --
> ISC funds the development of this software with paid support subscriptions.
> Contact us at https://www.isc.org/contact/ for more information.
> 
> To unsubscribe visit https://lists.isc.org/mailman/listinfo/kea-users.
> 
> Kea-users mailing list
> Kea-users at lists.isc.org
> https://lists.isc.org/mailman/listinfo/kea-users


More information about the Kea-users mailing list