PXE-Linux

Requirements

Alright first thing we need to do is install the requirements.

root@netbooter ~# apt-get update
root@netbooter ~# apt-get install pxelinux syslinux dnsmasq -y

Network

Static IP

Now that we have the package installed, let's configure the networking of our pxe-linux server. Let's backup the current /etc/network/interfaces config file.

root@netbooter ~# cp -v /etc/network/interfaces /etc/network/interfaces.original

And let's edit the config file

root@netbooter ~# nano /etc/network/interfaces

In my example, I will configure the ip 10.10.0.10/24.

# This file describes the network interfaces available on your system
# and how to activate them. For more information, see interfaces(5).

source /etc/network/interfaces.d/*

# The loopback network interface
auto lo
iface lo inet loopback

# The primary network interface
allow-hotplug eth0
auto eth0
iface eth0 inet static
	address 10.10.0.10
	netmask 255.255.255.0
	gateway 10.10.0.2

Now let's restart the network service to apply the changes.

systemctl restart networking

DNSMASQ

We need dnsmasq to provide a few bits of information to the computers to find the tftp server. Let's begin. First as usual, we will backup the original configuration files before creating our own configuration file.

mv -v /etc/dnsmasq.conf /etc/dnsmasq.conf.original

Now we can create our configuration file.

nano /etc/dnsmasq.conf

port=0
log-dhcp
dhcp-range=10.10.0.10,proxy
dhcp-boot=pxelinux.0
pxe-service=x86PC,'Network Boot',pxelinux
enable-tftp
tftp-root=/tftpboot

Once our configuration file is created, we may restart the service.

systemctl restart dnsmasq

TFTP Server

Now that we have configured our network to support tftp, we need to build and configure our tftp environment. We will start by creating our environment.

mkdir -p /tftpboot/pxelinux.cfg/
cp -v /usr/lib/PXELINUX/pxelinux.0 /tftpboot/
cp -v /usr/lib/syslinux/modules/bios/{menu,ldlinux,libmenu,libutil}.c32 /tftpboot/
cp -v /usr/lib/syslinux/memdisk /tftpboot/

Now that the environment is built, we will create the configuration file.

nano /tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
menu title Boot Menu
timeout 600
ontimeout localboot

    label localboot
        menu label Boot from Local Disk
        localboot 0

Now that our PXE-Server is installed and configured, I recommend you restart the server and test with another computer.

This script is used to install and configure PXELinux and configure the images explained in this documentation. It may be used to automate the installation.

OS Tested :

  • Debian Linux 8 Jessie

root@netbooter ~# ./pxelinux.sh

    ██████╗ ██╗  ██╗███████╗    ██╗     ██╗███╗   ██╗██╗   ██╗██╗  ██╗
    ██╔══██╗╚██╗██╔╝██╔════╝    ██║     ██║████╗  ██║██║   ██║╚██╗██╔╝
    ██████╔╝ ╚███╔╝ █████╗█████╗██║     ██║██╔██╗ ██║██║   ██║ ╚███╔╝
    ██╔═══╝  ██╔██╗ ██╔══╝╚════╝██║     ██║██║╚██╗██║██║   ██║ ██╔██╗
    ██║     ██╔╝ ██╗███████╗    ███████╗██║██║ ╚████║╚██████╔╝██╔╝ ██╗
    ╚═╝     ╚═╝  ╚═╝╚══════╝    ╚══════╝╚═╝╚═╝  ╚═══╝ ╚═════╝ ╚═╝  ╚═╝

Usage: ./pxelinux.sh [options] [functions] [arguments]

Options:

--debug                              => Enable Debug Mode
                                        Input commands sent are stored in pxelinux.log
--screen                             => Enable Screen Mode
                                        Output commands sent are stored in pxelinux.screen.log
    Arguments:  -a                      Append log to the last one instead of overwriting it
--smb                                => Enable SMB Mode

Functions:

--help                               => Displays the list of available commands
--update                             => Update the system
--restart                            => Restart the system
--config-sources                     => Configure APT Sources
--config-network                     => Configure a static IP
    Arguments:  -i                      IP Address, Netmask and Gateway must be provided as arguments
--get-ip                             => Find system IP
--install-essentials                 => Install Essentials cifs-utils, fping, mtr, screen, htop
--install-pxelinux                   => Install a PXE Server
    Arguments:  -g                      Configure a more fancy boot menu
--pxelinux-clonezilla                => Add CloneZilla to PXE Server
    Arguments:  -as                     Use alternate source link must be provided as second argument
--pxelinux-win7pe                    => Add Windows 7 PE to PXE Server
--pxelinux-win10pe                   => Add Windows 10 PE to PXE Server

Example:
root@netbooter ~# ./pxelinux.sh --debug --screen -a --config-sources --update --install-essentials --install-pxelinux -g --pxelinux-clonezilla

root@netbooter ~# wc -l pxelinux.sh
     631 pxelinux.sh