How to Setup a Linux PXE Server

Share on Social Media

Unlock the power of automated installations with a Linux PXE server—save time, boost efficiency, and stay ahead of the curve. Don’t fall behind—set up your PXE environment today! #centlinux #linux #pxe

What is PXE Server?

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.

Problem Statement

In this article, we will setup a Linux PXE server in RHEL 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.

How to Setup a Linux PXE Server
How to Setup a Linux PXE Server

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 – pxe-server.itlab.com
  • IP Address – 192.168.116.41/24

Recommended Training: The Linux Command Line Bootcamp: Beginner To Power User from Colt Steele

3998050 2ed8
show?id=oLRJ54lcVEg&bids=1074530

Configure DHCP Service

Connect to pxe-server.itlab.com 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 192.168.116.0
netmask 255.255.255.0
{
range 192.168.116.100 192.168.116.199;
option domain-name-servers 192.168.116.2;
option domain-name "itlab.com";
option routers 192.168.116.2;
option broadcast-address 192.168.116.255;
default-lease-time 600;
max-lease-time 7200;
#PXE boot server
next-server 192.168.116.41;
filename "pxelinux.0";
}
EOF

Start and enable dhcpd.service.

systemctl start dhcpd.service
systemctl enable 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

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 /usr/share/syslinux/pxelinux.0 /var/lib/tftpboot/
cp /usr/share/syslinux/menu.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/mboot.c32 /var/lib/tftpboot/
cp /usr/share/syslinux/chain.c32 /var/lib/tftpboot/

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=ftp://192.168.116.41/pub/rhel7
EOF

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:

PXE Menu (BIOS)
PXE Menu (BIOS)

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

Install Linux over PXE
Install Linux over PXE

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.

Frequently Asked Questions (FAQs)

What is a PXE server, and what is it used for?
A PXE (Preboot eXecution Environment) server allows computers to boot and install an operating system over a network, eliminating the need for physical media like USB drives or DVDs. It’s commonly used for deploying Linux systems across multiple machines.

What do I need to set up a PXE server?
You need a Linux machine as the server, a DHCP server to assign IP addresses, a TFTP server to transfer boot files, and an NFS/HTTP/FTP server to host the installation files. All these services can run on the same machine.

Do I need a separate DHCP server for PXE?
If your network already has a DHCP server, you’ll need to configure it to point to your PXE server. If not, you can set up a DHCP server on the same machine as your PXE server.

Can I use PXE to install different Linux distributions?
Yes, you can configure the PXE server to offer multiple Linux distributions by adding their respective boot files and installation sources to the server.

Is a PXE server secure?
PXE itself doesn’t include encryption, so it’s best used in a trusted local network. For security, restrict access via firewall rules and ensure only authorized clients can boot from the PXE server.

Final Thoughts

Setting up a Linux PXE server isn’t just a cool trick—it’s a game-changer for sysadmins and IT teams who value speed, scalability, and control. You’ve now seen how simple it can be to configure your network for unattended OS installations and deployments. Don’t wait until you’re knee-deep in repetitive setups or lagging behind competitors who’ve already streamlined their infrastructure.

Take action now: implement what you’ve learned and experience the freedom and power of PXE. The future of efficient Linux deployment is already here—will you be part of it, or play catch-up later?

Need expert AWS and Linux system administration? From cloud architecture to server optimization, I provide reliable and efficient solutions tailored to your needs. Hire me on Fiverr today!

Looking for something?

24 responses to “How to Setup a Linux PXE Server”

  1. Anonymous Avatar
    Anonymous

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

  2. Ahmer M Avatar

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

  3. marklorenz_007 Avatar

    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 🙂

  4. Ahmer M Avatar

    Thanks for the appreciation.

  5. Anonymous Avatar
    Anonymous

    Thanks so much Boss

  6. Anonymous Avatar
    Anonymous

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

  7. Ahmer M Avatar

    Yes. Please see my other articles on PXE section.

  8. Anonymous Avatar
    Anonymous

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

  9. Ahmer M Avatar

    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.

  10. Anonymous Avatar
    Anonymous

    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

  11. Ahmer M Avatar

    I will work on this topic soon.

  12. Anonymous Avatar
    Anonymous

    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

  13. Ahmer M Avatar

    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.

  14. Anonymous Avatar
    Anonymous

    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.

  15. Ahmer M Avatar

    Please discuss this on our Facebook page.

  16. Patric Avatar

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

  17. Ahmer M Avatar

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

  18. Anonymous Avatar
    Anonymous

    Centos os hang on Reached target Basic System

  19. Ahmer M Avatar

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

  20. Anonymous Avatar
    Anonymous

    all step done. with no error.

    i tested in other vm machine. centos successfully installed. but next day , again i tested. on other vm machine.

    1. dhcp server assigned ip address
    2. install screen appeared
    3. only counter is working. like automatic boot. 3.2.1…. again automatic boot 3.2.1 .. this time no success. where is problem?

  21. Ahmer M Avatar

    It is very difficult to identify the cause of this problem with just limited information. However, let me have a wild guess! Check you FTP server.

  22. Anonymous Avatar
    Anonymous

    i followed all step with no error. but when i start other vm. dhcp assigned ip address but stack on install redhat 7.5 and shows automatic boot in 3.2.1 counter with no success and repeat counter 3.2.1. i can't do anything

  23. Ahmer M Avatar

    Already answered in below comment.

Leave a Reply

Available for Amazon Prime