Setting up PXE / BOOTP / TFTP

RHEL / Ubuntu / Devuan / Slackware

Requirements

Ubuntu and Devuan,

apt install isc-dhcp-server tftpd-hpa tftp inetutils-inetd pxelinux nginx

RHEL,

yum install dhcp syslinux tftp-server

Slackware,

ls -1 /var/log/packages/ | grep dhcp
ls -1 /var/log/packages/ | grep sysli
ls -1 /var/log/packages/ | grep tftp

DHCP

mv -i /etc/dhcp/dhcpd.conf /etc/dhcp/dhcpd.conf.dist
vi /etc/dhcp/dhcpd.conf

allow bootp;
ddns-update-style none;
allow unknown-clients;

subnet 172.17.0.0 netmask 255.255.0.0 {
}

subnet 10.8.8.0 netmask 255.255.255.0 {
        range 10.8.8.100 10.8.8.199;
        next-server 10.8.8.1;
        filename "pxelinux.0";
        #filename "pxeboot_ia32.bin";
        option root-path "10.8.8.1:/tftpboot";

         if substring (option vendor-class-identifier, 0, 17)
           = "NetBSD:i386:libsa" {
             if filename = "netbsd" {
                 filename "tftp:netbsd7/amd64/binary/kernel/netbsd-INSTALL.gz";
             }
         }
}

#allow booting;
#option option-128 code 128 = string;
#option option-129 code 129 = text;

dhcpd -t -cf /etc/dhcp/dhcpd.conf

Ref. (Ubuntu) /usr/share/doc/isc-dhcp-server/examples/dhcpd.conf.example

TFTP

ls -lhd /tftpboot/
ls -lhd /var/lib/tftpboot/
#ln -s var/lib/tftpboot /tftpboot

Note. /tftpboot on RHEL6 and /var/lib/tftpboot on RHEL7 and Ubuntu

Ubuntu,

ls -lhF /usr/sbin/in.tftpd
cp -pi /etc/default/tftpd-hpa /etc/default/tftpd-hpa.dist
vi /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -s"
RUN_DAEMON="yes"

Devuan with IPv6 disabled at boot time,

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-4 --secure"

RHEL,

vi /etc/xinetd.d/tftp

disable = no

Slackware,

mkdir -p /tftpboot/pxelinux.cfg/
vi /etc/inetd.conf

tftp  dgram   udp     wait    root    /usr/sbin/in.tftpd  in.tftpd -s /tftpboot -r blksize

Acceptance testing,

tftp x.x.x.x

get netbsd-INSTALL.gz

PXE Configuration

handy symlinks,

cd ~/
ls -ldhF /tftpboot/
ln -s ../tftpboot
#ls -ldhF /var/lib/tftpboot
#ln -s ../var/lib/tftpboot

the needed stuff for PXELINUX to work,

cp -i /usr/lib/syslinux/modules/bios/ldlinux.c32 /tftpboot/
cp -i /usr/lib/syslinux/modules/bios/libutil.c32 /tftpboot/
#cp -i /usr/lib/syslinux/modules/bios/meminfo.c32 /tftpboot/
cp -i /usr/lib/syslinux/modules/bios/menu.c32 /tftpboot/
cp -i /usr/lib/PXELINUX/pxelinux.0 /tftpboot/

PXELINUX setup,

mkdir /tftpboot/pxelinux.cfg/
vi /tftpboot/pxelinux.cfg/default

default menu.c32
prompt 0
menu title PXE

HTTP

cp -pi /etc/nginx/sites-available/default /etc/nginx/sites-available/default.dist
vi /etc/nginx/sites-enabled/default

#listen [::]:80 default_server;

#root /var/www/html;
root /tftpboot;
autoindex on;

Kernels and Repositories

Ready to go

stop & start in order

tail -n0 -F /var/log/* /var/log/*/*

Ubuntu,

systemctl stop nginx
systemctl stop tftpd-hpa
systemctl stop isc-dhcp-server

systemctl start isc-dhcp-server
systemctl start tftpd-hpa
systemctl start nginx

Devuan,

service nginx stop
service tftpd-hpa stop
service isc-dhcp-server stop

service isc-dhcp-server start
service tftpd-hpa start
service nginx start

RHEL,

systemctl restart dhcpd

Slackware,

pkill dhcpd
dhcpd -q eth0
/etc/rc.d/rc.inetd restart #tftp

check the services,

ps auxw | grep dhcpd
ps auxw | grep tftp
curl -s localhost/

resulting processes on Ubuntu,

/usr/sbin/in.tftpd --listen --user tftp --address :69 -l -s /tftpboot

dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf

resulting processes on Devuan,

/usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 -4 --secure /tftpboot

/usr/sbin/dhcpd -4 -q -cf /etc/dhcp/dhcpd.conf

Testing your PXE Service

WARNING: iPXE 1.0.0+ on VirtualBox did not let the NetBSD boot loader, once loaded tru PXE, use TFTP again, nor did the Ubuntu installer fully show up, but I did not troubleshoot that one so far. One cannot fully test with VirtualBox, use hardware.

However for quick tests as first attempts,

brctl addbr dummybr0
ifconfig dummybr0 x.x.x.x/24 up
curl x.x.x.x

and eventually bind a virtual machine and its NIC to that bridge.

References