[Dnsmasq-discuss] Retrieve the Raspberry Pi serial over DHCP using dnsmasq

Simon Kelley simon at thekelleys.org.uk
Fri Jan 7 16:32:28 UTC 2022



On 07/01/2022 15:09, Google wrote:
> Hi,
> 
> Raspberry Pi CM4 sends its serial as part of Option 97 but I cannot find
> a way to get hold of this value in my *dnsmasq* hook script.
> 
> *Does anyone know if this is currently possible or if it would require a
> code change?*

Not possible, and actually far from trivial. The events that get sent to
hook script are actually changes to the DHCP lease database, not
directly events in the DHCP protocol.

Option 97 is part of the PXE protocol, which is a baroque netboot
protocol which piggy backs over DHCP. The bits which send and receive
option 97 are not the same as the conventional DHCP events and don't
affect the DHCP lease database at all (It's possible, for instance, to
have the PXE server as an entirely separate server from the DHCP server
which is allocating addresses.) That makes feeding data from the PXE
process into the hook script via the lease database problematic.

> 
> Note that I do find a reference to Option 97 in the dnsmasq logs, but
> this value is truncated. Also it is sent as part of the DHCPOFFER, which
> seems a bit backwards as I would expect the client send this to the
> server and not the other way around.


It gets echoed back by the server. These interactions are PXE, not DHCP.


Cheers,

Simon.

> 
> *Is dnsmasq just echoing back what was by the client or is it creating
> its own id?*
> 
> Best regards,
> 
> Christoffer
> 
> PS I have also posted a version of this question on the [Raspberry
> Pi](https://raspberrypi.stackexchange.com/q/135324/143240
> <https://raspberrypi.stackexchange.com/q/135324/143240>) and will update
> it accordingly with any relevant answers I might get here!
> 
> PPS My hope is to provision the correct TFTP files and NFS share for the
> next stages of the PXE/netboot process that will be specific to each
> Raspberry. During this process Pi will request TFTP files with the
> serial as part of the the path, e.g. 
> 
> /ac78de89/start4.elf
> 
> … where ac78de89 is the serial id.
> 
> According to Raspberry Pi issues discussd on Github
> (cf. https://github.com/raspberrypi/rpi-eeprom/issues/182#issuecomment-657069276
> <https://github.com/raspberrypi/rpi-eeprom/issues/182#issuecomment-657069276>) the
> DHCP option 97 sent by the client should contain "/a combination of
> 0x34695052 (RPi4 as 4 bytes, backwards), the board revision (so you can
> detect the exact model, ram, and everything), part of the mac, and the
> full serial#/”.
> 
> 
> 
> _______________________________________________
> Dnsmasq-discuss mailing list
> Dnsmasq-discuss at lists.thekelleys.org.uk
> https://lists.thekelleys.org.uk/cgi-bin/mailman/listinfo/dnsmasq-discuss
> 



More information about the Dnsmasq-discuss mailing list