Skip to content

Latest commit

 

History

History
109 lines (83 loc) · 4.12 KB

README.md

File metadata and controls

109 lines (83 loc) · 4.12 KB

PXE ROM Builder

This is an all-in-one solution for self-hosting and managing PXE ROMs, Linux kernels and kernel preseeds. Use the provided Makefile to build custom PXE ROMs which point to a self-hosted TFTP and HTTP server.

Usage

  1. Build the PXE ROMS,

    1. Build on native host simply by calling make.

    2. Or, build use the provided Dockerfile:

      $ make container
      $ docker run -it --rm \
        -v $(pwd)/out:/pxe-roms/out:rw \
        nderjung.net/pxe-roms:latest \
        make

      You can also specify specific roms, e.g. make ubuntu/xenial64 or create your own by adding them into the config/custom directory.

    3. (Optional) You can embed a preseed url for the rom you are building by providing an environmental variable PRESEED_URL during make:

      $ make PRESEED_URL=... ubuntu/xenial64
  2. Set up a TFTP server to host the PXE ROMs,

    1. Set the hostname, e.g. tftp.

    2. Expose port udp/69.

    3. Install and run the TFTP server:

      1. You can use the built in TFTP server:

        $ DOCKER_TARGET=serve make container
        $ docker run -it --rm -p 69:69/udp nderjung.net/pxe-roms:latest
      2. Or, install one via package manager, e.g:

        # apt install -y tftpd-hpa tftp-hpa xinetd

        Then copy the contents from out/ to the TFTP server:

        $ scp -r out/ 10.1.0.69:/srv/tftp
        
  3. (Optional) Set up a HTTP server to host preseeds and kernels. A pre-built server is included in the docker-compose.yml file as an example. In the rest of this tutorial, I will be referring to https://pub.nderjung.net as the self-hosted HTTP server.

  4. Set up a DHCP server to indicate to the network bootable server a ROM is available,

    1. Set the hostname, e.g. router.

    2. Edit /etc/dnsmasq.conf:

      # Define PXE ROMs as seperate tags (from `out/`)
      dhcp-boot=tag:ubuntu-trusty64-serial, pxelinux.ubuntu-trusty64-serial, <router_ipaddr>, <tftp_ipaddr>
      dhcp-boot=tag:ubuntu-trusty64-preseed, pxelinux.ubuntu-trusty64-preseed, <router_ipaddr>, <tftp_ipaddr>
      dhcp-boot=tag:ubuntu-xenial64-serial, pxelinux.ubuntu-xenial64-serial, <router_ipaddr>, <tftp_ipaddr>
      dhcp-boot=tag:ubuntu-xenial64-preseed, pxelinux.ubuntu-xenial64-preseed, <router_ipaddr>, <tftp_ipaddr>
      dhcp-boot=tag:ubuntu-bionic64-serial, pxelinux.ubuntu-bionic64-serial, <router_ipaddr>, <tftp_ipaddr>
      dhcp-boot=tag:ubuntu-bionic64-preseed, pxelinux.ubuntu-bionic64-preseed, <router_ipaddr>, <tftp_ipaddr>
      
      # (Optional from 3.) Define a new DHCP option for retrieving the preseed URL,
      # and define the specific preseed URLs for the relevant tags.
      # ${preseed-url} will be replaced in relevant PXE config files
      dhcp-option=244,preseed-url
      dhcp-option=tag:ubuntu-trusty64-preseed,244,"https://pub.nderjung.net/preseeds/ubuntu.trusty64.cfg"
      dhcp-option=tag:ubuntu-xenial64-preseed,244,"https://pub.nderjung.net/preseeds/ubuntu.xenial64.cfg"
      dhcp-option=tag:ubuntu-bionic64-preseed,244,"https://pub.nderjung.net/preseeds/ubuntu.bionic64.cfg"
      
      # Set device-specific ROMs (adjust accordingly)
      dhcp-host=<hwaddr>, set:ubuntu-trusty64-serial, <ipaddr>, <hostname>
      dhcp-host=<hwaddr>, set:ubuntu-xenial64-preseed, <ipaddr>, <hostname>
      
    3. (Optional) To acknowledge the new DHCP option for the preseed URL, you must define it.

      1. In a BSD-like environment, you can edit /etc/config/dhcp and add the following:

        
        
      2. In Linux-like environment, you can edit /etc/dhcpd.conf and add the following:

        option preseed-url code 244 = string;
        
    4. Restart the service:

      # /etc/init.d/dnsmasq restart
      
  5. Reboot and viola!