Към съдържанието

How to Turn Your OpenWRT Router into a PXE Server with netboot.xyz

24.11.2026

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.

  1. 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 wget explicitly because the default Dropbear version lacks support for SSL/HTTPS, which is required for downloading files from the netboot.xyz servers.

  2. Configure Automatic Mounting: To ensure the USB drive is available even after a reboot, we will configure OpenWRT to mount the tftp partition 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.

  1. Navigate to the mounted USB directory:

    cd /mnt/usb/
  2. For Legacy (PCBIOS) Systems:

    wget --no-check-certificate https://boot.netboot.xyz/ipxe/netboot.xyz.kpxe
  3. 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.

  1. Enable TFTP and Define the Boot File: Configure dnsmasq to 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 restart

    Note: In many modern setups, netboot.xyz.kpxe is versatile, but if you specifically need UEFI boot, you may need to adjust the boot file setting to netboot.xyz.efi in 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:

  1. Log in to the OpenWRT web interface (LuCI).
  2. Navigate to Network $\rightarrow$ Interfaces.
  3. Edit the LAN interface.
  4. Go to the DHCP Server tab, then the IPv6 Settings sub-tab.
  5. Uncheck "Advertise router advertisements" or "Announce itself as a DNS server" (the exact wording may vary depending on your OpenWRT version).
  6. Click Save & Apply.

local-ipv6-dns-server

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.