Here's a patch for Etherboot 5.3.9 that contains a
solution to a problem I had. The problem was that of
using DHCP on a network that has more than one DHCP
server answering broadcast queries. I wanted to ensure
that each client always boots up with my preferred DHCP
server (instead of someone else's server, or perhaps a
rogue server that got onto the network somehow).
4 files are changed:
src/core/nic.c
I added a block of code that checks the DHCP reply sent
by the server, and makes sure it matches a predefined
IP address. If it doesn't match, the packet is dropped
on the floor, and the client continues to wait for more
DHCP packets to be received. It works now for up to 4
IP addresses. Extending this to MAC addresses should
be easy and straightforward, if somebody needs that in
the future.
src/Config = The IP addresses are defined here at
compile time, and I also changed a default so that PXE
would be started immediately without waiting.
src/genrules.pl = This is a patch I mailed in a few
days ago, to discard some rarely-used drivers in order
to work around the 64KB code size limit when making a
"super" PCI driver disk. I needed this, as a
prerequisite for this patch.
src/makefloppy.sh = This script just compiles Etherboot
and places the resulting boot image into a floppy disk,
with many sanity checks (as many disks are of poor
quality these days).About the IP addresses that are
matched: The IP addresses are stored in a structure
that is placed in the uncompressed area in the boot
image, along with some "magic markers" nearby. This
allows the IP addresses to be changed simply by
searching the boot image binary for these markers, then
hex-editing the nearby IP addresses (which are at a
fixed offset from there)! I added this feature to make
it possible to change the IP addresses without having
to recompile.
I tested this and it worked for me, putting floppy
disks in a client to "lock on" to certain DHCP servers!
I hope that others find this useful as well.
DHCP lock, Floppy Sanity Check and limit drivers included on etherboot-pci