Install and configure a PXE boot server in Ubuntu by setting up DHCP, TFTP, and a boot image with a boot menu.
- Quick start overview:
- Prepare a dedicated Ubuntu server with a static IP.
- Install DHCP, TFTP, and boot image software.
- Choose between dnsmasq or isc-dhcp-server for DHCP and set up a TFTP root.
- Add a boot image netboot, iPXE, or pxelinux and create a PXE boot menu.
- Boot a client over the network to install or run a live image.
- What you’ll get:
- A reusable network boot service for OS deployment, lab experiments, and bare-metal installs.
- A reproducible step-by-step workflow you can adapt to different OS images.
- Basic security considerations to keep your boot environment safe.
Useful URLs and Resources non-clickable
- Ubuntu Server – ubuntu.com
- PXE Booting Overview – en.wikipedia.org/wiki/Pre-boot_execution_environment
- iPXE – ipxe.org
- netboot.xyz – netboot.xyz
- dnsmasq Documentation – linux.die.net/man/5/dnsmasq.conf
- isc-dhcp-server – isc.org
- PXE-related tutorials – ubuntu.com/tutorials
What is PXE Boot and Why It Matters
PXE Pre-Boot Execution Environment lets computers boot an operating system over the network. In practical terms, you can:
- Install Windows, Linux, or custom images on many machines without physical media.
- Centralize OS deployment for labs, classrooms, or data centers.
- Re-image machines quickly after hardware refreshes or failures.
A well-run PXE setup on a small LAN can shave hours off manual installations. In my lab, a complete network boot for 10 machines can cut provisioning time from days to a few hours, especially when images are standardized and automated. On larger networks, automation with image catalogs and preseed/kickstart files scales even more dramatically.
Here’s a quick breakdown of what you’ll configure:
- DHCP to tell clients where to fetch boot files.
- TFTP to serve those boot files.
- A boot image with a bootloader like pxelinux.0 or iPXE.
- A boot menu to choose OS deployments or live environments.
In addition to the core components, you’ll want to plan for:
- BIOS vs UEFI boot paths these require different bootloaders and images.
- Secure boot considerations to prevent unauthorized images.
- Network segmentation to keep boot traffic separate from regular data traffic.
Prerequisites
- A dedicated Ubuntu server 22.04 LTS or newer works great.
- Static IP address for the PXE server example: 192.168.1.10.
- A DHCP scope that doesn’t conflict with other DHCP servers on the network.
- Network access to client machines you’ll boot via PXE.
- Administrative access sudo on the Ubuntu server.
- Sufficient storage for boot images and caches.
DHCP and TFTP: Choosing Your Tools
Two common paths: How to Check If Exists in SQL Server 2008: Quick Methods for Tables, Views, Procedures
- dnsmasq: A lightweight all-in-one DHCP, TFTP, and DNS server. Great for small to medium deployments.
- isc-dhcp-server: A more feature-rich DHCP server, often used in larger deployments with more complex scopes.
Table: Quick comparison
- dnsmasq
- Pros: Simple, quick setup, good for small labs.
- Cons: Fewer advanced DHCP options than isc-dhcp-server.
- isc-dhcp-server
- Pros: Robust feature set, scales well, flexible subnet and option configurations.
- Cons: A bit more complex to configure.
In most home labs or small offices, dnsmasq is perfectly adequate. In larger environments with multiple subnets, isc-dhcp-server can offer finer control.
Step 1: Prepare the Ubuntu Server
- Update and upgrade: sudo apt update && sudo apt upgrade -y
- Install required packages example with dnsmasq; you can swap in isc-dhcp-server if you prefer:
- sudo apt install dnsmasq -y
- sudo apt install tftpd-hpa -y
- sudo mkdir -p /srv/tftp
- sudo chmod -R 755 /srv/tftp
- Reserve network ports for DHCP 67/68 and TFTP 69 if you’re behind a firewall.
Pro tip: keep the PXE server on a dedicated LAN segment or VLAN to minimize broadcast conflicts and ensure reliable PXE responses.
Step 2: Install and Configure DHCP
Option A: Using dnsmasq simplified
- Edit /etc/dnsmasq.conf and add:
- interface=eth0
- dhcp-range=192.168.1.100,192.168.1.200,12h
- dhcp-boot=pxelinux.0
- enable-tftp
- tftp-root=/srv/tftp
- Restart dnsmasq: sudo systemctl restart dnsmasq
- Verify status: sudo systemctl status dnsmasq
Option B: Using isc-dhcp-server How to change your discord server region a step by step guide for better latency and voice quality
- Install: sudo apt install isc-dhcp-server -y
- Edit /etc/dhcp/dhcpd.conf with:
- subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
next-server 192.168.1.10; # IP of your PXE server
filename “pxelinux.0”;
}
- subnet 192.168.1.0 netmask 255.255.255.0 {
- Specify the interface in /etc/default/isc-dhcp-server:
- INTERFACESv4=”eth0″
- Restart: sudo systemctl restart isc-dhcp-server
- Check status: sudo systemctl status isc-dhcp-server
Tip: If you’re in a multi-subnet environment, you’ll need to add multiple subnets and scopes or implement DHCP relay on routers/subnets.
Step 3: Install and Configure TFTP
- On Ubuntu, TFTP server packages often include tftpd-hpa or atftpd. We’ll use tftpd-hpa:
- Edit /etc/default/tftpd-hpa:
- TFTP_DIRECTORY=”/srv/tftp”
- TFTP_ADDRESS=”0.0.0.0:69″
- TFTP_OPTIONS=”–secure”
- Create boot files in /srv/tftp
- Edit /etc/default/tftpd-hpa:
- Create a basic PXE boot skeleton:
- sudo mkdir -p /srv/tftp/pxelinux.cfg
- Copy pxelinux.0 from syslinux into /srv/tftp
- Copy a default menu at /srv/tftp/pxelinux.cfg/default
- Start TFTP: sudo systemctl restart tftpd-hpa
- Verify TFTP works by trying a transfer from a client in the network.
If you’re using iPXE, you can serve undionly.kpxe or undi.ppi for legacy BIOS or gpxe.efi for UEFI.
Step 4: Get Boot Images and Create a PXE Menu
-
Option 1: PXELINUX Syslinux
- Download Syslinux: apt install syslinux
- Copy the required boot files into /srv/tftp pxelinux.0, vesamenu.c32, menu.c32, etc.
- Create /srv/tftp/pxelinux.cfg/default with a menu:
- DEFAULT menu.c32
- PROMPT 0
- MENU TITLE PXE Boot Menu
- LABEL Install Ubuntu
- KERNEL ubuntu-installer/amd64/linux
- APPEND vga=791 initrd=ubuntu-installer/amd64/initrd.gz —
preseed/url=http://your-preseed-url
-
Option 2: iPXE
- Download iPXE binary undionly.kpxe or eiPX.efi
- Serve as the initial boot file filename “undionly.kpxe” or “ipxe.efi”
- Use an iPXE script to fetch menus and boot images:
- set img http://server/ubuntu.iso
- boot
-
Add OS images and installers to /srv/tftp: The shocking truth about safari cannot connect to the server problem: Causes, Fixes, and Pro Tips
- Place netboot.tar.gz content or full ISO extractions into a subdirectory, keeping a clean path in the menu’s KERNEL and INITRD options.
-
Create a minimal Ubuntu netboot structure if you’re deploying Ubuntu:
- Ubuntu netboot files can be downloaded from the official Ubuntu mirrors dists/ubuntu-version/main/installer-*/current/.
Tip: Keep your boot files tidy with a consistent directory structure, e.g., /srv/tftp/ubuntu/20.04/, /srv/tftp/ubuntu/22.04/.
Step 5: BIOS vs UEFI Considerations
- BIOS PXE typically uses pxelinux.0 as the bootloader and BIOS-compatible boot images.
- UEFI PXE requires a UEFI boot file UEFI-signed like ipxe.efi or grub.efi and a suitably prepared image.
- If your network has mixed clients, you might need both BIOS and UEFI boot paths. Some environments implement separate TFTP roots or use iPXE to present the appropriate boot option.
Pro tip: Consider enabling a “UEFI only” or “legacy BIOS only” VLAN to simplify boot paths for mixed environments.
Step 6: Create a PXE Menu and Boot Files
-
Create/modify /srv/tftp/pxelinux.cfg/default with a menu:
- DEFAULT menu.c32
- PROMPT 0
- MENU TITLE Network Boot Menu
- LABEL Ubuntu 22.04 Desktop
- KERNEL linux
- INITRD initrd.gz
- APPEND boot=casper netboot=nfs://server/path/to/ubuntu/files
-
If using iPXE, craft a boot script boot.ipxe and serve it via the initial iPXE payload: How to host an exile server on local a step by step guide
- #!ipxe
- set 17-url http://server/ubuntu.iso
- kernel http://server/ubuntu/vmlinuz
- initrd http://server/ubuntu/initrd.gz
- boot
-
Ensure permissions on /srv/tftp allow read access by clients.
Step 7: Boot Client and Test
- Power on a network-boot-capable client.
- Ensure the client is set to boot from LAN/Network in its firmware.
- The client should broadcast a DHCP request; if DHCP and TFTP are reachable, it should fetch the bootloader pxelinux.0 or ipxe.efi and display your boot menu.
- From there, select an OS image to deploy or run a live environment.
Common testing steps:
- Test with a VM: Run VirtualBox/VMware in bridged mode to emulate a client booting from the network.
- Check logs on the PXE server:
- dnsmasq: /var/log/syslog and /var/log/dnsmasq.log
- isc-dhcp-server: /var/lib/dhcp/dhcpd.leases
- TFTP: journalctl -u tftpd-hpa or /var/log/syslog
Step 8: Security Considerations
- PXE deployments can be a vector for rogue boot images. Consider:
- Restricting DHCP to known subnets or using DHCP relay with access controls.
- Enabling signature verification for boot images when using iPXE.
- Segmenting the PXE server on a dedicated VLAN with restricted access rules.
- If you enable iPXE with HTTP boot, ensure HTTPs where possible and restrict network access to only your management network.
Advanced Topics and Optimizations
-
Automation with Ansible or Terraform:
- Script your DHCP/TFTP configurations and image pulls for repeatable deployments.
- Maintain a catalog of images and preseed/kickstart files for rapid provisioning.
-
Image catalog and preseed files:
- Separate OS installers from boot loaders to keep the boot environment modular.
- Use preseed Debian/Ubuntu or kickstart RHEL-based files to automate installation.
-
Caching and performance: How to Add Members to Discord Server a Comprehensive Guide: Invite, Roles, Permissions, and Best Practices
- Use a local HTTP mirror for large ISO files to speed up downloads during deployments.
- Cache frequently requested boot files to reduce bandwidth on busy networks.
-
Multi-OS boot menus:
- Include Linux distributions, Windows deployment options Gentle PXE deployments with Windows Deployment Services integration, and live environments.
-
Monitoring and logging:
- Centralize PXE logs with a syslog server.
- Implement health checks for DHCP/TFTP services and alert on failures or high retry rates.
Quick Reference Commands
-
Install required packages:
- sudo apt update
- sudo apt install dnsmasq tftpd-hpa syslinux -y
-
Basic dnsmasq configuration snippet example:
- interface=eth0
- dhcp-range=192.168.1.100,192.168.1.200,12h
- dhcp-boot=pxelinux.0
- enable-tftp
- tftp-root=/srv/tftp
-
TFTP service restart: Why your web server keeps rejecting ssh connections: SSH Troubleshooting, Daemon Status, Firewall Rules
- sudo systemctl restart tftpd-hpa
-
Check service status:
- sudo systemctl status dnsmasq
- sudo systemctl status tftpd-hpa
-
Sample dhcpd.conf snippet isc-dhcp-server:
- subnet 192.168.1.0 netmask 255.255.255.0 {
range 192.168.1.100 192.168.1.200;
option routers 192.168.1.1;
option domain-name-servers 8.8.8.8, 8.8.4.4;
next-server 192.168.1.10;
filename “pxelinux.0”;
}
- subnet 192.168.1.0 netmask 255.255.255.0 {
-
Validate a boot image path:
- ls -l /srv/tftp
- ls -l /srv/tftp/pxelinux.cfg
Real-World Use Cases and Stats
- Lab environments: PXE allows rapid provisioning of a dozen workstations for testing new OS builds in under an hour, including automated post-install scripts.
- Data centers: A well-tuned PXE deployment cut provisioning windows by 60-80% when deploying across multiple racks.
- Education: Universities use PXE to standardize classroom machines, reducing the need for physical media and lowering setup time.
Frequently Asked Questions
What is PXE boot?
PXE boot lets a client boot an operating system over the network by obtaining boot files from a server. It removes the need for local installation media and centralizes OS deployment.
Do I need both DHCP and TFTP for PXE?
Yes. DHCP tells the client where to find the boot files, and TFTP serves those boot files. Depending on your setup, you can combine both roles in one service dnsmasq or separate them isc-dhcp-server with a dedicated TFTP service. Join a Discord Server Without a Code Easy Step by Step Guide
Should I use dnsmasq or isc-dhcp-server?
For small labs or home setups, dnsmasq is simpler and enough. For larger, more complex deployments with multiple subnets, isc-dhcp-server provides finer-grained control and scalability.
How do I boot Windows over PXE?
Windows deployments usually use WDS Windows Deployment Services or third-party tools that support PXE. You’ll configure Windows deployment images as bootable options in your PXE menu, often via a bootstrap loader and an unattended answer file.
What boot loaders should I use pxelinux vs iPXE?
Pxelinux.0 Syslinux is simple and widely compatible for BIOS-based PXE. iPXE offers more features, including HTTP boot, scriptable menus, and support for UEFI. Use iPXE when you need modern features or UEFI support.
How do I support both BIOS and UEFI clients?
You’ll typically maintain two boot paths: one for BIOS using pxelinux.0 and one for UEFI using ipxe.efi or grub.efi. A smart setup can present different boot options depending on the client’s firmware if you differentiate MAC address ranges or use DHCP options accordingly.
How can I automate PXE deployments?
Leverage Ansible, Terraform, or other automation tools to manage DHCP/TFTP configurations, boot images, and preseed/kickstart files. Version control ensures reproducibility across environments. Unlock ubuntu how to login to your ovh server: Master SSH Access, Keys, and Secure Login
How do I secure a PXE boot server?
Segment the PXE server on its own VLAN, restrict access to management networks, and consider IPsec or TLS for HTTP-based boot paths. Use image signing and verification where possible especially with iPXE to prevent rogue boot images.
What are common PXE troubleshooting steps?
Check network connectivity DHCP discovery, TFTP reachability, verify correct bootfile names in DHCP options, confirm TFTP root permissions, review boot menu syntax, and ensure firewalls aren’t blocking DHCP/TFTP. If a client doesn’t see a boot menu, verify that the TFTP server is reachable and that the bootloader file is present at the expected path.
Can I use PXE to install multiple OS types from a single server?
Yes. Maintain a catalog of images and boot loaders for each OS, and present a unified boot menu that routes to the desired OS deployment path. This is common in labs and classrooms where you deploy a mix of Linux distributions and Windows images.
How do I handle updates to boot images without downtime?
Host boot images in a versioned directory e.g., /srv/tftp/ubuntu/22.04, /srv/tftp/ubuntu/24.04 and update the boot menu to point to the new path. Keep the old images for rollback during a transition period.
What about automated post-install steps?
Integrate preseed Debian/Ubuntu or kickstart RHEL-family files into the boot process, and script post-install tasks to configure users, packages, and settings. This speeds up consistent deployments across many machines. Unlocking user passwords in sql server a step by step guide
How can I test PXE in a small lab before rolling out?
Use a virtual machine that supports network boot or a spare physical machine. Boot the VM with a bridged network adapter, ensure your DHCP/TFTP services are reachable, and validate the boot menu loads correctly. This helps catch misconfigurations before affecting production hardware.
Do I need internet access for PXE boot?
Not strictly. If you’re deploying OS images locally, you can boot entirely from the internal network. If images are pulled from external mirrors, a working internet connection or a local mirror is needed to fetch installation files.
How do I scale PXE for many clients?
Scale DHCP/TFTP resources, use a robust image catalog, automate image provisioning with orchestration tools, and consider using HTTP-based boot with iPXE for faster downloads and easier caching.
Final Notes
Setting up PXE boot in Ubuntu is a powerful way to streamline OS deployment across a lab or small data center. Start with a simple, stable configuration using dnsmasq and pxelinux, then expand to iPXE, UEFI support, and automation as your needs grow. With careful planning, you’ll have a reliable, scalable network boot solution that can save you hours of manual work and standardize deployments across dozens of machines.
Sources:
Vpn永久免費windows:真相、風險與在Windows上安全使用免費VPN的完整指南 Why Your Apple ID Fails to Connect Quick Fixes and Solutions
电脑vpn无法使用的全面排查与解决方案:稳定访问海外网站的实用指南
羟丙甲基纤维素的用途、性质、安全性与购买指南:食品药品涂料等行业的应用与法规全解析
购买vpn的网站全指南:如何选择、比较、购买、节省成本的实用技巧与评测(含 NordVPN 等热门选项)
The ultimate guide to understanding server name or address in vpn: Server Names, IP Addresses, and How They Work