Setting up PXE & BOOTP

Requirements

Slackware,

ls -l /var/log/packages/{dhcp-,syslinux-,tftp-hpa-}*

Debian/Ubuntu,

apt install isc-dhcp-server tftpd-hpa tftp inetutils-inetd pxelinux nginx
#tftp client conflicts with tftp-hpa

RHEL,

yum install dhcp syslinux tftp-server

DHCP

ifconfig | grep inet

slackware

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

ubuntu

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

proceed

allow bootp;
ddns-update-style none;
allow unknown-clients;
max-lease-time 7200;

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 "syslinux.efi";
        #filename "pxeboot_ia32.bin";
        #filename "pxeboot.bin";

        next-server TFTP-NFS-SERVER;
        #option root-path "10.8.8.1:/tftpboot";
        option root-path "/tftpboot";
}

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

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

Slackware /etc/dhcpd.conf.example

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

In case you want your network to get access to the internet,

option routers x.x.x.254;
option domain-name-servers 208.67.222.222, 208.67.222.220;
#option domain-search "example.local";
#option domain-name example.local;

Enable at boot time on slackware

vi /etc/rc.local

echo -n DHCP daemon...
dhcpd -q eth0 && echo done
pgrep -a dhcpd

TFTP

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

Default locations:

Slackware,

mv -i /etc/inetd.conf /etc/inetd.conf.dist
grep '^# tftp' /etc/inetd.conf.dist | sed 's/^# //' > /etc/inetd.conf

for the record, the content will be,

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

chmod +x /etc/rc.d/rc.inetd
/etc/rc.d/rc.inetd restart

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

PXE bootloader

locate menu.c32 pxelinux.0
#ldlinux.c32

slackware

ll /tftpboot/
ll /usr/share/syslinux/
cp -f /usr/share/syslinux/pxelinux.0 /tftpboot/
cp -f /usr/share/syslinux/menu.c32 /tftpboot/

ubuntu

ll /var/lib/tftpboot/
ll /usr/lib/syslinux/modules/bios/

cd /tftpboot/
rm -f ldlinux.* libutil.c32 menu.c32 pxelinux.0 syslinux*.efi

cp -f /usr/lib/syslinux/modules/bios/pxelinux.0 /tftpboot/
cp -f /usr/lib/syslinux/modules/bios/menu.c32 /tftpboot/

#ldlinux.c32
#libutil.c32

PXE/EFI64 bootloader

locate syslinux.efi
#ldlinux.e64

ubuntu

ll /usr/lib/syslinux/modules/efi64/

for f in efi64/ldlinux.e64 efi64/libutil.c32 efi64/menu.c32 efi64/syslinux.efi; do
    echo -n $f...
    cp -f $tmp/$f /tftpboot/ && echo done
done; unset f
chmod -x /tftpboot/syslinux*.efi

unset tmp
#meminfo.c32

Setup

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

default menu.c32
prompt 0
menu title PXE
#menu title PXE/EFI64

label slackware142 install
        kernel slackware142/kernels/huge.s/bzImage
        append initrd=slackware142/isolinux/initrd.img vga=791

label netbsd install
        kernel pxeboot_ia32.bin

label exit
        localboot 0

HTTP & NFS

Slackware, using HTTP,

sbopkg -i thttpd
cp /etc/thttpd.conf /etc/thttpd.conf.dist           
vi /etc/thttpd.conf

#host=localhost

dir=/tftpboot

thttpd -C /etc/thttpd.conf
ps auxw | grep thttpd

#ldd /usr/lib64/libgd.so
#sbopkg -i nginx

Slackware, using NFS,

mv /etc/exports /etc/exports.dist
vi /etc/exports

/tftpboot       x.x.x.x/24(ro,root_squash,async,subtree_check)

exportfs -ra

Ubuntu, using HTTP,

apt install nginx
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

Proceed with further ado over there (look for pxe.* guides)

Remote Acceptance

dhcpd

dhclient -v NIC

tftpd

cd ~/
tftp PXE-SERVER-ADDRESS

get pxelinux.0
^D

ls -l pxelinux.0

http

curl -s PXE-SERVER-ADDRESS

iPXE

You can validate with VirtualBox and here’s a draft to try it out with QEMU instead

ip tuntap add tap0 mode tap
brctl addif xenbr0 tap0
qemu-system-x86_64 -net nic,model=virtio,macaddr=00:00:00:00:00:01 -net tap,ifname=tap0

brctl delif xenbr0 tap0
ip tuntap del tap0 mode tap

Beware NetBSD tftp client and iPXE don’t understand each other

Operations

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

Slackware,

pkill thttpd
/etc/rc.d/rc.inetd stop
pkill dhcpd

dhcpd -q NETIF1 NETIF2
/etc/rc.d/rc.inetd start
/usr/local/sbin/thttpd -C /etc/thttpd.conf

pgrep -a dhcpd
pgrep -a inetd
pgrep -a thttpd

Debian/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

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

RHEL,

systemctl restart dhcpd

resulting processes on Ubuntu,

dhcpd -user dhcpd -group dhcpd -f -4 -pf /run/dhcp-server/dhcpd.pid -cf /etc/dhcp/dhcpd.conf
/usr/sbin/in.tftpd --listen --user tftp --address :69 -l -s /tftpboot

resulting processes on Devuan,

/usr/sbin/dhcpd -4 -q -cf /etc/dhcp/dhcpd.conf
/usr/sbin/in.tftpd --listen --user tftp --address 0.0.0.0:69 -4 --secure /tftpboot

Misc

improved layout

ui menu.c32
prompt 0
menu title PXE
timeout 100
default ...

#path lib/

sub-menus

label bsd
        kernel menu.c32
        append pxelinux.cfg/bsd

label linuces
        kernel menu.c32
        append pxelinux.cfg/linuces

label ghost & rescue
        kernel menu.c32
        append pxelinux.cfg/ghostrescue

label obsolete
        kernel menu.c32
        append pxelinux.cfg/obsolete

label dos
        kernel menu.c32
        append pxelinux.cfg/dos

And the sub-menus may also have a title

vi /tftpboot/pxelinux.cfg/linuces

menu title GNU/Linux

vi /tftpboot/pxelinux.cfg/bsd

menu title BSD

Resources

PXELINUX https://wiki.syslinux.org/wiki/index.php?title=PXELINUX

How to install PXE Server on Ubuntu 16.04 https://www.ostechnix.com/how-to-install-pxe-server-on-ubuntu-16-04/

DisklessUbuntuHowto https://help.ubuntu.com/community/DisklessUbuntuHowto

PXE-netboot-install https://wiki.ubuntu.com/UEFI/PXE-netboot-install

PXEInstallServer https://help.ubuntu.com/community/PXEInstallServer

Howto do QEMU full virtualization with bridged networking https://ahelpme.com/linux/howto-do-qemu-full-virtualization-with-bridged-networking/


Nethence | Pub | Lab | Pbraun | SNE Russia | xhtml