Set up a debian pxe server with ipxe using FOG 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 atool. atool is just a script to extract compressed files easily.

apt-get install dnsmasq atool

Download and extract latest release of FOG. At this moment is 1.5.8

wget https://github.com/FOGProject/fogproject/archive/1.5.8.tar.gz
aunpack 1.5.8.tar.gz

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

mkdir -p /home/tftp/ipxe

Copy needed files.

cp fogproject-1.5.8/packages/tftp/snponly.efi /home/tftp/ipxe/
cp fogproject-1.5.8/packages/tftp/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
pxe-service=x86PC, "ipxe bios", ipxe/undionly.kpxe
pxe-service=x86-64_efi, "ipxe efi", ipxe/snponly.efi

'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