Nethence Newdoc Olddoc Lab Your IP BBDock  

Setting up PXE / BOOTP / TFTP

Requirements

Ubuntu,

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:/var/lib/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

Ubuntu,

ls -lhd /var/lib/tftpboot/
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="/var/lib/tftpboot"
TFTP_ADDRESS=":69"
TFTP_OPTIONS="-l -s"
RUN_DAEMON="yes"

RHEL,

ls -lhd /tftpboot/
ls -lhd /var/lib/tftpboot/

vi /etc/xinetd.d/tftp

disable = no

Note. /tftpboot on RHEL6 and /var/lib/tftpboot on RHEL7, hence on RHEL7,

ln -s var/lib/tftpboot /tftpboot

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

/etc/rc.d/rc.inetd restart

Acceptance testing,

tftp 10.8.8.1

get netbsd-INSTALL.gz

PXE Configuration

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

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

mkdir /var/lib/tftpboot/pxelinux.cfg/
vi /var/lib/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

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

    tail -F /var/log/syslog &
    systemctl restart nginx
    curl -s localhost
    curl -s localhost/centos7x64/

Kernels and Repositories

Ready to go

Ubuntu, start the services,

tail -F /var/log/syslog &
systemctl start tftpd-hpa
systemctl start isc-dhcp-server
    systemctl start nginx

stop the services,

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

check the services,

ps auxw | grep tftp
ps auxw | grep dhcpd

resulting processes,

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

RHEL,

systemctl restart dhcpd

Slackware,

pkill dhcpd
dhcpd -q eth0

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 10.8.8.1/24 up
curl 10.8.8.1

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

References


Home | GitHub | Docker Hub | Donate | Contact