Set Up a TFTP Server on Ubuntu for Network Booting

Network booting lets a computer fetch its first boot files from a server rather than local media. Its firmware requests a bootloader over UDP, commonly through PXE, and the server returns a kernel, installer, or recovery image. On Ubuntu, this supports automated deployments, diskless systems, embedded devices, and workshops where USB installers would slow the process.

Trivial File Transfer Protocol (TFTP) supplies files, but DHCP assigns addresses and tells each client which server and filename to request. The example below runs both services on one Ubuntu host; separate hosts work too if their addresses and routes are configured. It assumes a wired private IPv4 network and exactly one DHCP authority per broadcast domain.

Plan the boot network before changing services

Choose a fixed address for the Ubuntu server, such as 192.168.1.10, and exclude it from the DHCP pool. Check the active interface and current routes with ip -br addr and ip route. If Ubuntu manages the Ethernet link through NetworkManager, set the address statically there or in Netplan so it returns after a reboot.

Australian NBN installations often place an ISP gateway in front of the customer’s router, whether the service is FTTP, FTTN, HFC, or fixed wireless. That gateway commonly owns 192.168.1.0/24 and runs DHCP, so adding dnsmasq to the same range creates two DHCP servers. Either disable the gateway’s DHCP after confirming how to restore it, or place the PXE service on an isolated VLAN with its own subnet, such as 192.168.50.0/24.

Before changing the router, check what the target computer supports. Current systems normally use UEFI and need an .efi bootloader, while older systems use BIOS and load pxelinux.0. Network booting over Wi-Fi is uncommon, so use Ethernet. In apartments in Sydney or Melbourne, a wired port or clearly separated IoT VLAN is more dependable than congested shared Wi-Fi. Ubiquiti UniFi gateways and TP-Link Omada switches are common in the Australian market and can provide VLAN tagging, although their management interfaces vary by model.

Install and secure the TFTP daemon

Install the HPA daemon, which provides a small TFTP service suitable for serving boot files:

sudo apt update
sudo apt install tftpd-hpa

The package creates the tftp user and a systemd service. Edit its defaults with sudo nano /etc/default/tftpd-hpa and use settings similar to these:

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/srv/tftp"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_SECURE="yes"
TFTP_OPTIONS="--secure --verbose"

Binding to all interfaces is convenient for a dedicated server, although an explicit server address can reduce exposure. The secure option prevents clients from escaping the configured directory with traversal paths. TFTP itself has no authentication or encryption, so network isolation remains essential.

Create the export directory and start the service:

sudo install -d -o tftp -g tftp -m 0755 /srv/tftp
sudo systemctl enable tftpd-hpa
sudo systemctl restart tftpd-hpa
sudo systemctl status tftpd-hpa --no-pager
sudo ss -lunp | grep ':69'

If UFW is active, permit TFTP only from the local boot subnet. Replace the example subnet when using a VLAN:

sudo ufw allow from 192.168.1.0/24 to any port 69 proto udp

Configure DHCP to deliver boot details

DHCP provides the client’s address, the TFTP server address in option 66, and the initial filename in option 67. Some consumer routers allow custom DHCP options, but many cannot provide architecture-specific UEFI filenames. Dnsmasq gives precise control over these values and can share the same /srv/tftp directory with tftpd-hpa.

Install dnsmasq and create a dedicated configuration file:

sudo apt install dnsmasq
sudo nano /etc/dnsmasq.d/pxe.conf

Replace eno1 with the Ethernet interface found earlier, then add settings along these lines:

interface=eno1
bind-dynamic
port=0
dhcp-range=192.168.1.100,192.168.1.199,255.255.255.0,12h
dhcp-option=option:router,192.168.1.1
dhcp-option=option:subnet-mask,255.255.255.0
dhcp-option=option:dns-server,192.168.1.1
dhcp-option=option:tftp-server,192.168.1.10
enable-tftp
tftp-root=/srv/tftp
dhcp-match=set:efi64,option:client-arch,7
dhcp-match=set:efi64,option:client-arch,9
dhcp-match=set:efi64,option:client-arch,15
dhcp-option=tag:efi64,option:bootfile-name,syslinux.efi
dhcp-match=set:bios,option:client-arch,0
dhcp-option=tag:bios,option:bootfile-name,pxelinux.0

Setting port=0 disables dnsmasq’s DNS function while retaining DHCP and TFTP, which avoids competing with systemd-resolved. The architecture rules cover common x86-64 UEFI identifiers and legacy BIOS clients. Raspberry Pi and other ARM boards require their own firmware files and should not be assigned the x86 filenames automatically.

Do not start dnsmasq until the NBN gateway or another router is no longer answering DHCP on this network. Two active DHCP servers can produce unpredictable addresses and boot options. After saving the file, restart the service and inspect its log:

