Skip to content

Latest commit

 

History

History
85 lines (59 loc) · 4.72 KB

pxe.md

File metadata and controls

85 lines (59 loc) · 4.72 KB

PXE

TL;DR

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).

Background

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:

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?)

dnsmasq for libvirt

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.

ToDo

  1. Play with VMs instead of metal: Add required config to the dnsmasq that 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=n maybe with -device e1000,netdev=n1 -netdev user,id=n1,tftp=/path/to/tftp/files,bootfile=/pxelinux.0, or -kernel ipxe.lkrn as used here

  2. Build one of those fat uber Kernels with an embedded initrd that can run entirely from RAM without loading a root FS.

  3. Copy this container with dnsmasq and improve it by adding darkhttpd?

References