Set Up TFTP Server

This guide will walk you through configuring your TFTP server so that your physical hosts can obtain the necessary files for PXE boot. Specifically, it will serve

  • the bootloader image,
  • the host-specific PXE configuration files, and
  • the OS specific kernel and initramfs

Note

You will use dnsmasq on your bootstrap host as to act as TFTP server.

What You’ll Need

Procedure

  1. Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:

    root@host:~# apt-get update root@host:~# apt-get install -y pxelinux syslinux-common dnsmasq
  2. Prepare the TFTP environment.

    1. Create the TFTP root:

      root@host:~# mkdir -p /var/lib/tftpboot
    2. Have the bootloader and the core module under the TFTP root:

      root@host:~# ln -sf /usr/lib/PXELINUX/pxelinux.0 /var/lib/tftpboot/ root@host:~# ln -sf /usr/lib/syslinux/modules/bios/ldlinux.c32 /var/lib/tftpboot/
    3. Create the PXE configuration root:

      root@host:~# mkdir -p /var/lib/tftpboot/pxelinux.cfg
  3. Have the kernel and initramfs available under the TFTP root. Choose one of the following options based on your desired OS.

    root@host:~# mkdir -p /var/lib/tftpboot/Rocky8 root@host:~# cp -av /mnt/iso/images/pxeboot/{initrd.img,vmlinuz} /var/lib/tftpboot/Rocky8/ '/mnt/iso/images/pxeboot/initrd.img' -> '/var/lib/tftpboot/Rocky8/initrd.img' '/mnt/iso/images/pxeboot/vmlinuz' -> '/var/lib/tftpboot/Rocky8/vmlinuz'
  4. Configure dnsmasq to act as TFTP server.

    1. Disable DNS. Copy the following configuration snippet and paste it in /etc/dnsmasq.d/dns.conf.

      # Disable DNS Server port=0 # Listen on all interfaces bind-interfaces
    2. Enable TFTP. Copy the following configuration snippet and paste it in /etc/dnsmasq.d/tftp.conf.

      enable-tftp tftp-root=/var/lib/tftpboot
    3. Restart the service:

      root@host:~# service dnsmasq restart

Verify

  1. Go to your bootstrap host and install the necessary packages, if you don’t have them already on your system:

    root@host:~# apt-get update root@host:~# apt-get install -y tftp-hpa
  2. Verify that you can download the bootloader image:

    root@host:~# tftp -v <IP> -c get /pxelinux.0 /dev/null Connected to <IP>, port 69 getting from <IP>:/pxelinux.0 to /dev/null [netascii] Received 42359 bytes in 0.1 seconds [5886262 bit/s]

    Replace <IP> with the IP address of your bootstrap host, for example:

    root@host:~# tftp -v 192.168.2.10 -c get /pxelinux.0 /dev/null Connected to 192.168.2.10 (192.168.2.10), port 69 getting from 192.168.2.10:/pxelinux.0 to /dev/null [netascii] Received 42359 bytes in 0.1 seconds [5886262 bit/s]
  3. Verify that you can download the OS kernel. Choose one of the following options based on your OS.

    root@host:~# tftp -v <IP> -c get /Rocky8/vmlinuz /dev/null Connected to <IP>, port 69 getting from <IP>:/Rocky8/vmlinuz to /dev/null [netascii] Received 10239302 bytes in 6.6 seconds [12467397 bit/s]

    Replace <IP> with the IP address of your boostrap host, for example:

    root@host:~# tftp -v 192.168.2.10 -c get /Rocky8/vmlinuz /dev/null Connected to 192.168.2.10 (192.168.2.10), port 69 getting from 192.168.2.10:/Rocky8/vmlinuz to /dev/null [netascii] Received 10239302 bytes in 6.6 seconds [12467397 bit/s]

Summary

You have successfully configured your TFTP server.

What’s Next

The next step is to set up your PXE server.