dotlinux blog

Setting up a ‘PXE Network Boot Server’ for Multiple Linux Distribution Installations in RHEL/CentOS 7

In modern IT environments, especially data centers and large-scale deployments, installing operating systems on individual machines via USB drives or DVDs is inefficient and time-consuming. Preboot Execution Environment (PXE) network booting solves this problem by allowing client computers to boot and install an operating system directly from a server over the network.

This blog provides a comprehensive, step-by-step guide to setting up a robust PXE boot server on a RHEL (Red Hat Enterprise Linux) or CentOS 7 system. This server will be capable of serving multiple Linux distributions, giving you the flexibility to deploy different systems (like CentOS, Ubuntu, or Fedora) from a single central point. We will cover everything from configuring the DHCP and TFTP services to setting up the boot menus and file serving via HTTP.


2026-05

Table of Contents#

  1. Understanding the PXE Boot Process
  2. Prerequisites
  3. Network and Firewall Configuration
  4. Installing and Configuring the DHCP Server
  5. Installing and Configuring the TFTP Server
  6. Setting up the PXE Boot Environment (SYSLINUX)
  7. Configuring the HTTP Server for Installation Files
  8. Adding Multiple Linux Distributions
  9. Creating the PXE Boot Menu
  10. Testing the PXE Boot Server
  11. Troubleshooting Common Issues
  12. Conclusion
  13. References

1. Understanding the PXE Boot Process#

Before diving into the setup, it's crucial to understand the sequence of events during a PXE boot:

  1. Client Boots: The client machine is powered on and configured to boot from the network (NIC) in its BIOS/UEFI settings.
  2. DHCP Request: The client broadcasts a DHCP request on the network.
  3. DHCP Offer: The PXE server's DHCP service responds with an IP address lease and, critically, the location (next-server) of the TFTP server and the initial boot file (filename), typically pxelinux.0.
  4. TFTP Download: The client contacts the TFTP server and downloads the initial bootloader (pxelinux.0) and its configuration files (like pxelinux.cfg/default).
  5. Boot Menu: The bootloader presents a menu to the user (if configured) based on the downloaded configuration.
  6. Kernel and Initramfs: The client downloads the Linux kernel (vmlinuz) and initial RAM disk (initrd.img) for the selected OS via TFTP.
  7. Kernel Execution: The kernel is loaded into memory and starts execution.
  8. Installation: The kernel fetches the actual installation files (the OS repository) from a web (HTTP), FTP, or NFS server to begin the installation process.

Our setup will use HTTP for serving the installation repositories due to its speed and reliability.

2. Prerequisites#

  • A system running RHEL/CentOS 7 with a static IP address (e.g., 192.168.1.10).
  • Root or sudo privileges.
  • Sufficient disk space to host the ISO files of the Linux distributions you plan to serve (20-30 GB is a good starting point).
  • A network environment where you can run a DHCP server without conflict (ideally a isolated lab or a controlled subnet).

3. Network and Firewall Configuration#

Set a static IP address for your server. Edit the network configuration file (replace ens192 with your interface name).

sudo vi /etc/sysconfig/network-scripts/ifcfg-ens192

Ensure the configuration looks similar to this:

DEVICE=ens192
BOOTPROTO=static
ONBOOT=yes
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.1
DNS1=8.8.8.8
TYPE=Ethernet

Restart the network service:

sudo systemctl restart network

Configure the firewall to allow the required services (DHCP, TFTP, HTTP).

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

4. Installing and Configuring the DHCP Server#

Install the DHCP server package.

sudo yum install -y dhcp

Edit the DHCP configuration file /etc/dhcp/dhcpd.conf. We will configure it for a specific subnet.

sudo vi /etc/dhcp/dhcpd.conf

Add the following configuration, adjusting the subnet, range, and domain to match your network:

# A simple DHCP server configuration for PXE
authoritative;
default-lease-time 600;
max-lease-time 7200;
 
subnet 192.168.1.0 netmask 255.255.255.0 {
  range 192.168.1.100 192.168.1.200;
  option domain-name-servers 8.8.8.8;
  option routers 192.168.1.1;
  # PXE-specific settings
  next-server 192.168.1.10;  # IP address of your TFTP server (this machine)
  filename "pxelinux.0";     # Initial boot file
}

Start and enable the DHCP service.

sudo systemctl start dhcpd
sudo systemctl enable dhcpd

Important Warning: Do not run this DHCP server on a network that already has another DHCP server, as it will cause conflicts.

5. Installing and Configuring the TFTP Server#

The TFTP server is used to serve the initial boot files to the client.

Install the TFTP server and the xinetd super-server that will manage it.

sudo yum install -y tftp-server xinetd

Configure TFTP by editing the xinetd configuration file for TFTP.

sudo vi /etc/xinetd.d/tftp

Change the disable and server_args lines to match the following:

service tftp
{
        socket_type             = dgram
        protocol                = udp
        wait                    = yes
        user                    = root
        server                  = /usr/sbin/in.tftpd
        server_args             = -s /var/lib/tftpboot  # TFTP root directory
        disable                 = no                    # Change from 'yes' to 'no'
        per_source              = 11
        cps                     = 100 2
        flags                   = IPv4
}

Start and enable the xinetd service.

sudo systemctl start xinetd
sudo systemctl enable xinetd

6. Setting up the PXE Boot Environment (SYSLINUX)#

We will use the SYSLINUX bootloader, specifically the PXELINUX component.

Install the necessary package.

sudo yum install -y syslinux-tftpboot

This package installs the required files into /var/lib/tftpboot/. The key file we referenced in the DHCP configuration is pxelinux.0.

