Table of Contents

Network Booting with dnsmasq

I have lots of computers, and, as I grow older, ever decreasing amounts of patience. So, when I want to reinstall the operating system on something, I don't want to mess around with floppy disks, CD-ROMs or USB flash drives.

On most recent unix-ish systems you can install dnsmasq to provide a combined DNS, DHCP, PXE and TFTP server with very little configuration.

dnsmasq.conf

Here's the bare bones of a working DHCP, PXE + TFTP configuration:

# The range in which we offer IP addresses
dhcp-range=192.168.1.1,192.168.1.190,255.255.255.0,12h

# Set up three static hosts who will always get the same IP
dhcp-host=00:00:00:00:00:0a,rod,192.168.1.1
dhcp-host=00:00:00:00:00:0b,jane,192.168.1.2
dhcp-host=00:00:00:00:00:0c,freddy,192.168.1.3

# Set the gateway address assigned to DHCP clients
dhcp-option=option:router,192.168.1.254

pxe-prompt="== PXE Netboot Server =="
pxe-service=x86PC, "Boot from local disk"
pxe-service=x86PC, "Install a new operating system", pxelinux

enable-tftp
tftp-root=/export/tftp

That's about as simple as it gets and will serve IP addresses in the range 192.168.1.1-190 to any DHCP client on your network.

In addition, if a PC-based system boots up and has PXE enabled, it will get a menu prompting it to either Boot from local disk or Install a new operating system.

Selecting the latter option will chain load a TFTP pxelinux menu entry system from /export/tftp - which you'll need files from the syslinux package installing to create.

pxelinux

In order to have a complete PXE menu system you'll want syslinux installing and the following files:

There are additional options, but using just the above 3 will give you a menu system that can cope with netbooting most operating systems.

My /export/tftp directory looks like this:

I then have the following in the default menu file:

default syslinux/menu.c32
prompt 0

MENU TITLE Installer Menu
menu separator

LABEL LinuxMint
MENU LABEL Linux - Mint Menu
KERNEL menu.c32
APPEND pxelinux.cfg/linux-mint

LABEL LinuxUbuntu
MENU LABEL Linux - Ubuntu Menu
KERNEL menu.c32
APPEND pxelinux.cfg/linux-ubuntu

LABEL NetBSD
MENU LABEL Unix - NetBSD Menu
KERNEL menu.c32
APPEND pxelinux.cfg/netbsd

LABEL DOS
MENU LABEL MS-DOS/Windows Menu
KERNEL menu.c32
APPEND pxelinux.cfg/dos

This serves as my root menu, with operating system flavours branching off. For example, the Linux - Ubuntu menu would then serve to actually boot and install Ubuntu, selecting MS-DOS/Windows would launch a DOS boot floppy, etc.


Currently I have the following entries: