Sunday, August 2, 2020

How to determine PXE mac address when booting illumos via PXELinux/iPXE

In illumos, if you need to determine the interface which was used for booting via PXE then it's possible to use "boot-mac" property:
# /sbin/devprop -s boot-mac 

c:c4:7a:04:ef:2c

But this property is set by illumos pxeboot. On some setup we use PXELinux to boot multiple illumos clients over PXE. For any illumos distribution "append" line in pxelinux.cfg looks like:
label omni PXE
kernel mboot.c32
append omni7/platform/i86pc/kernel/amd64/unix -B install_media=http://192.168.1.1/kayak.zfs.xz,install_config=http://192.168.1.1 ---omni7/miniroot
If you have small amount of clients, then it's possible to just add each client's mac address to the kernel line with -B boot-mac=<hardware-address>, but it doesn't work in case you have a hundreds of clients. 

Pxelinux menu has "ipappend 2" option, which appends "BOOTIF=<hardware-address-of-boot-interface>" to the kernel command line, but pxelinux puts BOOTIF exactly at the end of "append" line, after boot_archive, and kernel does not recognise this variable after boot. There are no any way to set something like -B BOOTIF dynamically here. 

Fortunately, we can boot iPXE from pxelinux menu. DHCP configuration was updated to allow iPXE boot when ipxe.lkrn boot:
...
if exists user-class and option user-class = "iPXE" {
        filename "menu.ipxe";
  } else {
        filename "pxelinux.0";
} 

pxelinux.cfg/default:
...
label omni7 
   kernel ipxe.lkrn
menu.ipxe:
#!ipxe

kernel  omni7/platform/i86pc/kernel/amd64/unix -B boot-mac=${netX/mac},install_media=http://192.168.1.1/omni7/kayak.zfs.xz,install_config=http://192.168.1.1/omni7
initrd  omni7/miniroot
boot
iPXE allows to get mac address with ${netX/mac} variable, so "boot-mac" will contain mac-address which was used for booting via PXE.

How to determine PXE mac address when booting illumos via PXELinux/iPXE

In illumos, if you need to determine the interface which was used for booting via PXE then it's possible to use "boot-mac" pro...