Network Boot Linux (PXE) on Ubuntu/Debian

Overview

PXE (Preboot Execution Environment) allows you to boot and install Linux over the network without USB drives or optical media. This is ideal for deploying Linux to multiple machines simultaneously.

This guide sets up a PXE server on Ubuntu/Debian.

What You Need

Step 1: Install Required Services

sudo apt update
sudo apt install dhcpd tftpd-hpa syslinux-common apache2

Step 2: Configure DHCP Server

sudo nano /etc/dhcp/dhcpd.conf

Add this configuration (adjust for your network):

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 domain-name-servers 8.8.8.8, 8.8.4.4;
  filename "pxelinux.0";
  next-server 192.168.1.10;
}

Note: Replace next-server with your PXE server's IP address.

Configure DHCP Interface

# Edit the interface configuration
sudo nano /etc/default/isolated-dhcp-server

# Add your network interface, e.g.:
INTERFACESv4="eth0"

Restart DHCP

sudo systemctl restart isc-dhcp-server
sudo systemctl enable isc-dhcp-server

Step 3: Configure TFTP Server

# Edit TFTP config
sudo nano /etc/default/tftpd-hpa

# Set these values:
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"

Copy Bootloader Files

sudo mkdir -p /var/lib/tftpboot/pxelinux.cfg
sudo cp /usr/lib/syslinux/modules/bios/pxelinux.0 /var/lib/tftpboot/
sudo cp /usr/lib/syslinux/modules/bio/menu.c32 /var/lib/tftpboot/
sudo cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /var/lib/tftpboot/

Create Boot Menu

sudo nano /var/lib/tftpboot/pxelinux.cfg/default

Add this content:

DEFAULT menu
PROMPT 0
TIMEOUT 60

MENU TITLE PXE Boot Menu

LABEL ubuntu-server
    MENU LABEL Install Ubuntu Server
    KERNEL ubuntu-installer/amd64/linux
    APPEND initrd=ubuntu-installer/amd64/initrd.gz ip=dhcp auto=true priority=curl http://192.168.1.10/ubuntu/preseed.cfg

Restart TFTP

sudo systemctl restart tftpd-hpa

Step 4: Set Up HTTP Repository

Mount or copy the Linux ISO contents to Apache's web directory:

# Create mount point and mount ISO
sudo mkdir -p /var/www/html/ubuntu
sudo mount -o loop /path/to/ubuntu-server.iso /mnt/ubuntu
sudo cp -r /mnt/ubuntu/* /var/www/html/ubuntu/

# Or download files directly:
sudo apt install debmirror
# Configure and mirror the repository

Create Preseed File (Optional — for unattended installs)

sudo nano /var/www/html/ubuntu/preseed.cfg

A basic preseed file automates partitioning, user creation, and package selection. See Ubuntu documentation for full syntax.

Restart Apache

sudo systemctl restart apache2

Step 5: Boot Client Machines

  1. Connect the target machine to the same network as the PXE server
  2. Enter BIOS/UEFI and enable "PXE Boot" or "Network Boot"
  3. Set Network/PXE as the first boot device (or use one-time boot menu)
  4. The machine should receive an IP via DHCP and load the PXE menu
  5. Select the Linux installation option and follow prompts

Firewall Configuration

If UFW is enabled, allow required ports:

sudo ufw allow 67/udp   # DHCP server
sudo ufw allow 68/udp   # DHCP client
sudo ufw allow 69/udp   # TFTP
sudo ufw allow 80/tcp   # HTTP

Troubleshooting

Debug with verbose TFTP

# Watch TFTP requests in real-time
sudo tcpdump -i eth0 port 69