<div dir="ltr"><div>This is hard to describe, so I'll try to show it as clearly as I can.</div><div><br></div><div>The leases script takes the client id, skips the first digit, then converts each letter of the already byte encoded string to hexadecimal.</div><div><br></div><div>Here's the lease from the isc dhcpd leases file:</div><div><br></div><div><font face="monospace">lease 192.168.1.26 {<br>        starts 2 2025/02/11 17:53:02 UTC;<br>        ends 1 2025/05/12 17:53:02 UTC;<br>        hardware ethernet 72:f9:a1:9d:ba:05;<br>        uid 01:72:f9:a1:9d:ba:05;<br>}</font></div><div><br></div><div>As you can see, the uid is simply the MAC address prepended by "01:" Every device on my network that provides a uid does this.  The others provide nothing.</div><div><br></div><div>Here's the corresponding output from the script</div><div><font face="monospace">address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context<br>192.168.1.26,72:f9:a1:9d:ba:05,31:3a:37:32:3a:66:39:3a:61:31:3a:39:64:3a:62:61:3a:30,7772400,1747093734,1,0,0,,0,</font></div><div><br></div><div>As you can see, the client_id from the kea script looks nothing like the uid to which it should correspond. As it turns out, someone did a lot of work to get this wrong.  After staring at it long enough, I realized what it was.  Let me show you what it is by decoding each byte for you.</div><div><span style="font-family:monospace"> 1  :  7  2  :  f  9  :  a  1  :  9  d  :  b  a  :  0</span></div><div><span style="font-family:monospace">31:3a:37:32:3a:66:39:3a:61:31:3a:39:64:3a:62:61:3a:30</span><span style="font-family:monospace"></span></div><div>Look familiar?  For quick reference, here's the UID from the ISC leases file again <span style="font-family:monospace">0<u>1:72:f9:a1:9d:ba:0</u>5</span></div><div><br></div><div>Now, I think other types of UID/client_id may exist, but at least for this kind, this worked for me:</div><div><font face="monospace">106c106<br>>                 , ':'.join([format((ord(x)),'02x') for x in v["uid"].encode('utf-8').decode('unicode-escape')[1:-1]])<br>---</font></div><div><font face="monospace"><                 , v["uid"]</font></div><div><br></div><div>Then I get</div><div><font face="monospace">address,hwaddr,client_id,valid_lifetime,expire,subnet_id,fqdn_fwd,fqdn_rev,hostname,state,user_context<br>192.168.1.26,72:f9:a1:9d:ba:05,01:72:f9:a1:9d:ba:05,7772400,1747093734,1,0,0,,0,</font></div><div><div>Please note that this type of UID/client_id is exactly what kea-dhcp4 puts in the lease file itself, not the kind the script originally generated.</div><div><br></div></div><div>Like I said, someone went to a lot of work to get this wrong, at least for this UID type.  I believe that this may be appropriate for UIDs that start with "00" but I don't have any of those to test with, so if you do, this may break your conversion.</div><div><br></div><div>If the github would accept me as a member, I'd create a ticket for this, but it looks like I'll need some help with that again.</div><span class="gmail_signature_prefix">-- </span><br><div dir="ltr" class="gmail_signature" data-smartmail="gmail_signature"><div dir="ltr">John Lind<div><a href="mailto:steinhelten@gmail.com" target="_blank">steinhelten@gmail.com</a></div><div><br></div></div></div></div>