Index syndication
comment syndication

Using your MacBookPro to PXEBoot OpenBSD

December 8, 2008 at 03:07 · Filed under mac, openbsd, tech, unix

This post does not show a successful outcome in case that’s what you where hoping for.

I was trying to get OpenBSD bootstrapped using the PXEBoot NIC in a server. I decided to use my Mac which has tftp and bootpd installed. This post is quite in depth and technical so if you are game then read on.

The quick and short of it was I turned it all on, and copied my pxeboot image, like this from the Terminal:

sudo apachectl start
sudo service tftp start
sudo cp /Library/WebServer/Documents/pub/OpenBSD/4.4/i386/pxeboot  /private/tftpboot/

Then I neeed to setup the bootp server which comes with Internet Sharing. The idea was to add the pxeboot filename needed by OpenBSD (the file copied to tftpboot above) to the bootp (AKA dhcp) server options. The important file here is /etc/bootpd.plist. If this file doesn’t exist when Internet Sharing starts then bootpd will create it, removing it when it stops. But courtesy of Jules.FM “if the file already exists when it starts, the Mac will leave it alone and not overwrite or remove it”. So to add new dhcp options you perform these steps:

  1. Start Internet Sharing
  2. Copy the file somewhere safe: “cp /etc/bootpd.plist /tmp/
  3. Stop Internet Sharing
  4. Edit /tmp/bootpd.plist
  5. Add your required options
  6. Copy the file back in place: “sudo cp /tmp/bootpd.plist /etc/
  7. Start Internet Sharing

Since the Mac bootpd.plist file has no option for “filename” documented and since there appears to be a bug in the bootpd implementation with respect to supplying dhcp_options I added these data options to the bootpd.plist file:


<key>dhcp_option_66</key>
<data>
wKgCAQ==
</data>
<key>dhcp_option_67</key>
<data>
cHhlYm9vdA==
</data>
<key>dhcp_option_93</key>
<data>
AA==
</data>

In RFC2132 (Paragraphs 9.4 and 9.5) it specifies that options 66 and 67 are for the tftp server and boot filename. However the bootpd bug meant I had to encode the string “pxeboot” to hexadecimal “0x707865626F6F74” then Base64 encode it being “cHhlYm9vdA==” and that is way too time consuming to stuff around and try something else everytime the tftp file retrieval fails.

Don’t try using the dhcp_option_66 I had either as it is an encoded IP of my tftp server, not yours.

I got it all going, and the MacBookPro worked as planned, but the bootp server offered a filename of “pxeboot” and the silly Intel 10/100 card decided to fail due to missing files on the tftp server. Many hours later and I figured I should use a network sniffer instead of trying to turn on tftpd logging.

A packet dump showed \377 or 0xff being appended to the filename by the boot client (intel Nic on remote server) when using tftp to request the file. This made the filename “pxeboot” look like “pxeboot\377” in Wireshark’s view of the packet, as discussed here by other pioneers in netbooting.

If I get a full working implementation of dhcpd/tftp/pxe using the Mac – and actually working independent of the intel nic problem on the server, I’ll update this entry or write a complete run down.

Don’t hold your breath though. I rebuilt the OpenBSD server using bsd.rd (being a ramdisk installation) so my need is no longer a driver.

Jonathan Pittman said,

December 13, 2009 @ 08:44

I ran into this same issue with the file pxelinux.0 being requested by
the computer as pxelinux.0377 in a wireshark capture. 377 is octal for
hex 0xff or decimal 255. This was not an Intel NIC. It was a NIC using
a RealTek 8139.

To get around this issue, I did the following in the “/private/tftpboot”
directory.

ln -s pxelinux.0 $(printf “pxelinux.0377”)

This created a symbolic link to pxelinux.0 named pxelinux.0%ff. The
tftpd process handled it without trouble. The machine PXEd just fine.
In the /etc/bootpd.plist file, I just used plain text for the strings
instead of a base 64 encoded hex version.

