jmccon115
Posts: 2
Joined: Tue Mar 27, 2018 2:52 pm

HOWTO: configuring network booting using isc-dhcp-server options

Tue Mar 27, 2018 3:50 pm

I recently figured out how to configure network booting for my Raspberry Pi Model 3 B+ on my existing home network and wanted to share the results with everyone here since I couldn't find any easy guides on how to set up the DHCP options for any DHCP server software other than dnsmasq.
The most visible guide I could find on the site here was for configuring the necessary dnsmasq options at https://www.raspberrypi.org/documentati ... utorial.md
More helpful in the process for getting a DHCP service other than dnsmasq to work though, was found at https://www.raspberrypi.org/documentati ... des/net.md
I followed the tutorial instructions and successfully set the USB boot flag to allow booting by adding the program_usb_boot_mode=1 line to the /boot/config.txt file and then removing it after rebooting. This verified successfully, and after removing the SD card and flash drive from the pi I could see the raspberry pi requesting a dhcp address in the isc-dhcp-server logs, though it would give up after 5-6 attempts and then would never continue the boot process when attempting to use the existing pxe booting server options. For PXE roms, I use the nextserver configuration option in isc-dhcp-server and the filename configuration option to identify the initial bootstrap for pxelinux.0. Since this is a Broadcom chipset, it isn't surprising that it wouldn't work the same way as a conventional PXE boot configuration. Fortunately, the DHCP discovery packet from the raspberry pi offered some useful clues as to what kind of information I needed to specify to make it grab the bootcode.bin file from the tftp server. The DHCP discovery packet from the Pi includes DHCP option 55, specifying which options it expects to be present in the DHCP offer to continue the boot process. It asks for option 43, option 60, option 67, options 128-135, option 66, option 1, and option 3. It doesn't appear to actually require 128-135, since it boots for me without those options being sent. Options 1 and 3 are already included in a working network, at least they are in mine. Then I simply followed dhcpd's usage instructions for options at the man page at https://linux.die.net/man/5/dhcpd-options
NOTE: dhcpd.conf is the configuration file for isc-dhcp-server
A summary of the host configuration follows:
Option 43 (vendor-encapsulated-options) – important – needs to be set to colon separated hex values 6:1:3:a:4:0:50:58:45:9:14:0:0:11:52:61:73:70:62:65:72:72:79:20:50:69:20:42:6f:6f:74:ff or text string “ Raspberry Pi Boot”
Option 60 (vendor-class-identifier) – needs to be set to text value “PXEClient”
Option 66 (tftp-server-name) – needs to be set to IP address for tftp server hosting all the files from the /boot folder on the pi image
Option 67 (bootfile-name) – needs to be set to bootcode.bin, assuming the file is in the root of the tftp server. It may be possible to set it to a subfolder, but I haven’t tested that yet