Create the directory structure for the PXE configuration and boot menus.

mkdir -p /var/lib/tftpboot/pxelinux.cfg
mkdir -p /var/lib/tftpboot/images
  • pxelinux.cfg/: Directory for boot menu configuration files.
  • images/: Directory to store kernel (vmlinuz) and initramfs (initrd.img) files for each OS.

Copy the menu module files for a nicer boot menu.

cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/vesamenu.c32 /var/lib/tftpboot/ # More graphical menu

7. Configuring the HTTP Server for Installation Files#

We'll use Apache to serve the full installation repositories (the contents of the ISO files).

Install the Apache web server.

sudo yum install -y httpd

Start and enable Apache.

sudo systemctl start httpd
sudo systemctl enable httpd

Create a directory to host the OS files. We'll use /var/www/html/os.

mkdir -p /var/www/html/os

8. Adding Multiple Linux Distributions#

8.1. Adding CentOS 7#

Download the CentOS 7 ISO or mount the ISO you have.

# If you have the ISO file:
mount -o loop /path/to/CentOS-7-x86_64-DVD-2009.iso /mnt
# Copy the entire contents to the web directory
cp -r /mnt/* /var/www/html/os/centos7/
umount /mnt

Copy the kernel and initramfs files to the TFTP images directory.

cp /var/www/html/os/centos7/images/pxeboot/vmlinuz /var/lib/tftpboot/images/centos7-vmlinuz
cp /var/www/html/os/centos7/images/pxeboot/initrd.img /var/lib/tftpboot/images/centos7-initrd.img

8.2. Adding Ubuntu 20.04 LTS#

Download the Ubuntu 20.04 LTS ISO and mount it.

mount -o loop /path/to/ubuntu-20.04.3-live-server-amd64.iso /mnt
mkdir -p /var/www/html/os/ubuntu2004
cp -r /mnt/* /var/www/html/os/ubuntu2004/
umount /mnt

Copy the kernel and initramfs files. For Ubuntu, they are located in the casper directory.

cp /var/www/html/os/ubuntu2004/casper/vmlinuz /var/lib/tftpboot/images/ubuntu2004-vmlinuz
cp /var/www/html/os/ubuntu2004/casper/initrd /var/lib/tftpboot/images/ubuntu2004-initrd.img

9. Creating the PXE Boot Menu#

Now, create the main PXE configuration file. This file is read by the pxelinux.0 bootloader.

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

Add the following configuration. This creates a menu with options for CentOS 7, Ubuntu 20.04, and a local boot option.

DEFAULT vesamenu.c32
PROMPT 0
TIMEOUT 100
 
MENU TITLE PXE Server - Main Menu
 
LABEL centos7
    MENU LABEL Install CentOS 7
    KERNEL images/centos7-vmlinuz
    APPEND initrd=images/centos7-initrd.img inst.repo=http://192.168.1.10/os/centos7 inst.lang=en_US.UTF-8 inst.keymap=us quiet
 
LABEL ubuntu2004
    MENU LABEL Install Ubuntu 20.04 LTS
    KERNEL images/ubuntu2004-vmlinuz
    APPEND initrd=images/ubuntu2004-initrd.img root=/dev/rd/0 rw url=http://192.168.1.10/os/ubuntu2004/ubuntu-20.04.3-live-server-amd64.iso automatic-oui=true cloud-config-url=/dev/null quiet
 
LABEL local
    MENU LABEL Boot from Local Drive
    LOCALBOOT 0

Explanation of key APPEND parameters:

  • For CentOS: inst.repo points to the HTTP location of the installation files.
  • For Ubuntu: url points directly to the ISO file (or the network installer mini ISO can be used for a more efficient setup). The cloud-config-url=/dev/null bypasses cloud-init questions.

Set the correct permissions for the TFTP directory.

chown -R nobody: /var/lib/tftpboot
chmod -R 755 /var/lib/tftpboot

10. Testing the PXE Boot Server#

  1. Configure a client machine to boot from the network (PXE) in its BIOS/UEFI settings.
  2. Power on the client machine. It should receive an IP from your DHCP server.
  3. You should see the PXE boot menu with the options you configured.
  4. Select an option (e.g., "Install CentOS 7") and the installation should begin.

11. Troubleshooting Common Issues#

  • Client gets no IP address: Check if the DHCP service is running (systemctl status dhcpd). Ensure there's no other DHCP server on the network. Check firewall rules.
  • Client gets IP but fails to download pxelinux.0: Verify the next-server and filename options in /etc/dhcp/dhcpd.conf. Check if xinetd and the TFTP service are running (systemctl status xinetd). Check the TFTP root directory permissions.
  • Menu appears but OS installation fails: Check the paths to the vmlinuz and initrd.img files in the pxelinux.cfg/default file. Verify that the HTTP server is accessible and the OS files are correctly copied. You can test by trying to access http://192.168.1.10/os/centos7/ from another machine on the network.
  • Use the logs: Check /var/log/messages on the server for DHCP and general errors. Check /var/log/httpd/error_log for web server issues.

12. Conclusion#

You have now successfully set up a versatile PXE boot server on RHEL/CentOS 7. This server can dramatically streamline the process of installing Linux on multiple machines. You can easily extend this setup by adding more distributions (like Fedora, Debian, etc.) by following the same pattern: mount the ISO, copy the files to the web directory, and add a new menu entry pointing to the correct kernel and initramfs.

This is a foundational setup. For production environments, you might want to explore more advanced options like Kickstart files for unattended CentOS installations or Preseeds for Ubuntu to achieve full automation.

13. References#