This article details my practical reference guide for iPXE Bare-Metal Bootstrap & Kickstart over HTTP/DHCP, originally published as a secure GitHub Gist snippet.


🛠️ Section 1: Basic Ubuntu Autoinstall via DHCP

1. Fetching the Source & Building the Custom iPXE Image

First, clone the official iPXE repository:

git clone http://git.ipxe.org/ipxe.git
cd ipxe/src

2. Creating the Embedded Boot Script (ubuntu-amd64-installer.ipxe)

Write the embedded boot configuration:

#!ipxe
dhcp
echo Starting Ubuntu x64 installer for \${hostname}
set base-url http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
kernel \${base-url}/linux
initrd \${base-url}/initrd.gz

# NOTE: make sure you update the LOCAL_NETWORK_IP and preseed file present there
imgargs linux auto=true url=http://LOCAL_NETWORK_IP/preseed.cfg
boot || 

# If everything failed, give the user some options
echo Boot from \${base-url} failed
prompt --key 0x197e --timeout 2000 Press F12 to investigate || exit
shell

3. Compiling the Embedded Images

Compile the target boot payloads (ISO, USB, or VMware ROMs):

# Create standard ISO file
make bin/ipxe.iso EMBED=./ubuntu-amd64-installer.ipxe 

# Create bootable USB image
make bin/ipxe.usb EMBED=./ubuntu-amd64-installer.ipxe 

# Transfer the USB image to your device (Note: XX is your target usbdevice ID)
dd if=bin/ipxe.usb of=/dev/sdXX

⚙️ Section 2: Advanced Autoinstall via Static IP Config

If you do not have a local DHCP server or prefer static addressing:

1. Creating the Static Embedded Script

#!ipxe
# static ip settings
ifopen net0
set net0/ip 192.168.1.240
set net0/netmask 255.255.255.0
set net0/gateway 192.168.1.1
set dns 192.168.1.1
set hostname puppet1
set domain_name domain.local

echo "Configured IP Details:"
show net0/ip
show net0/netmask
show net0/gateway
show dns
show hostname
show domain_name
route

set menutimeout 5
echo Starting Ubuntu x64 installer for \${hostname}
set base-url http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
kernel \${base-url}/linux priority=critical
initrd \${base-url}/initrd.gz

# NOTE: make sure you update the LOCAL_NETWORK_IP and preseed file present there
imgargs linux auto=true url=http://LOCAL_NETWORK_IP/preseed.cfg interface=eth0 hostname=\${hostname} domain=\${domain_name} netcfg/disable_dhcp=true netcfg/get_ipaddress=\${net0/ip} netcfg/get_netmask=\${net0/netmask} netcfg/get_gateway=\${net0/gateway} netcfg/get_nameservers=\${dns}
boot || 

# If everything failed, give the user some options
echo Boot from \${base-url} failed
prompt --key 0x197e --timeout 2000 Press F12 to investigate || exit
shell

2. Compiling the Boot Mediums

# Create ISO file
make bin/ipxe.iso EMBED=./ubuntu-amd64-installer.ipxe 

# Create bootable ISO specialized for VMware ESXi
make bin/8086100f.mrom bin/808610d3.mrom bin/10222000.rom bin/15ad07b0.rom bin/ipxe.iso EMBED=./ubuntu-amd64-installer.ipxe

# Create USB bootable image
make bin/ipxe.usb EMBED=./ubuntu-amd64-installer.ipxe 

# Transfer the USB image to your target device (Note: XX is your target usbdevice ID)
dd if=bin/ipxe.usb of=/dev/sdXX

🎛️ Section 3: Interactive Multi-Choice Boot Menu

This builds an interactive iPXE boot selection screen with diagnostic network utilities:

1. The Interactive Script

#!ipxe

# static ip settings
ifopen net0
set net0/ip 192.168.1.100
set net0/netmask 255.255.255.0
set net0/gateway 192.168.1.2
set dns 192.168.1.2
set hostname puppet1
set domain_name domain.local
set repo_server 192.168.1.240
set preseed_file preseed.cfg

set menu-timeout 10000

menu iPXE boot menu
item
item ubuntu_netboot_14_04     Install Ubuntu Trusty 14.04
item reboot_ipxe              Reboot iPXE Menu
item debug_ipxe               Debug iPXE Network Connectivity
item

choose --timeout \${menu-timeout} --default ubuntu_netboot_14_04 target && goto ip_details || goto debug_ipxe

:ip_details
# If everything failed, give the user some options
echo Entering to shell for Debug
echo "Configured IP Details:"
show net0/ip
show net0/netmask
show net0/gateway
show dns
show hostname
show domain_name
show repo_server
show preseed_file
route
goto \${target}

:ubuntu_netboot_14_04
echo Starting Ubuntu Trusty 14.04_x64 installer for \${hostname}
set base-url http://archive.ubuntu.com/ubuntu/dists/trusty/main/installer-amd64/current/images/netboot/ubuntu-installer/amd64
kernel \${base-url}/linux priority=critical
initrd \${base-url}/initrd.gz
imgargs linux auto=true url=http://\${repo_server}/\${preseed_file} interface=eth0 hostname=\${hostname} domain=\${domain_name} netcfg/disable_dhcp=true netcfg/get_ipaddress=\${net0/ip} netcfg/get_netmask=\${net0/netmask} netcfg/get_gateway=\${net0/gateway} netcfg/get_nameservers=\${dns}
boot ||

:debug_ipxe
# for ping/nslookup to work enable ping/nslookup command in config.h while building ipxe
echo "Interface Stat: net0"
ifstat net0
echo "Ping to gateway \${net0/gateway} should work from here"
shell

:reboot_ipxe
echo "press any key to reboot"
exit

2. Compilation Rules

# Compile and output standard media options
# make bin/ipxe.iso EMBED=./ubuntu-amd64-installer.ipxe 
# make bin/8086100f.mrom bin/808610d3.mrom bin/10222000.rom bin/15ad07b0.rom bin/ipxe.iso EMBED=./ubuntu-amd64-installer.ipxe
# make bin/ipxe.usb EMBED=./ubuntu-amd64-installer.ipxe 
# dd if=bin/ipxe.usb of=/dev/sdXX