Setup Iventoy With Isc Dhcp Server for Pxe Boot

Table of Contents

Overview

  1. Setup the IVentoy server
  2. Setup DHCP server to handle DHCP and PXE boot options

This guide assumes that these are two different servers with static IP addresses. By the end, you'll be able to PXE boot any files placed in the ISO folder of Ventoy.

Setting up IVentoy PXE server

Download and extract the latest iventoy from the IVentoy Github Releases. I placed the files in /opt/ventoy/

Start the Ventoy server and load the web interface. Enter the settings and set the DHCP mode to "External". Also make sure that the right network/ip range is selected and then click the run button

/opt/ventoy/iventoy.sh -R start

After completing those steps, stop the ventoy server

/opt/ventoy/iventoy.sh stop

This is all we need to get things working on the Ventoy side of things. To automatically start the IVentoy service, create this systemd unit file in /etc/systemd/system/iventoy.service

  [Unit]
  Description=iVentoy PXE Booter
  Documentation=https://www.iventoy.com
  Wants=network-online.target

  [Service]
  Type=forking
  Environment=IVENTOY_API_ALL=1
  Environment=IVENTOY_AUTO_RUN=1
  Environment=LIBRARY_PATH=/opt/iventoy/lib/lin64
  Environment=LD_LIBRARY_PATH=/opt/iventoy/lib/lin64
  ExecStart=/opt/iventoy/lib/iventoy
  WorkingDirectory=/opt/iventoy
  Restart=on-failure

  [Install]
  WantedBy=multi-user.target

Now enable and start the service.

  systemctl daemon-reload
  systemctl enable --now iventoy.service
  # Making sure its running
  /opt/ventoy/iventoy.sh status

Setting up the DHCP Server

Important note: Make sure DHCP is disabled on your router after setting this up. If you have any errors saying "No subnet declaration for INTERFACE" when running journalctl -u isc-dhcp-server, the problem is that you either dont have your interface specified in /etc/default/isc-dhcp-server or there is a syntax error in the dhcpd.conf. In my experience the error logging has been amibigious and not user friendly.

Okay, with that out of the way, lets install it!

  apt install isc-dhcp-server

Add the line INTERFACE=YOUR_INTERFACE to /etc/default/isc-dhcp-server. Uncomment the lines at the bottom named INTERFACES.

  # Defaults for isc-dhcp-server (sourced by /etc/init.d/isc-dhcp-server)

  # Path to dhcpd's config file (default: /etc/dhcp/dhcpd.conf).
  #DHCPDv4_CONF=/etc/dhcp/dhcpd.conf
  #DHCPDv6_CONF=/etc/dhcp/dhcpd6.conf

  # Path to dhcpd's PID file (default: /var/run/dhcpd.pid).
  #DHCPDv4_PID=/var/run/dhcpd.pid
  #DHCPDv6_PID=/var/run/dhcpd6.pid

  # Additional options to start dhcpd with.
  #       Don't use options -cf or -pf here; use DHCPD_CONF/ DHCPD_PID instead
  #OPTIONS=""

  # On what interfaces should the DHCP server (dhcpd) serve DHCP requests?
  #       Separate multiple interfaces with spaces, e.g. "eth0 eth1".
  INTERFACES="eth0"
  #INTERFACESv4="eth0"
  #INTERFACESv6=""

Now edit /etc/dhcp/dhcpd.conf. This template creates a DHCP server to handout addresses for the 192.168.50.0/24 network. Change the network IP to reflect your own. Edit the address for next-server and tftp-server-name to point to your IVentoy server instead.

    ddns-update-style none;
    authoritative;
    deny declines;

    subnet 192.168.50.0 netmask 255.255.255.0 {
     authoritative;
     range 192.168.50.100 192.168.50.200;
     default-lease-time 3600;
     max-lease-time 3600;
     option subnet-mask 255.255.255.0;
     option broadcast-address 192.168.50.255;
     option routers 192.168.50.1;
     option domain-name-servers 8.8.8.8;
     # For iPXE:
     next-server 192.168.50.53;
     # For HyperV guests:
     option dhcp-client-identifier "PXEClient"; #option 60
     option tftp-server-name "192.168.50.53"; #option 66
     option bootfile-name "iventoy_loader_16000"; #option 67
     #option vendor-class-identifier "PXEClient";

  }

Turn off DHCP on your router and start the services on the server.

  systemctl enable --now isc-dhcp-server

The end

You're clients will now be able to PXE boot! I tested this on Hyper-V and KVM guest machines. This will work with UEFI and BIOS clients at the same time.