A Preboot eXecution Environment server offers the needed resources to clients that were configured to boot from one of its network devices instead of booting from the classic mass storage options (SSD/HDD/DVD).
For this setup we will install the following packages:
- DNSMASQ – a light DNS Forwarder that support DNS and DHCP services with support for PXE and TFTP
- Syslinux – a linux boot loader for networking booting
- TFTP Server – a server which allow images to be downloaded via network
- VSFTPD Server – host for the locally mounted mirrored DVD images
Step 1: Setup DNSMASQ Server
# dnf install dnsmasq
Once it is installed we will find default configuration file under /etc/dnsmasq.conf. Let’s change it according our network settings.
interface=enp0s3,lo
#bind-interfaces
domain=0x01
# DHCP range-leases
dhcp-range= enp0s3,10.0.0.3,10.0.0.254,255.255.255.0,1h
# PXE
dhcp-boot=pxelinux.0,pxeserver,10.0.0.2
# Gateway
dhcp-option=3,10.0.0.1
# DNS
dhcp-option=6,10.0.0.1, 1.1.1.1
server=1.1.1.1
# Broadcast Address
dhcp-option=28,10.0.0.255
# NTP Server
dhcp-option=42,0.0.0.0
pxe-prompt="Press F8 for menu.", 60
pxe-service=x86PC, "Install CentOS 8 from PXE server", pxelinux
enable-tftp
tftp-root=/var/lib/tftpboot
Config lines that we need to change are:
interface – network interfaces of the server to listen and provide service
bind-interfaces – uncomment to bind interface to the given network card
domain – replace with your domain
dhcp-range – change with your network range
dhcp-boot – replace with your network interface IP
dhcp-option=3,192.168.1.1 – replace with your network Gateway
dhcp-option=6,92.168.1.1 – replace with your DNS Server
server=8.8.4.4 – add your DNS forwarders IPs
dhcp-option=28,10.0.0.255 – replace with your network broadcast IP
dhcp-option=42,0.0.0.0 - add your network time servers (0.0.0.0 is for self-reference)
pxe-prompt – keep it as default
pxe=service – use x86PC for 32-bit/64-bit architectures and add a menu description prompt order
enable-tftp – enables built-in TFTP server
tftp-root – add network booting files location /var/lib/tftpboot
Step 2: Setup SYSLINUX
# dnf install syslinux
Bootloaders are installed under /usr/share/syslinux
Step 3: Install TFTP-Server and Copy SYSLINUX Bootloaders
# dnf install tftp-server # cp -r /usr/share/syslinux/* /var/lib/tftpboot
Step 4: Setup PXE Server
PXE Server reads configurations from specific files found in pxelinux.cfg. Create pxelinux.cfg
directory and create default with the following commands.
# mkdir /var/lib/tftpboot/pxelinux.cfg # touch /var/lib/tftpboot/pxelinux.cfg/default
Now let’s edit PXE default configuration file with our installation options. The following config is an example file that can be used.
default menu.c32 prompt 0 timeout 300 ONTIMEOUT local menu title ########## PXE Boot Menu ########## label 1 menu label ^1) Install CentOS 8 x64 (Local Repo) kernel centos8/vmlinuz append initrd=centos8/initrd.img method=ftp://10.0.0.2/pub devfs=nomount label 2 menu label ^2) Install CentOS 8 x64 (Remote Repo) kernel centos8/vmlinuz append initrd=centos8/initrd.img method=http://mirror.centos.org/centos/8/BaseOS/x86_64/os/ devfs=nomount ip=dhcp label 3 menu label ^3) Install CentOS 8 x64 (Local Repo using VNC) kernel centos8/vmlinuz append initrd=centos8/initrd.img method=ftp://10.0.0.2/pub devfs=nomount inst.vnc inst.vncpassword=password label 4 menu label ^4) Boot from local drive
Step 5: Add CentOS 8 Image to PXE Server
We need to download CentOS 8 DVD ISO image locally using wget and then mount it. Then we need to create a centos8 directory and copy bootable kernel and initrd images.
# wget http://mirrors.primetelecom.ro/centos/8.2.2004/isos/x86_64/CentOS-8.2.2004-x86_64-dvd1.iso # mount -o loop CentOS-8.2.2004-x86_64-dvd1.iso /mnt # mkdir /var/lib/tftpboot/centos8 # cp /mnt/images/pxeboot/vmlinuz /var/lib/tftpboot/centos8 # cp /mnt/images/pxeboot/initrd.img /var/lib/tftpboot/centos8
Step 6: Create CentOS 8 Local Mirror
Now we will install Vsftpd server and copy CentOS 8 DVD content to FTP directory /var/ftp/pub
# dnf install vsftpd # cp -r /mnt/* /var/ftp/pub/ # chmod -R 755 /var/ftp/pub
Now we can start, enable, and verify the status of DNSMASQ and VSFTPD servers
# systemctl start dnsmasq # systemctl status dnsmasq # systemctl start vsftpd # systemctl status vsftpd # systemctl enable dnsmasq # systemctl enable vsftpd
That’s all for setting up a basic PXE Server on CentOS/RHEL 8.
Looking to automate server provisioning at scale?
→ Check out our Infrastructure Automation Services
0 Comments