Setting up network boot server using Proxy DHCP server

pxe-pdhcp is an implementation of Proxy DHCP server. Proxy DHCP is used to boot diskless computers by using the network boot standard named Preboot Execution Environment (PXE). PXE with Proxy DHCP makes it easy to prepare thin clients, HPC cluster or real servers behind load balancers because diskless computers can be increased and be exchanged easily.

Proxy DHCP server works with DHCP server running on another host. The DHCP server assigns IP addresses to network boot clients and the Proxy DHCP server tells the location of Network Bootstrap Program (NBP, one like a boot loader) to the clients. Since the clients use TFTP to get NBP, the location of NBP is the IP address of the TFTP server and filename of the NBP.

The advantage of using Proxy DHCP is that you can separate the DHCP server and the network boot server. This means that you can add network boot feature to the existent network without reconfiguring already running DHCP server.

Now I will introduce a concrete procedure for setting up the network boot server here.

Usage of the pxe-dhcp

usage: pxe-pdhcp  [-d] [-i interface]
                  [-l listen address] [-t tftp address] [-b broadcast address]
                  <nbp name>

-i interface option specifies the network interface name to listen on ('eth0' for examle, on Linux). If the network interface has more than one IP address, -i interface option is unusable. Use -l listen address and -b broadcast address options instead.

-t tftp address option specifies the IP address of the TFTP server. If this option is omitted, the IP address of the the host running the pxe-pdhcp server is used.

At the end of the options, specify the filename of the Network Bootstrap Program (NBP) that exists on the TFTP server. It will be like "pxelinux.0" if you are using PXELINUX for NBP.

Note that root privilege is needed to run pxe-pdhcp because it listens on well-known port (67/udp). And pxe-pdhcp and DHCP server won't run on the same host because they listen on the same port. Run DHCP server on another host.

Setting up network boot server

The following procedure assumes that computers connected to one flat L2 network (network without routers). And one computer (gateway router, for example) have to be already configured to run DHCP server.

First, download pxe-pdhcp and compile it. pxe-pdhcp is hosted on CodeRepos svn repository.

$ svn co
$ cd pxe-pdhcp
$ make

Then download a TFTP server implementation and compile it. Although many of Linux distributors provide binary package of TFTP server, soon you will realize that compiling it by your self is the most simple way after all. :-p

$ wget
$ tar jxvf tftp-hpa-0.48.tar.bz2
$ cd tftp-hpa-0.48
$ ./configure --without-tcpwrappers
$ make
$ cp tftpd/tftpd ../
$ cd ..

Download PXELINUX and compile it. PXELINUX is one of the implementations of Network Bootstrap Program (NBP).

$ wget
$ tar jxvf syslinux-3.70.tar.bz2
$ cd syslinx-3.70
$ make pxelinux.0
$ cp pxelinux.0 ../
$ cd ..

Create a directory for serving it with TFTP server and copy the compiled PXELINUX, its configuretaion file and linux kernel into the directory. It will copy currently used linux kernel from /boot direcotry.

$ mkdir tftpboot
$ cp /boot/vmlinuz-`uname -r` tftpboot/vmlinuz
$ cp /boot/initrd-`uname -r`.img tftpboot/initrd.img
$ cp pxelinux.0 tftpbot/
$ mkdir tftpboot/pxelinux.cfg
$ vi tftpboot/pxelinux.cfg/default

The configuration file of PXELINUX is as follows.

$ cat tftpboot/pxelinux.cfg/default
default mypxe
prompt 0

label mypxe
kernel vmlinuz
append initrd=initrd.img

Finally, run TFTP server and Proxy DHCP server.

$ sudo ./tftpd -l -s ./tftpboot
$ sudo ./pxe-pdhcp -i eth0 pxelinux.0

Now it is ready to network booting. Confirm that boot priority setting in the BIOS configuration is set to boot with PXE and boot the computer. With the PXE, Network Bootstrap Program (pxelinux.0 file) will be loaded first and then the linux kernel (vmlinuz file) will be loaded. But it will hung up with saying "kernel panic." It is because the root filesystem is not available.

The hunged kernel is not usable but the fact is important that the kernel surely booted. I will introduce how to provide root filesystem later.