The rest of the setup process is normal for a tftpboot directory setup
with PXE config files.

John Lockwood said,

February 27, 2010 @ 02:13

Yes, Apple’s bootpd forces you to use data values for DHCP option fields. However I am not sure your problem with the TFTP file name is Apple’s fault. As far as I can see the correct value you should be using for a file name of

pxelinux.0

is

cHhlbGludXguMA==

and for the file name

pxelinux

cHhlbGludXg=

This website http://hogehoge.tk/tool-i/ is a great help.

An alternate method for converting strings only is

echo “pxelinux.o” | openssl enc -base64

Openssl seems to pad out strings whereas other methods do not. This does not seem to make a realworld difference though. Openssl is also less helpful if you are trying to convert hex, IP addresses or unsigned integers.

Dave Riley said,

October 8, 2011 @ 06:44

I had a similar problem with garbage being appended to the filename with a Realtek NIC client. I found that the solution that worked was to insert a NULL at the end of the string in the bootpd.plist file (either by using the base64-encoded string or by manually inserting a NULL with vi, which is unpleasant). My guess is that the client code isn’t converting the Pascal-style string (length at front, no terminator) to a C-style one properly and is assuming the NULL terminator to be present when sending the TFTP request. tcpdump indicates that the BOOTP server is sending the string correctly.

In any case, that fixed my problem. It may fix yours!

Aaron said,

August 28, 2012 @ 02:37

Here are the steps I used to successfully PXE-boot OpenBSD from OSX. My MacBook Pro is connected to the Internet via the AirPort, and my soon-to-be OpenBSD box is connected to my Mac via the Ethernet port. As a slight added complication, my WLAN uses the 192.168.2.x subnet, so Internet Sharing needed to be adjusted to use a non-default address range.

So first, I fixed my Internet Sharing address conflict:
– Disable Internet Sharing
– Close any System Preferences windows
– Edit /Library/Preferences/SystemConfiguration/com.apple.nat.plist to add:
SharingNetworkNumberStart 192.168.3.0

Then I configured and launched tftpd:
– Edit /System/Library/LaunchDaemons/tftp.plist
– Remove the “Disabled” key+value
– Add -i to ProgramArguments
– Invoke launchd:
launchctl load -w /System/Library/LaunchDaemons/tftp.plist

I downloaded the appropriate OpenBSD pxeboot files to /private/tftpboot:
lwp-download http://ftp5.usa.openbsd.org/pub/OpenBSD/5.1/amd64/pxeboot
lwp-download http://ftp5.usa.openbsd.org/pub/OpenBSD/5.1/amd64/bsd.rd
mv bsd.rd bsd

Edited the bootpd.plist file:
– Launch Internet Sharing and make a copy of /etc/bootpd.conf as lantrix describes above.
– Stop Internet Sharing and copy your bootpd.conf back to /etc
– Edit /etc/bootpd.conf:
– Add dhcp_option_66
= Do an ifconfig to find the ip address of the interface that the OpenBSD box will be connecting to. In my case because of the modification I made to the InternetSharing settings, this is 192.168.3.1, but for a default OSX install it would be 192.168.2.1.
= Compute the Base64 string to use with this command:
perl -MMIME::Base64 -e’print encode_base64(pack(“C*”,192,168,3,1)).”\n”‘
– Add dbcp_option_67
= The proper string to use is “cHhlYm9vdAA=” for “pxeboot”.
= If you want to use a different file, you can compute the string like this:
perl -MMIME::Base64 -e’print encode_base64(“pxeboot”).”\n”‘

Start up Internet Sharing.

Make sure PXE-boot is enabled on the OpenBSD box and that the OpenBSD box.

Boot it up!

NB: If your OpenBSD box is on the same LAN as your OSX box rather than behind Internet Sharing as in my setup, you will need to adjust the IPs appropriately, and manually configure and launch the bootpd service. (and be careful to avoid DHCP server conflicts!)

RSS feed for comments on this post · TrackBack URI

Leave a Comment