Monday, 22 October 2018

How to Setup a PXE Boot Server in RHEL/CentOS 7

Setup a PXE Boot Server in RHEL/CentOS 7

PXE (pronounced as pixie) is the abbreviation of Preboot eXecution Environment. It is a standardized specification of a client-server environment, where PXE-enabled clients can boot their machines by using PXE boot images retrieved from a preconfigured PXE Boot Server.

In this article, we will setup a PXE boot server in RHEL/CentOS 7, and add option to install Red Hat Enterprise Linux 7 therein.

Our PXE boot server requires different services such as DHCP, TFTP and FTP to function properly. Although, it is not necessary to configure all these services on a single machine, and if you have a running FTP server, you may place the required installation files on your existing FTP server. Similarly, if you have a DHCP server configured for your network, you may define the DHCP configurations therein.

However, for simplicity, we will configure all these services on the same machine.

Note: In this article, we are performing everything from CLI, therefore, it is highly recommended that, you should have Linux Pocket Guide: Essential Commands by O'Reilly Media for quick reference.

Setup a PXE Boot Server in RHEL/CentOS 7

Table of Contents:


System Specification:

We have a Linux machine with following machine. We will setup it as the PXE boot server.

  • CPU - 2 Core (2.4 Mhz)
  • Memory - 2 GB
  • Storage - 50 GB
  • Operating System - RHEL 7.5
  • Hostname -
  • IP Address -


Configure DHCP Service:

Connect to using ssh.

Install DHCP server using yum.

# yum install -y dhcp

Configure DHCP service.

# cat >> /etc/dhcp/dhcpd.conf << EOF
> #DHCP configuration for PXE boot server
> ddns-update-style interim;
> ignore client-updates;
> authoritative;
> allow booting;
> allow bootp;
> allow unknown-clients;
> subnet
> netmask
> {
> range;
> option domain-name-servers;
> option domain-name "";
> option routers;
> option broadcast-address;
> default-lease-time 600;
> max-lease-time 7200;
> #PXE boot server
> next-server;
> filename "pxelinux.0";
> }

Start and enable dhcpd.service.

# systemctl start dhcpd.service && systemctl enable dhcpd.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/dhcpd.service.

Allow DHCP service through Linux firewall. Also, proxy-dhcp port is required for propagation of TFTP server’s IP Address.

# firewall-cmd --permanent --add-service={dhcp,proxy-dhcp}
# firewall-cmd --reload


Configure TFTP Service:

Install TFTP (Trivial FTP) server using yum.

# yum install -y tftp-server

Start and enable tftp.service.

# systemctl start tftp.service && systemctl enable tftp.service

Allow TFTP service through Linux firewall.

# firewall-cmd --permanent --add-service=tftp
# firewall-cmd --reload


Configure FTP Service:

FTP Service is required to share the OS Installation media to PXE boot clients. Some system administrators use NFS instead of FTP service. However, if we use NFS then we have to configure Samba as well, when we are going to add Microsoft Windows OS installation options to our PXE boot server. Therefore, it is good to use a single common technology to share the OS installation media for different operating systems. HTTP is also a good alternative of FTP, and can be used to share OS installation media.

Install VSFTPD server using yum.

# yum install -y vsftpd

Start and enable vsftpd.service.

# systemctl enable vsftpd.service && systemctl start vsftpd.service
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/vsftpd.service.

Allow FTP Service through Linux firewall.

# firewall-cmd --permanent --add-service=ftp
# firewall-cmd --reload


Installing Syslinux:

Syslinux package provides various bootloaders including FAT filesystem to boot into Microsoft Windows environment.

Install syslinux package via yum.

# yum install -y syslinux


Configure PXE Boot Server:

Copy necessary bootloaders (provided by syslinux) to /var/lib/tftpboot directory.

# cp -v /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
â/usr/share/syslinux/pxelinux.0â -> â/var/lib/tftpboot/pxelinux.0â

