How to Turn Your OpenWRT Router into a PXE Server with netboot.xyz
How to Turn Your OpenWRT Router into a PXE Server with netboot.xyz
Have you ever dreamed of installing an operating system on a machine without the hassle of searching for, burning, and swapping USB drives or DVDs? A PXE (Preboot Execution Environment) server provides a much more streamlined and professional approach by allowing you to boot and install operating systems directly over your local network.
By leveraging an OpenWRT router and the versatile netboot.xyz tool, you can transform your network gateway into a powerful, lightweight deployment server. In this guide, we will walk you through the complete process of setting up a PXE server on OpenWRT, using a USB drive as a dedicated TFTP storage medium to ensure high performance and ease of use.
Prerequisites
Before you begin, ensure you have the following:
- An OpenWRT Router: This guide was successfully tested on version 19.07, but the steps are generally applicable to newer versions (like 21.02 or 22.03).
- A Spare USB Drive: A small USB stick will serve as your TFTP storage. Note: All existing data on this drive will be erased during the process.
- Command Line Access: You should be comfortable using the Linux command line via SSH.
- Network Access: An active internet connection for downloading necessary packages and bootloader files.
Step 1: Prepare the USB Storage
To ensure reliability and performance, we will format the USB drive using the ext4 file system and label it tftp. This makes it easy to identify and mount automatically by the system.
Warning
This process will erase all existing data on your USB drive. Back up any important files before proceeding.
First, identify your USB drive's partition (e.g., /dev/sdc1) using lsblk or fdisk -l, then run:
mkfs.ext4 -L tftp /dev/sdXX
Replace /dev/sdXX with your actual partition path (e.g., /dev/sda1).
Step 2: Prepare the OpenWRT Environment
Next, we need to install the drivers and utilities required to handle USB storage, the ext4 file system, and the TFTP service.
-
Install Required Packages: Connect to your router via SSH and execute the following:
opkg update opkg install usbutils kmod-usb-storage block-mount kmod-fs-ext4 wget mkdir -p /mnt/usb/Note: We install
wgetexplicitly because the default Dropbear version lacks support for SSL/HTTPS, which is required for downloading files from the netboot.xyz servers. -
Configure Automatic Mounting: To ensure the USB drive is available even after a reboot, we will configure OpenWRT to mount the
tftppartition to/mnt/usb.Run these commands to update the system configuration:
uci set fstab.@mount[0].label=tftp uci set fstab.@mount[0].target=/mnt/usb uci set fstab.@mount[0].options=noatime,nodiratime uci commit block mount
Step 3: Download netboot.xyz Bootloaders
Instead of manually managing dozens of ISO files, we will use netboot.xyz. This powerful tool provides a menu-driven interface that downloads and boots various operating systems on demand over the network, saving you significant time and storage space.
-
Navigate to the mounted USB directory:
cd /mnt/usb/ -
For Legacy (PCBIOS) Systems:
wget --no-check-certificate https://boot.netboot.xyz/ipxe/netboot.xyz.kpxe -
For UEFI Systems:
wget --no-check-certificate https://boot.netboot.xyz/ipxe/netboot.xyz.efi
Step 4: Configure the DHCP/TFTP Server (dnsmasq)
The dnsmasq service is responsible for handling DHCP requests and serving the bootloader files via the TFTP protocol.
- Enable TFTP and Define the Boot File:
Configure
dnsmasqto serve files from your USB drive and set the default bootloader:uci set dhcp.@dnsmasq[0].enable_tftp=1 uci set dhcp.@dnsmasq[0].tftp_root=/mnt/usb/ uci set dhcp.@dnsmasq[0].dhcp_boot=netboot.xyz.kpxe uci commit /etc/init.d/dnsmasq restartNote: In many modern setups,
netboot.xyz.kpxeis versatile, but if you specifically need UEFI boot, you may need to adjust the boot file setting tonetboot.xyz.efiin some configurations. For a general-purpose setup, the above is highly effective.
Step 5: Troubleshooting: Resolving the IPv6 Conflict
A common issue when using OpenWRT as a PXE server is a conflict with Local IPv6 DNS. During testing, it was observed that the router announcing itself as an IPv6 DNS server can interfere with iPXE DNS lookups, even when the client is booting via IPv4.
The Fix:
- Log in to the OpenWRT web interface (LuCI).
- Navigate to Network $\rightarrow$ Interfaces.
- Edit the LAN interface.
- Go to the DHCP Server tab, then the IPv6 Settings sub-tab.
- Uncheck "Advertise router advertisements" or "Announce itself as a DNS server" (the exact wording may vary depending on your OpenWRT version).
- Click Save & Apply.

Summary Overview
| Component | Purpose | Action / Command |
|---|---|---|
| USB Drive | TFTP Storage | mkfs.ext4 -L tftp /dev/sdXX |
| OpenWRT | System Drivers | opkg install kmod-fs-ext4 block-mount ... |
| Bootloader | netboot.xyz | wget ... netboot.xyz.efi |
| Network | TFTP/DHCP | uci set dhcp.@dnsmasq[0].enable_tftp=1 |
Conclusion
You have successfully transformed your OpenWRT router into a versatile PXE server! This setup is an invaluable tool for technicians, home lab enthusiasts, or anyone who frequently reinstalls or updates operating systems on various machines. By leveraging netboot.xyz, you now have access to a massive, ever-growing library of OS installers, all accessible via a simple network boot.