The resulting host configuration for my raspberry pi in the dhcpd.conf file follows:
host raspberrypi.local {
hardware ethernet b8:27:eb:xx:xx:xx;
fixed-address 192.168.xx.xx;
option host-name "raspberrypi";
ddns-hostname "raspberrypi";
allow booting;
allow bootp;
option tftp-server-name "192.168.xx.xx";
option bootfile-name "bootcode.bin";
option vendor-class-identifier "PXEClient";
option vendor-encapsulated-options 6:1:3:a:4:0:50:58:45:9:14:0:0:11:52:61:73:70:62:65:72:72:79:20:50:69:20:42:6f:6f:74:ff;
}
To make this work for other instances, the information for the addresses will need to match that of your environment (ie replace all the information that I've added as xx with the addresses that are specific to the network this is being configured for).
I converted the string from the bootmode page from decimal to hex so isc-dhcp-server would recognize it and plugged it in for the vendor encapsulated options setting.
The rest of the process is already detailed elsewhere in documentation I found, but hopefully this can help if you need to add boot parameters to isc-dhcp-server for the raspberry pi.
Hope this helps somebody out there working on network booting their raspberry pi using isc-dhcp-server!

mfa298
Posts: 1386
Joined: Tue Apr 22, 2014 11:18 am

Re: HOWTO: configuring network booting using isc-dhcp-server options

Thu Mar 29, 2018 3:31 pm

I had the same issue as well, and worked out a config that worked for me (although hadn't gotten around to documenting it). I think some of your settings aren't needed, this is my config (I use groups to group similar devices meaning the host statements can generally be shorter)

Code: Select all

group pi {
       if substring (option vendor-class-identifier,0,9) = "PXEClient" {
                option vendor-class-identifier "PXEClient";
                option vendor-encapsulated-options "Raspberry Pi Boot";
                option tftp-server-name "192.168.xx.yy";
                max-lease-time 300;
                ddns-updates off;
        }

        host raspberry3b {    # Pi3B+
                hardware ethernet b8:27:eb:aa:bb:cc;
                option host-name "raspberry3b";
        }
}
In most cases the ddns-updates off may not be required (I don't want, this was copied over from my x86 pxe config where I don't want the pxe client boot to do ddns as that conflicts with the ddns for the host booting). It seems like the bootfile-name option isn't needed (although I'd be interested to see if it honours what's set in there). I also prefer the text version of vendor-encapsulated-options, it makes it much easier to see what's going on.

As an aside, my DHCP and tftp servers are on different hosts (although all the same subnet as the client) and that seems to work (if the dhcp and tftp we're on the same host is might also be possible to leave out the tftp-server-name option)

jmccon115
Posts: 2
Joined: Tue Mar 27, 2018 2:52 pm

Re: HOWTO: configuring network booting using isc-dhcp-server options

Fri Mar 30, 2018 1:22 pm

I hadn't had much of a chance during this week to review and test different configurations since I got it working on Monday, but I mostly just copy my host declarations from other clients and just plug in the new information. I tend to treat individual hosts a certain way based on their role in the network, so that if I need to replace them I can just drop in a new piece of hardware and then update the hardware address for them for the networking side of the client configuration.
It is good to know about the group declarations, and when I get a chance I'll test setting that up in my environment, but for now I've just been working with a single pi.
At first, I had used the hostname for the tftp server instead of the ip, and then it occurred to me that it was unlikely that the pi would be able to resolve the hostname at that point in the boot process, despite the option being named "tftp-server-name" so I just switched it to the ip. I had tried the text for the vendor-encapsulated-options setting at first, then changed it while I was troubleshooting and just didn't change it back at the end. I was a bit concerned that the option didn't have a pre-defined length after seeing one of my test packet captures report that the dhcp replies were malformed, which is when I switched it to the hex string. I added all the options that were requested to make sure I covered all my bases and now that it works I'll try taking out a few that aren't necessary.
My end goal is making a solution that can be scaled up for kiosks that pull a specific URL for display. I use isc-dhcp-server at home, but to deploy this solution at work I'm going to need a way to implement this in Windows dhcp server.
My boss sent me a link to https://medium.com/stories-from-upstate ... c2724acaa1 that he used to set up a test kiosk, but he used a single device with a microSD card. To actually deploy them to over 120 offices, we will need a way to centrally manage and secure the devices without physically having to handle them. I'm hoping to use the PoE hat on the raspberry pi 3 B+ devices to make it easier to power cycle them remotely, but I just haven't gotten to that point yet.
Thanks for the reply, that feedback is really helpful :D . I've had a good experience with isc-dhcp-server and bind9 using ddns so far so I'm always interested in getting more input to improve my configuration.

networksandchill
Posts: 7
Joined: Sun Aug 18, 2019 3:48 am

Re: HOWTO: configuring network booting using isc-dhcp-server options

Wed Jan 08, 2020 11:03 pm

Ran accross this post trying to PXE boot my Pi4 using a juniper srx300 as the dhcp server and this was immensely helpful, thank you!

here is my config

Code: Select all

[edit access address-assignment pool PILAN family inet dhcp-attributes]
root@SRX300# show
name-server {
    10.3.14.14;
}
router {
    10.3.14.14;
}
boot-file /tftpboot/bootcode.bin;
boot-server 10.3.14.1;
tftp-server 10.3.14.1;
propagate-settings irb.314;
option 60 string PXEClient;
option 43 string "Raspberry Pi Boot";

ka9q
Posts: 7
Joined: Thu May 09, 2013 8:20 am

Re: HOWTO: configuring network booting using isc-dhcp-server options

Fri Jun 05, 2020 8:59 am

networksandchill wrote:
Wed Jan 08, 2020 11:03 pm
Ran accross this post trying to PXE boot my Pi4 using a juniper srx300 as the dhcp server and this was immensely helpful, thank you!
Works for me too! Many thanks.

Return to “Advanced users”