Create IPv4 hex filenames for PXELINUX

The PXE network booting system distributed by the Syslinux Project is widely used for installing operating systems on networks of all sizes. It’s used in conjunction with DHCP and TFTP servers.

The PXELINUX bootloader will look for a succession of files. You should read the official documentation to get the full story, but the short version is that their filenames are based on

  1. Client UUID (not always present)
  2. Client Ethernet MAC
  3. IPv4 address in hexadecimal
  4. A file named default

The part that usually trips me up is converting an IPv4 address to hex. So I hacked up the pxehex script. It will not only produce a single-address filename but will (if asked nicely) print all the address-based filenames that can be used for any given IPv4 address.