[Kea-users] Help with setting up MySQL backend for KEA

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[Kea-users] Help with setting up MySQL backend for KEA

phincylp
Hello,

I am trying to setup KEA dhcp to replace our old ISC dhcp infrastructure. I
am trying to use MySQL backend for host database. Leases are written to a
file in /dev/shm/

Following configuration is working fine.
{
// DHCPv4 configuration starts in this line
"Dhcp4": {

    "valid-lifetime": 1000,
    "renew-timer": 1000,
    "rebind-timer": 2000,

    "hooks-libraries": [
            {
                "library": "/opt/keadhcp/lib/kea/hooks/libdhcp_host_cmds.so"
            },
            {
                "library": "/opt/keadhcp/lib/kea/hooks/libdhcp_lease_cmds.so"
            }

    ],

    "interfaces-config": {
        "interfaces": [ "bond0" ],
        "dhcp-socket-type": "udp"
    },

   "control-socket": {
                "socket-name": "/tmp/kea4-ctrl-socket",
                "socket-type": "unix"
     },
    "host-reservation-identifiers": [
            "hw-address"
        ],

// And we specify the type of lease database
   "lease-database": {
            "lfc-interval": 3600,
            "max-row-errors": 100,
            "name": "/dev/shm/kea-dhcp4.csv",
            "persist": true,
            "type": "memfile"
        },


    "client-classes":[


        {
            "name": "ipxe_client",
            "test": "substring(option[77].hex,0,4) == 'iPXE'"
        },

        {
            "name": "pxeclient",
            "test": "substring(option[60].hex,0,9) == 'PXEClient'",
            "boot-file-name": "undionly.kpxe",
            "next-server": "10.252.183.12"
        },
        {
            "name": "bootp_client",
            "test": "member('ipxe_client') and member('pxeclient')",
            "boot-file-name": "http://10.252.183.12/ipxe/default"
        },
        {
            "name": "dhcp_client",
            "test": "not(member('ipxe_client') or member('pxeclient'))"
        },

        {
            "name": "my_client",
            "test": "member('ipxe_client') or member('pxeclient') or
member('dhcp_client')"
        },

        {
            "name": "pxe_only_client",
            "test": "not(member('ipxe_client')) and member('pxeclient') and
member('KNOWN')",
            "boot-file-name": "undionly.kpxe",
            "next-server": "10.252.183.12"
        },

        {
           "name": "kickstart_client",
           "test": "member('bootp_client') and member('KNOWN')",
           "boot-file-name": "http://10.252.183.12/ipxe/undidefault"
        }


    ],
//    "subnet4": <?include "/dev/shm/kea_subnets.conf"?>,
      "subnet4": [{
                "subnet": "10.252.183.0/26",
                "client-class": "my_client",
                "option-data": [{"data": "10.252.183.1", "name": "routers"}],
                "pools": [{"pool": "10.252.183.11 - 10.252.183.63"}],
                "id": 390628,
                "reservations": [
                        {
      "hostname": "app101.lab.myhost.com",
                        "hw-address": "ac:1f:6b:7c:e9:02",
                        "ip-address": "10.252.183.46",
                        "next-server": "10.252.183.12"
    }



                        ]
                }
        ],


    "loggers": [
        {
            "name": "kea-dhcp4",
            "output_options": [
                {
                    "output": "/var/log/kea-debug.log",
                    "maxver": 8,
                    "maxsize": 1073741824,

                    "flush": false,
                    "pattern": "%d{%j %H:%M:%S.%q} %c %m\n"
                }
            ],
            "severity": "INFO"
        }
   ]
}
}

If I run a curl query to kea api, I get

$ curl -X POST -H "Content-Type: application/json" -d '{"command":
"reservation-get", "arguments": {"identifier": "ac:1f:6b:7c:e9:02",
"subnet-id": 390628, "identifier-type" :"hw-address"}, "service":
["dhcp4"]}' http://localhost:8000/  | jq
  % Total    % Received % Xferd  Average Speed   Time    Time     Time
Current
                                 Dload  Upload   Total   Spent    Left
Speed
100   447  100   291  100   156    98k  54054 --:--:-- --:--:-- --:--:--
142k
[
  {
    "arguments": {
      "boot-file-name": "",
      "client-classes": [],
      "hostname": "app101.lab.myhost.com",
      "hw-address": "ac:1f:6b:7c:e9:02",
      "ip-address": "10.252.183.46",
      "next-server": "10.252.183.12",
      "option-data": [],
      "server-hostname": ""
    },
    "result": 0,
    "text": "Host found."
  }
]


All looking good here. I am able to PXE boot my host, it sends PXE call
first, DHCP sends next-server and undionly.kpxe file. Then host loads
undionly.kpxe file and makes another dhcp call with IPXE, this time, host
sends "http://10.252.183.12/ipxe/undidefault".

Problem appear when I move the reservation to the MySQL database. As per the
logs, I can see KEA is resolving the configs for the host when a dhcp
request is seen, and responding fine. I confirmed this with tcpdump as well.
Also reservation-get command via rest api gives the same result as above.
However, the host go into DHCP loop. It never do a TFTP call to download the
undionly.kpxe file.

As soon as I delete the reservation from MySQL and add it back to
configuration, things start working. If there is not reservation(either in
MySQL or config file, things are still working as expected. That is, it
loads, undionly.kpxe and then http://10.252.183.12/ipxe/default from
boop_client class)

Any help with the above issue is welcome.




--
Sent from: http://kea-users.7364.n8.nabble.com/
_______________________________________________
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
[hidden email]
https://lists.isc.org/mailman/listinfo/kea-users