To run a proxy DHCP just for PXE booting, create a dnsmasq.conf file containing:
interface=eno1
dhcp-range=192.168.1.1,proxy
and then run it with (note the 192.168.1.100 IP, that's where a TFTP server must run on port 69):
sudo dnsmasq --keep-in-foreground --no-daemon --log-queries --log-dhcp --log-debug \
--port=0 --conf-file=dnsmasq.conf \
--dhcp-match=set:bios,option:client-arch,0 --dhcp-boot=tag:bios,undionly.kpxe \
--dhcp-match=set:efi32,option:client-arch,6 --dhcp-boot=tag:efi32,ipxe.efi \
--dhcp-match=set:efibc,option:client-arch,7 --dhcp-boot=tag:efibc,ipxe.efi \
--dhcp-match=set:efi64,option:client-arch,9 --dhcp-boot=tag:efi64,ipxe.efi
Note how (inspired by here, but maybe with server name and address) we use
pairs of --dhcp-match=set:XXX,... --dhcp-boot=tag:XXX,... instead of using --dhcp-option=66,"1.2.3.4" for all (like
the single next-server, which is the DHCP Server-Name option 66, seen in ISC DHCP server configuration files).
Run dnsmasq, at home probably using Proxy DHCP,
and to break the loop configure dhcp-match and dhcp-boot like this
using ipxe.efi (e.g. for ThinkPad, with UEFI PXE;
or undionly.kpxe for BIOS PXE, with
cp undionly.kpxe undionly.kpxe.0 like here).
That last dhcp-boot can be a number of things, e.g. either one of:
- URL to a HTTP hosted text file of an iPXE script. These have to start with ("magic")
#!ipxeand then contain e.g.kernel,initrd,boot. - Arch Linux Netboot: Download, Wiki
- Sidero
On a (my) ThinkPad T460s getting the PXE firmware at boot is a confusing PITA; it required setting UEFI only (not Legacy, or Mixed) and moving PCI LAN up before disk in the boot order, and disabling secure boot; takes some fiddling. Also seems needs an Ethernet with an active link?
It doesn't work over WiFi. (Although iPXE appears to have some WiFi support, untested; but perhaps putting iPXE on disk and booting that from a regular disk bootloader to let it do PXE boot over WiFi could work?)
Note that e.g. on a Fedora with KVM + libvirt, there is a /var/lib/libvirt/dnsmasq/default.conf
which is the DHCP server for interface=virbr0 which gives VMs IPs from 192.168.122.2 onwards;
this is started by libvirtd for each virtual network.
Note that this different from and unrelated to the /usr/lib/systemd/system/dnsmasq.service
which systemctl status dnsmasq.service shows to be disabled (at least on a Fedora Workstation 36).
There is also the default /etc/dnsmasq.conf which does not actually seem to be used,
according to sudo lsof /etc/dnsmasq.conf.
So we can run a dnsmasq on the eno1 interface that's separate from all of the above.
-
Play with VMs instead of metal: Add required config to the
dnsmasqthat QEMU is already running for DHCP, and start QEMU with some options to launch a PXE client "firmware", instead of disk or Kernel directly;qemu-system-x86_64 -boot order=nmaybe with-device e1000,netdev=n1 -netdev user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0, or-kernel ipxe.lkrnas used here -
Build one of those fat uber Kernels with an embedded initrd that can run entirely from RAM without loading a root FS.
-
Copy this container with
dnsmasqand improve it by addingdarkhttpd?
- https://matchbox.psdn.io
- https://www.talos.dev/v1.2/talos-guides/install/bare-metal-platforms/matchbox/
- https://github.com/poseidon/dnsmasq
- https://wiki.archlinux.org/title/Dnsmasq
- https://wiki.archlinux.org/title/Preboot_Execution_Environment
- https://ipxe.org; NB https://ipxe.org/howto/chainloading
- https://wiki.archlinux.org/title/Syslinux#PXELINUX - I don't really understand what the point of this is
- https://github.com/danderson/netboot/tree/master/pixiecore looks neat, haven't tried it; is not longer actively developed
- https://github.com/DongJeremy/pxesrv
- https://github.com/pojntfx/ipxebuilderd