<html><head><style>body{font-family:Helvetica,Arial;font-size:13px}</style></head><body style="word-wrap:break-word"><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">Thanks for the suggestion, Marcin. No luck though. I haven’t yet had the opportunity to really systematically go through my configuration to look for the fault, but here’s what I can tell you so far:</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto">I added the client-id host identifier type to my MySQL database. I believe I did this correctly.</div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><br></div><div id="bloop_customfont" style="font-family:Helvetica,Arial;font-size:13px;color:rgba(0,0,0,1.0);margin:0px;line-height:auto"><div id="bloop_customfont" style="margin:0px">MariaDB [kea]> SELECT * FROM host_identifier_type;</div><div id="bloop_customfont" style="margin:0px">+------+------------+</div><div id="bloop_customfont" style="margin:0px">| type | name       |</div><div id="bloop_customfont" style="margin:0px">+------+------------+</div><div id="bloop_customfont" style="margin:0px">|    0 | hw-address |</div><div id="bloop_customfont" style="margin:0px">|    1 | duid       |</div><div id="bloop_customfont" style="margin:0px">|    2 | circuit-id |</div><div id="bloop_customfont" style="margin:0px">|    3 | client-id  |</div><div id="bloop_customfont" style="margin:0px">+------+------------+</div><div id="bloop_customfont" style="margin:0px">4 rows in set (0.00 sec)</div><div id="bloop_customfont" style="margin:0px"><br></div><div id="bloop_customfont" style="margin:0px">I set “host-reservation-identifiers” to “auto” in the Dhcp4 section of kea.conf as you suggested. (Everything that follows is the same as what I get if I set it to “auto” or to any combination of “hw-address” and “client-id” with or without other tokens. If I JUST set it to “hw-address” then Kea doesn’t bother trying to look up host reservations by client ID, which is exactly what I’d expect.)</div><div id="bloop_customfont" style="margin:0px"><br></div><div id="bloop_customfont" style="margin:0px">Then I created a host reservation with a client ID. The reservation looks like this:</div><div id="bloop_customfont" style="margin:0px"><br></div><div id="bloop_customfont" style="margin:0px"><div id="bloop_customfont" style="margin:0px">MariaDB [kea]> SELECT * FROM hosts WHERE host_id=272 \G</div><div id="bloop_customfont" style="margin:0px">*************************** 1. row ***************************</div><div id="bloop_customfont" style="margin:0px">              host_id: 272</div><div id="bloop_customfont" style="margin:0px">      dhcp_identifier: milo</div><div id="bloop_customfont" style="margin:0px"> dhcp_identifier_type: 3</div><div id="bloop_customfont" style="margin:0px">      dhcp4_subnet_id: 168715520</div><div id="bloop_customfont" style="margin:0px">      dhcp6_subnet_id: NULL</div><div id="bloop_customfont" style="margin:0px">         ipv4_address: 168715522</div><div id="bloop_customfont" style="margin:0px">             hostname: <a href="http://milo.dallas.charlietango.com">milo.dallas.charlietango.com</a></div><div id="bloop_customfont" style="margin:0px"> dhcp4_client_classes: NULL</div><div id="bloop_customfont" style="margin:0px"> dhcp6_client_classes: NULL</div><div id="bloop_customfont" style="margin:0px">    dhcp4_next_server: NULL</div><div id="bloop_customfont" style="margin:0px">dhcp4_server_hostname: NULL</div><div id="bloop_customfont" style="margin:0px"> dhcp4_boot_file_name: NULL</div><div><br></div><div>The dhcp_identifier looks like plain text but it was created in what I assume is the proper way, by passing MySQL a hex representation of a sequence of bytes with the UNHEX function. I think it’s right and proper.</div><div><br></div><div><div>MariaDB [kea]> SELECT HEX(dhcp_identifier) FROM hosts WHERE host_id=272;</div><div>+----------------------+</div><div>| HEX(dhcp_identifier) |</div><div>+----------------------+</div><div>| 6D696C6F             |</div><div>+----------------------+</div></div></div></div> <div><br></div>Here’s the relevant debug log output from an attempt to get a DHCP lease using this client ID. I tested from a Linux VM with the command line “dhclient -I milo -v.” It’s worth pointing out there’s a DHCP-relaying router between the client and the server, but I see the same results when there’s no router in the way.<div><br></div><div><div>2017-01-04 13:34:00.731 DEBUG [kea-dhcp4.packets/4117] DHCP4_BUFFER_RECEIVED received buffer from <a href="http://10.14.99.254:68">10.14.99.254:68</a> to <a href="http://10.14.99.23:67">10.14.99.23:67</a> over interface ens192</div><div>2017-01-04 13:34:00.731 DEBUG [kea-dhcp4.options/4117] DHCP4_BUFFER_UNPACK parsing buffer received from 10.14.99.254 to 10.14.99.23 over interface ens192</div><div>2017-01-04 13:34:00.731 DEBUG [kea-dhcp4.packets/4117] DHCP4_PACKET_RECEIVED [hwtype=1 00:50:56:bc:89:97], cid=[6d:69:6c:6f], tid=0xd70f580e: DHCPDISCOVER (type 1) received from 10.14.99.254 to 10.14.99.23 on interface ens192</div><div><br></div><div>That’s both the correct MAC address and the correct client ID in hexadecimal. The IP 10.14.99.254 is the IP of the DHCP server’s side of the relaying router, and 10.14.99.23 is the IP of the DHCP server.</div><div><br></div><div><div>2017-01-04 13:34:00.731 DEBUG [kea-dhcp4.packets/4117] DHCP4_QUERY_DATA [hwtype=1 00:50:56:bc:89:97], cid=[6d:69:6c:6f], tid=0xd70f580e, packet details: local_address=<a href="http://10.14.99.23:67">10.14.99.23:67</a>, remote_adress=<a href="http://10.14.99.254:68">10.14.99.254:68</a>, msg_type=DHCPDISCOVER (1), transid=0xd70f580e,</div><div>options:</div><div>  type=050, len=004: 10.14.101.2 (ipv4-address)</div><div>  type=053, len=001: 1 (uint8)</div><div>  type=055, len=013: 1(uint8) 28(uint8) 2(uint8) 121(uint8) 15(uint8) 6(uint8) 12(uint8) 40(uint8) 41(uint8) 42(uint8) 26(uint8) 119(uint8) 3(uint8)</div><div>  type=061, len=004: 6d:69:6c:6f</div></div><div><br></div><div>Here we see Kea seems to properly decode option 61. I think.</div><div><br></div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.dhcpsrv/4117] DHCPSRV_CFGMGR_SUBNET4_ADDR selected subnet <a href="http://10.14.101.0/24">10.14.101.0/24</a> for packet received by matching address 10.14.101.254</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.packets/4117] DHCP4_SUBNET_SELECTED [hwtype=1 00:50:56:bc:89:97], cid=[6d:69:6c:6f], tid=0xd70f580e: the subnet with ID 168715520 was selected for client assignments</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.packets/4117] DHCP4_SUBNET_DATA [hwtype=1 00:50:56:bc:89:97], cid=[6d:69:6c:6f], tid=0xd70f580e: the selected subnet details: <a href="http://10.14.101.0/24">10.14.101.0/24</a></div><div><br></div><div>This is all correct, based on the giaddr from the relaying router, I’m assuming.</div><div><br></div><div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER get one host with IPv4 reservation for subnet id 168715520, identified by hwaddr=005056BC8997</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations using identifier: hwaddr=005056BC8997</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT using identifier hwaddr=005056BC8997, found 0 host(s)</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER_NULL host not found using subnet id 168715520 and identifier hwaddr=005056BC8997</div></div><div><br></div><div>I assume these are all reports that Kea is trying to look up a host reservation using the MAC address. There is no such host reservation in the database so it’s proper that these should fail.</div><div><br></div><div><div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ONE_SUBNET_ID_IDENTIFIER get one host with IPv4 reservation for subnet id 168715520, identified by client-id=6D696C6F</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ALL_IDENTIFIER get all hosts with reservations using identifier: client-id=6D696C6F</div><div>2017-01-04 13:34:00.732 DEBUG [kea-dhcp4.hosts/4117] HOSTS_CFG_GET_ALL_IDENTIFIER_COUNT using identifier client-id=6D696C6F, found 0 host(s)</div></div></div><div><br></div><div>I would have expected that to succeed, though. There IS a reservation with that subnet ID and that client ID … at least I think there is.</div><div><br></div><div>Am I not encoding the client ID correctly in the database? That’s the only thing I can think of that would be throwing this off. I’ve tried (superficially) looking at the MySQL query log, but it’s not very helpful because Kea uses prepared statements that MySQL doesn’t seem to log by default, or something like that. I haven’t figured it out yet.</div> <br><p class="airmail_on">On January 4, 2017 at 11:17:48 AM, Marcin Siodelski (<a href="mailto:marcin@isc.org">marcin@isc.org</a>) wrote:</p> <blockquote type="cite" class="clean_bq"><span><div><div></div><div>Jeffery,
<br>
<br>I think I found the flaw in Kea which may result in behavior you're
<br>observing. Thankfully, I also have a good guess how to work around this
<br>problem.
<br>
<br>Can you please try adding the following parameter to your DHCPv4 server
<br>configuration:
<br>
<br>"host-reservation-identifiers": [ "auto" ]
<br>?
<br>
<br>Other values should also work:
<br>
<br>"host-reservation-identifiers": [ "circuit-id", "hw-address", "duid",
<br>"client-id" ],
<br>
<br>OR
<br>
<br>"host-reservation-identifiers": [ "client-id" ],
<br>
<br>Marcin
<br>
<br>On 03.01.2017 18:57, Jeffery Harrell wrote:
<br>> Hi, Marcin. Thanks for the reply. I did try inserting the missing row
<br>> into our MySQL database. I also tried setting up an isolated test
<br>> environment this morning using PostgreSQL 9.5 as the backend but
<br>> client-id reservations weren't working for me there either, so it seems
<br>> pretty obvious that I'm doing something wrong. MAC address-based
<br>> reservations work like a charm, but if I try to get Kea to give me a
<br>> lease based on a client id reservation in a subnet with a pool, it gives
<br>> me an IP from the pool, and if I try to get one out of a subnet with no
<br>> pool it just doesn't give a lease at all.
<br>>  
<br>> Like I said, it seems to me to be a configuration problem on my end. I'm
<br>> going to try to go through things very systematically following the
<br>> documentation carefully to see if I can find my error.
<br>>  
<br>> On Tue, Jan 3, 2017 at 1:05 AM, Marcin Siodelski <<a href="mailto:marcin@isc.org">marcin@isc.org</a>
<br>> <mailto:<a href="mailto:marcin@isc.org">marcin@isc.org</a>>> wrote:
<br>>  
<br>>     On 03.01.2017 03:55, Jeffery Harrell wrote:
<br>>     > I hope this isn’t a frequently asked question or anything; I’ve
<br>>     searched
<br>>     > and searched. Is it a known issue that client-id-based host
<br>>     reservations
<br>>     > aren’t currently working using the MySQL backend? I ask because (A) I
<br>>     > can’t seem to get one to work in my environment, which may well be my
<br>>     > fault, but (B)
<br>>     > comparing /usr/share/kea/scripts/mysql/dhcpdb_create.mysql
<br>>     > and /usr/share/kea/scripts/pgsql/dhcpdb_create.pgsql I see that the
<br>>     > contents of host_identifier_type aren’t the same. The Postgres
<br>>     version has
<br>>     >
<br>>     > INSERT INTO host_identifier_type VALUES (3, 'client-id’);
<br>>     >
<br>>     > while the MySQL version stops at #2, circuit-id. This makes me
<br>>     wonder if
<br>>     > client-id host reservations aren’t supposed to be working with the
<br>>     MySQL
<br>>     > backend right now? I thought maybe I’d ask to see if there was a quick
<br>>     > answer that could save me more hours of fiddling around and trying to
<br>>     > read the source code.
<br>>     >
<br>>     > Again, apologies if I’m treading on old ground. Thanks!
<br>>     >
<br>>     >
<br>>  
<br>>     Hello Jeffery,
<br>>  
<br>>     It seems to be a bug in our MySQL database creation scripts. The
<br>>     host_identifier_type table should include 'client-id' entry. Other than
<br>>     that, the 'client-id' based reservations should work for MySQL.
<br>>  
<br>>     Did you try yo insert the dhcp_identifier_type of 3 into the hosts table
<br>>     for your reservation?
<br>>  
<br>>     Marcin
<br>>  
<br>>  
<br>
<br></div></div></span></blockquote></div></body></html>