Set up a debian pxe server with ipxe using standard debian files - cesetxeberria/pxeserver GitHub Wiki

Download debian netinst iso, burn it to a cd or a usb and install. Just the minimal install will suffice.

As root user install dnsmasq and ipxe

apt-get install dnsmasq ipxe

Create a new folder for the tftp-root and ipxe.

mkdir -p /home/tftp/ipxe

Copy needed files.

cp /usr/lib/ipxe/ipxe.efi /home/tftp/ipxe/
cp /usr/lib/ipxe/undionly.kpxe /home/tftp/ipxe/

Create a simple "Hello world" file for the menu.

nano /home/tftp/default.ipxe

#!ipxe
:MENU
menu
item --gap -- ---------------- iPXE boot menu ----------------
item hello        Hello world
item shell          ipxe shell
choose --default return --timeout 5000 target && goto ${target}
 
:hello
echo "hello world"
boot ||
goto MENU

:shell
shell ||
goto MENU
 
autoboot

Create new file /etc/dnsmasq.d/custom

nano /etc/dnsmasq.d/custom

interface=eth0
bind-dynamic
dhcp-range=192.168.1.54,proxy
enable-tftp
tftp-root=/home/tftp
dhcp-match=ipxe,175
dhcp-boot=net:ipxe,default.ipxe
pxe-service=#ipxe,x86PC, "ipxe bios", ipxe/undionly.kpxe
pxe-service=#ipxe,x86-64_efi, "ipxe efi", ipxe/ipxe.efi

Little explanation: dnsmasq asks if the client is using ipxe (code 175). If it's true, it offers the default.ipxe script to boot. If it's false ("#" simbol means "not") it tells the client to boot with the corresponding ipxe file. After that the client boots via ipxe, so code 175 becomes true and it gets the script.

'eht0' in the first line and '192.168.1.54' in the third one are just examples. Must be filled with your own interface name and network address. You can get your interface name with

ip -o link | grep "state UP" | awk '{print substr($2, 1, length($2)-1)}'

And your network address with

ip route show | grep src | awk '{print substr($1, 1, length($1)-3)}'

Restart dnsmasq

systemctl restart dnsmasq

Now you can try to pxe boot your client. You shoud see this screen