Set Up PXE Server

This guide will walk you through configuring your PXE server to bootstrap your physical hosts. To do so, you can choose between the following options:

  • Configure your existing DHCP server to act as PXE server.
  • Configure your bootstrap host to act as PXE/proxyDHCP server.

The second approach allows you to set a PXE environment without touching the configuration of your working DHCP server. This may be useful in case the existing DHCP server cannot be easily configured, for example when the DHCP service is provided by a hardware router.

Important

You will use dnsmasq on your bootstrap host to act as PXE server. If your DHCP server lives outside of your bootstrap host, you will use dnsmasq on your bootstrap host as a proxyDHCP server.

What You’ll Need

Procedure

  1. Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:

    root@host:~# apt-get update root@host:~# apt-get install -y dnsmasq
  2. Go to your bootstrap host and configure dnsmasq to act as PXE server.

    1. Disable DNS. Copy the following configuration snippet and paste it in /etc/dnsmasq.d/dns.conf.

      # Disable DNS Server port=0 # Listen on all interfaces bind-interfaces
    2. Enable PXE. Copy the following configuration snippet and paste it in /etc/dnsmasq.d/pxe.conf.

      dhcp-boot=pxelinux.0 pxe-service=x86PC,"Network Boot",pxelinux

      Note

      This assumes that the TFTP server runs on the same host.

    3. Configure proxyDHCP.

      Fast Forward

      Skip this step if you have already configured DHCP on the bootstrap host. This is only required if your DHCP server is on a different host than your PXE environment.

      Copy the following configuration snippet and paste it in /etc/dnsmasq.d/dhcp.conf.

      # Enable DHCP logging log-dhcp # Respond to PXE requests for the specified network; # run as DHCP proxy dhcp-range=<SUBNET>,proxy

      Replace <SUBNET> with your network subnet, for example:

      # Enable DHCP logging log-dhcp # Respond to PXE requests for the specified network; # run as DHCP proxy dhcp-range=192.168.2.0,proxy
    4. Restart the service:

      root@host:~# service dnsmasq restart

Verify

  1. Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:

    root@host:~# apt-get update root@host:~# apt-get install -y nmap

    Note

    For version 7.40 (Debian stretch) patch /usr/share/nmap/nselib/dhcp.lua as pointed in https://github.com/nmap/nmap/issues/1909#issuecomment-583109074.

  2. Test the PXE enabled DHCP service:

    root@host:~# nmap --script=./broadcast-dhcp-discover-pxe Pre-scan script results: | broadcast-dhcp-discover: | Response 1 of 1: | IP Offered: 0.0.0.0 | DHCP Message Type: DHCPOFFER | Server Identifier: 192.168.2.10 |_ Class Identifier: PXEClient

    Note

    This requires a custom script that makes a DHCPDISCOVER with options that identify a PXE-enabled client.

Summary

You have successfully configured your PXE server to bootstrap your physical hosts.

What’s Next

The next step is to set up OS configuration files for your physical hosts.