Network Nirvana: PXE Boot with OPNsense, netboot.xyz, and Unraid

Network Nirvana: PXE Boot with OPNsense, netboot.xyz, and Unraid

We've all been there – tinkering with our devices, pushing boundaries, and sometimes, well, messing things up. That's exactly what happened to me with my old notebook. In a moment of misguided experimentation, I managed to botch the BIOS settings so badly that booting from USB became impossible. Talk about a facepalm moment!
But as they say, necessity is the mother of invention. With USB booting off the table, I found myself exploring an alternative I'd heard about but never used: PXE booting. Little did I know, this mishap would lead me down a fascinating path of network-based boot solutions.

What is PXE?

PXE, which stands for Preboot Execution Environment, is a powerful protocol that allows a computer to boot from a network interface independently of available data storage devices or installed operating systems. Developed by Intel, PXE is part of the Wired for Management (WfM) specification and has become a standard feature in modern network cards and BIOS/UEFI implementations.

How PXE works

  • Network Interface Initialization: When a PXE-capable device boots, it initializes the network interface card (NIC) before any other boot devices.
  • DHCP Discovery: The client broadcasts a DHCP discover message with a PXE-specific option to locate a PXE boot server.
  • DHCP Offer: A DHCP server responds with an IP address offer and the location of boot files.
  • TFTP Transfer: The client uses TFTP (Trivial File Transfer Protocol) to download a small network bootstrap program (NBP) from the specified server.
  • NBP Execution: This bootstrap program is executed, which typically loads additional files or a lightweight OS kernel.
  • Boot Process: The downloaded OS or boot image then takes control of the boot process.

One of the key advantages of PXE is its ability to work with a bare-metal system, requiring no pre-existing OS or bootloader. This makes it invaluable for scenarios like mine, where traditional boot methods are unavailable, as well as for large-scale deployments, system recovery, and diskless workstations.

After experiencing the flexibility and power of PXE booting, I've decided to use it for all my future installations. Not only does it provide a consistent and controlled environment for system setup, but it also allows me to easily manage and update boot images centrally. To make this process even smoother, I've discovered netboot.xyz, a fantastic service that simplifies PXE booting by providing a curated collection of operating systems and utilities accessible via network boot.

This eliminates the need to maintain my own extensive library of boot images. Furthermore, I've leveraged my Unraid server to host a Docker container running netboot.xyz, ensuring I always have access to the latest boot options. To tie it all together, I'm using OPNsense, a powerful open-source firewall and routing platform, to handle DHCP distribution, seamlessly integrating PXE boot options into my network infrastructure. This combination of tools has transformed what was once a limitation into a streamlined, efficient system for managing all my installations and recovery needs.