sudo systemctl enable dnsmasq
sudo systemctl restart dnsmasq
sudo journalctl -u dnsmasq -n 30 --no-pager

If UFW is enabled, also permit the DHCP server port from the same subnet:

sudo ufw allow from 192.168.1.0/24 to any port 67 proto udp

Prepare boot files and run a local test

PXELINUX can provide a menu and load Linux kernels and initial RAM disks. Install the relevant packages and copy the BIOS and UEFI bootloaders into the TFTP root:

sudo apt install pxelinux syslinux-efi
sudo install -d /srv/tftp/pxelinux.cfg
sudo cp /usr/lib/PXELINUX/pxelinux.0 /srv/tftp/
sudo cp /usr/lib/syslinux/modules/bios/ldlinux.c32 /srv/tftp/
sudo cp /usr/lib/syslinux/modules/bios/libcom32.c32 /srv/tftp/
sudo cp /usr/lib/syslinux/modules/bios/libutil.c32 /srv/tftp/
sudo cp /usr/lib/syslinux/efi64/syslinux.efi /srv/tftp/syslinux.efi

Package paths can vary slightly between Ubuntu releases. Use dpkg -L pxelinux, dpkg -L syslinux-common, and dpkg -L syslinux-efi to locate the files if a copy command reports that its source is missing. Keep the bootloader names consistent with the DHCP configuration.

Download the current Ubuntu LTS amd64 netboot archive from the official Ubuntu archive, verify its checksum, and extract it into the export directory. An Australian Ubuntu mirror can reduce download time for large netboot images:

sudo mkdir -p /srv/tftp/netboot
sudo tar -xzf netboot.tar.gz -C /srv/tftp/netboot

Create /srv/tftp/pxelinux.cfg/default with a menu matching the extracted archive:

DEFAULT netboot
PROMPT 0
TIMEOUT 50
LABEL netboot
  KERNEL /netboot/ubuntu-installer/amd64/boot/linux
  INITRD /netboot/ubuntu-installer/amd64/boot/initrd.gz
  APPEND initrd=initrd.gz vga=normal --- quiet

The kernel and initial RAM disk paths must match the files actually extracted. PXELINUX downloads the selected files, after which Ubuntu’s installer can obtain the remaining installation files over the network. A signed GRUB and shim pair is required for PXE systems with UEFI Secure Boot enabled; unsigned Syslinux may be rejected before the menu appears.

Test file delivery before involving firmware:

echo 'TFTP works' | sudo tee /srv/tftp/test.txt >/dev/null
sudo chown tftp:tftp /srv/tftp/test.txt
sudo apt install tftp-hpa
tftp 127.0.0.1 -m octet -c get test.txt

Run the same client command from another computer, replacing 127.0.0.1 with 192.168.1.10. A successful local transfer confirms the daemon and directory permissions, while a remote transfer confirms basic network reachability.

Troubleshoot failures and keep the service contained

Watch both services and capture their network traffic while a client attempts to boot:

sudo journalctl -u tftpd-hpa -f
sudo journalctl -u dnsmasq -f
sudo tcpdump -ni eno1 'udp port 67 or udp port 69'

Missing DHCP offers usually indicate a cable problem, VLAN mismatch, competing DHCP server, or blocked UDP port 67. A missing boot filename points to option 67 or an unmatched architecture rule. If a transfer starts and then stalls, inspect directory permissions, firewall rules, and the requested path. The linked network troubleshooting notes provide extra examples for checking interfaces, routes, and sockets when service logs are inconclusive.

PXE error messages also narrow down the failure. PXE-E51 generally means no DHCP offer arrived, while PXE-E53 means the server did not supply a boot filename. A menu that appears but refuses to load a kernel indicates a missing or incorrect kernel, initial RAM disk, or GRUB configuration. Check the client’s architecture and confirm that every path in the menu is relative to /srv/tftp.

Keep UDP ports 67 and 69 restricted to the boot VLAN. Do not forward TFTP from an NBN connection or the public internet: the protocol provides neither authentication nor encryption, and many Australian NBN services use shared public addressing that provides no useful protection anyway. A separate IoT or provisioning VLAN, combined with the fixed DHCP range shown here, offers a safer boundary for ordinary home and office equipment.

Keeping timestamps consistent also helps when comparing DHCP, TFTP, and client logs across daylight-saving changes:

sudo timedatectl set-timezone Australia/Sydney

The practical takeaway is to give the PXE host a fixed address, keep one DHCP authority on its VLAN, restrict UDP 67 and 69 to that network, and verify the complete chain with a real UEFI computer. This makes each failure traceable to addressing, DHCP, file delivery, or the boot payload, leaving a repeatable network-booting service ready for routine deployments.