Network Boot Linux (PXE) on Fedora/RHEL

Overview

This guide sets up a PXE boot server on Fedora or RHEL to network-boot and install Linux on client machines. Uses dnsmasq for combined DHCP/TFTP/DNS services.

What You Need

Step 1: Install Packages

# Fedora
sudo dnf install dnsmasq syslinux tftp-server httpd

# RHEL/CentOS
sudo yum install dnsmasq syslinux tftp-server httpd

# Enable services
sudo systemctl enable --now dnsmasq httpd

Step 2: Configure dnsmasq

sudo nano /etc/dnsmasq.conf

Add this configuration:

# DHCP range
dhcp-range=192.168.1.100,192.168.1.200,12h

# Gateway and DNS
dhcp-option=3,192.168.1.1
dhcp-option=6,8.8.8.8,8.8.4.4

# PXE boot file
dhcp-boot=pxelinux.0

# TFTP root
enable-tftp
tftp-root=/var/lib/tftpboot

# Listen on specific interface
interface=enp0s3

Copy Boot Files

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

Create Boot Menu

sudo nano /var/lib/tftpboot/pxelinux.cfg/default
DEFAULT menu
TIMEOUT 60
PROMPT 0

MENU TITLE PXE Boot Menu

LABEL fedora
    MENU LABEL Install Fedora Server
    KERNEL fedora/vmlinuz
    APPEND initrd=fedora/initrd.img ip=dhcp repo=http://192.168.1.10/fedora

Restart dnsmasq

sudo systemctl restart dnsmasq

Step 3: Set Up Installation Repository

# Mount ISO to web directory
sudo mkdir -p /var/www/html/fedora
sudo mount -o loop /path/to/Fedora-Server-dvd-x86_64.iso /mnt/fedora
sudo cp -r /mnt/fedora/* /var/www/html/fedora/

# Set permissions
sudo chmod -R 755 /var/www/html/fedora

Configure SELinux (RHEL/Fedora)

# Allow HTTPD to serve files
sudo chcon -Rt httpd_sys_content_t /var/www/html/fedora

# If using Firewalld:
sudo firewall-cmd --permanent --add-service=dhcp
sudo firewall-cmd --permanent --add-service=tftp
sudo firewall-cmd --permanent --add-service=http
sudo firewall-cmd --reload

Step 4: Boot Clients via PXE

  1. Connect client to the same network
  2. Enable PXE boot in BIOS/UEFI
  3. Select Network Boot from boot menu
  4. The dnsmasq server assigns IP and loads the bootloader
  5. Select Fedora/RHEL installation from the menu

Kickstart for Unattended Installs

Create a kickstart file to automate installation:

# Generate from existing system (RHEL/Fedora)
sudo systemctl enable ks-script
sudo python3 -c "import pykickstart; print('pykickstart available')"

# Basic kickstart file at /var/www/html/ks.cfg:
# text
# lang en_US.UTF-8
# keyboard us
# network --bootproto dhcp
# rootpw yourpassword
# firewall --disabled
# authconfig --enableshadow --passalgo=sha512
# selinux --enforcing
# reboot

# %packages
# @^server-product-environment
# @core
# %end

Add to pxelinux.cfg/default:

APPEND initrd=fedora/initrd.img ip=dhcp repo=http://192.168.1.10/fedora ks=http://192.168.1.10/ks.cfg

Troubleshooting

Debug Commands

# Check dnsmasq logs
sudo journalctl -u dnsmasq -f

# Test TFTP locally
tftp 127.0.0.1
get pxelinux.0
quit