I have written before about dnsmasq and pxe-booting. I was setting up an old thin client as a print server, which could not boot from usb sticks. Therefore, I needed to run a pxe-server to install debian on its internal memory.
So here is a short description. This is more a "note-to-self", and especially, this kind of stuff keeps changing the way it works from now and then. But at least, sharing it with the world might make it easier for you to find a solution.
This setup is not for permanently running servers. It is for connecting a single other computer to a laptop via ethernet, booting it, and installing.
I want my computer to route from the interface eth0
to
wlan0
. wlan0
is managed by network-manager. For eth0
, my
interfaces(5)
contains
iface eth0 inet static
address 192.168.222.1
netmask 255.255.255.0
Make sure to restart your entire network setup, including
network-manager, otherwise, network-manager might try to keep setting
up eth0
. (I am not sure whether one can do this with network-manager
too.)
Furthermore, the sysctl(8)
-setting net.ipv4.ip_forward
must be set
to 1
. I put that setting into my sysctl.conf(5)
and reloaded, but
it can be set directly, so it is not persistent. To make eth0
a NAT
to wlan0
, I run
sudo iptables -t nat -A POSTROUTING -o wlan0 -j MASQUERADE
My working directory is /home/christoph/software/pxesetup
. In this,
I have a file dnsmasq.conf
with the contents
interface=eth0
bind-interfaces
dhcp-range=eth0,192.168.222.1,192.168.222.128,12h
dhcp-authoritative
enable-tftp
tftp-root=/home/christoph/software/pxesetup/tftp/
dhcp-boot=pxelinux.0
listen-address=192.168.222.1
Be careful to change the interface name accordingly: You will be
running an authoritative dhcp server, do not do this in networks you
do not own. Now we need the pxelinux files from Debian, which can (at
the time of writing this) be found
here
and
here. Create
/home/christoph/software/pxesetup/tftp
, and put pxelinux.0
in that
directory, and uncompress the tarball into it (it creates a
subdirectory debian-installer
). Do a chmod -R a+rwx
on that
directory - server-installations should set the permissions more
carefully, but for one-time-installations with my own laptop, it is
sufficient.
Finally, run
sudo dnsmasq -dC /home/christoph/software/pxesetup/dnsmasq.conf
connect your client and let it boot via PXE. I hope this helps. At least it will help me to remember my setup. Comments and corrections are welcome, just send me an e-mail.