iPXE Network Booting ESXi and Ubuntu

A simple copy-and-paste guide to configure iPXE lan booting to bootstrap the setup of VMware ESXi 6.5 or Ubuntu 18.04

What do you need

  1. A router with a DHCP server and a TFTP server. Both pfSense and OPNSense works;
  2. The ESXi and Ubuntu ISO
  3. An http server

Tl;DR

The server will boot in PXE mode --> 
    it will load the iPXE BIOS firmware via TFTP -->
    iPXE will load a menu from an http server -->
    the chosen image will be downloaded by http;

Configure the server to boot from LAN/PXE;

Configure the server to boot from LAN/PXE;

Configure the DHCP

Configure the DHCP with the address of the TFTP server and set undionly.kpxe as bootfile

Build a custom undionly.kpxe

We need a custom build because:

In a linux machine:

######################
# clone the sources  #
######################
apt update && apt install -y gcc binutils make perl liblzma-dev mtools mkisofs syslinux
git clone git://git.ipxe.org/ipxe.git
cd ipxe/src

#########################
# add the build options #
#########################
cat "#define IMAGE_COMBOOT /* SYSLINUX COMBOOT image support */" > config/local/general.h 

# TODO Add the menu #

#########
# build #
#########
make bin-x86_64-efi/snponly.efi

Copy snponly.efi in the root of TFTP server

Write the custom menu

cat >> boot.ipxe<< EOF
#!ipxe

set boot-url {your http server here}

echo Boot menu
menu Selection
item ubuntu18 Ubuntu 18.05
item esxi65u3 ESXi 6.5u3

choose os && goto ${os}

:ubuntu18
kernel ${boot-url}/ubuntu_18.04/linux  
initrd ${boot-url}/ubuntu_18.04/initrd.gz 
imgargs linux showmounts initrd=initrd root=/dev/ram0 ramdisk_size=1500000 ip=dhcp 
boot
goto start

:esxi65u3
kernel ${boot-url}/esxi_6.5u3/mboot.c32 -c ${boot-url}/esxi_6.5u3/boot.cfg
boot


EOF

Then copy boot.ipxe at the root of yout HTTP server

Other references:

Prepare the ISO images

Create a folder for each iso at the root of your http server (you can choose any folder layout you want, this is mine)

ESXi

Create the esxi_6.5u3 folder that will contain all the files, then:

  • copy the content of the ESXi ISO in esxi_6.5u3
  • `cd esxi_6.5u3
  • customize boot.cfg - reference
  • convert all the files to lowercase find ./ -type f -execdir rename 'y/A-Z/a-z/' {} \;
  • remove the / from boot.cfg: sed -i 's/\///g' boot.cfg
  • append the http server: cat prefix=http://XXX.XXX.XXX.XXX/esxi_6.5u3 >> boot.cfg

DONE!

Now you should be able to boot from iPXE both ESXi and ubuntu.