PUBLIC NODE *** READY ***
NODE 01
COMMAND: RUN LOGS PATH: /LOGS/2024-07-29-NETBOOTING-CHAPTER-1 LINK: ONLINE
LOG.31

Netbooting: Chapter 1 — Basic Setup with netboot.xyz

MODE: READ

FILE 2024-07-29-netbooting-chapter-1.log

DATE

TAGS PXE TFTP DHCP netboot.xyz

Set up DHCP, TFTP and PXELINUX to boot recovery and installation tools over the network.

Network booting is useful when an installation breaks or a recovery, diagnostics or installer environment is needed quickly—without first preparing a USB stick.

How it works

  1. Configure the network interface as a boot device in BIOS or UEFI.
  2. The PXE ROM requests an address and boot file from DHCP.
  3. The client downloads that boot file via TFTP.
  4. PXELINUX presents a menu.
  5. From there, another operating system or tool can be bootstrapped.

Preparation

This example uses a Debian-based server as DHCP, gateway and TFTP host. If DHCP already exists, set the TFTP server address and boot file there. Some servers expose these as options 67 and 150.

1. Install packages

apt install tftpd-hpa tftp-hpa syslinux pxelinux
apt install isc-dhcp-server

2. Configure DHCP

Edit /etc/dhcp/dhcpd.conf:

subnet 192.168.1.0 netmask 255.255.255.0 {
    range 192.168.1.100 192.168.1.200;
    option routers 192.168.1.1;
    option broadcast-address 192.168.1.255;
    option domain-name-servers 192.168.1.1, 1.1.1.1;

    next-server 192.168.1.1;
    filename "pxelinux.0";
}

3. Configure TFTP

Edit /etc/default/tftpd-hpa:

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="192.168.1.1:69"
TFTP_OPTIONS="--secure"

4. Prepare the TFTP directory

mkdir -p /var/lib/tftpboot/pxelinux.cfg
touch /var/lib/tftpboot/pxelinux.cfg/default
cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /var/lib/tftpboot/
cp /usr/lib/syslinux/modules/bios/menu.c32 /var/lib/tftpboot/
cp /usr/lib/syslinux/modules/bios/libcom32.c32 /var/lib/tftpboot/
cp /usr/lib/syslinux/modules/bios/libutil.c32 /var/lib/tftpboot/

5. Create a PXE menu

Edit /var/lib/tftpboot/pxelinux.cfg/default:

DEFAULT menu.c32
PROMPT 0
TIMEOUT 300
ONTIMEOUT local

MENU TITLE PXE Boot Menu
LABEL local
    MENU LABEL Boot from local drive
    LOCALBOOT 0

LABEL Netboot.xyz
    MENU LABEL Netboot.xyz
    KERNEL netboot.xyz.kpxe

6. Add netboot.xyz

wget https://boot.netboot.xyz/ipxe/netboot.xyz.kpxe \
  -O /var/lib/tftpboot/netboot.xyz.kpxe

7. Restart and enable services

systemctl restart isc-dhcp-server
systemctl restart tftpd-hpa
systemctl enable isc-dhcp-server
systemctl enable tftpd-hpa

Test the setup

A virtual machine without a disk is a convenient test client. Bridge its network adapter and put network boot first in its boot order. A physical machine works as well.

netboot.xyz provides a large menu of network-bootable installers and recovery tools, making it a useful next stage after the basic PXE path works.