# cp -v /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
â/usr/share/syslinux/menu.c32â -> â/var/lib/tftpboot/menu.c32â

# cp -v /usr/share/syslinux/mboot.c32 /var/lib/tftpboot/
â/usr/share/syslinux/mboot.c32â -> â/var/lib/tftpboot/mboot.c32â

# cp -v /usr/share/syslinux/chain.c32 /var/lib/tftpboot/
â/usr/share/syslinux/chain.c32â -> â/var/lib/tftpboot/chain.c32â

Create necessary directories.

# mkdir /var/lib/tftpboot/pxelinux.cfg
# mkdir -p /var/lib/tftpboot/networkboot/rhel7
# mkdir /var/ftp/pub/rhel7

Copy contents of RHEL 7.5 ISO to /var/ftp/pub/rhel7. we have mounted RHEL 7.5 ISO at /mnt/iso, therefore, we are using following command for copying contents of ISO file.

# cp -rf /mnt/iso/ /var/ftp/pub/rhel7

Copy boot images of RHEL 7.5 to /var/lib/tftpboot/networkboot/rhel7 directory.

# cp /var/ftp/pub/rhel7/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/networkboot/rhel7/

Configure PXE boot menu and add Red Hat Enterprise Linux 7 installation option therein.

# cat >> /var/lib/tftpboot/pxelinux.cfg/default << EOF
> default menu.c32
> prompt 0
> timeout 30
> menu title Ahmer's PXE Menu
> label Install RHEL 7.5
> kernel /networkboot/rhel7/vmlinuz
> append initrd=/networkboot/rhel7/initrd.img inst.repo=

Connect a new system to network and boot it. The new system will automatically obtain an IP Address from our DHCP Server and obtain the PXE boot menu from PXE Server and display it as follows:


Since, we have only one installation option so far, therefore, press <ENTER> to start installation.


We have successfully setup a PXE boot server in RHEL/CentOS 7. The installation process here is not automated. In our next article Kickstart: Automate PXE Client Installations, we will transform the same manual installation process to an automated installation with predefined configurations using Kickstart.

If you find this article useful? Don't you mind support us by Buy Me A Coffee


  1. Question: How would I set up dhcp relay (if I wanted to keep my current dhcp server in use)

    1. dhcp package also provides dhcrelay.service.
      You can use it to configure a dhcp relay on CentOS 7.

  2. Just would like to say that your step by step process is so precise it works after I followed it. Now I'm going to do the next step which is Kickstart to automate PXE installation :)

  3. Thanks so much Boss

  4. Great it possible to have one PXE server with multiple OS, say Centos 6 and Centos 7 for example?

    1. Yes. Please see my other articles on PXE section.

  5. how can i add other linux distros as well as windows in this pxe server.

    1. Every distro has different PXE configurations. I have demonstrated CentOS 7, CentOS 6 and Ubuntu 18. You can follow these guidelines to add other distros. But you have to do some R&D as well respective to the relevant distro.

  6. Hello Sir,
    How i can install ubuntu desktop in a pxe server . Using a netboot's file it directly boots to server . How i can mange for desktop

  7. Nice article,
    I think I've followed the instruction as best as I could but when I try to PXE boot the client machine I get PXE-E18: server response timeout. TFTP, FTP, and DHCP are all working from same client. Any ideas? Thanks

    1. PXE-E18: server response timeout may be caused due to network connectivity failures. Please ensure that your machine can communicate to the PXE boot server.

    2. I have connectivity because I can ping it, transfer to and from with ftp and tftp, and it is assigning an IP address to the current host.

    3. Please discuss this on our Facebook page.

  8. Thanks for precise step by step config. Please also share the method to load multiple ISOs (Linux + Windows + ESXi)

    1. Thank for the appreciation. We have already write on Linux and Windows ISOs. We will try to write a same article for ESXi soon.

  9. Centos os hang on Reached target Basic System

    1. We need more information to resolve this problem. Please discuss it on our Facebook page.


© 2022 CentLinux. All Rights Reserved.