What is TFTP?
Trivial File Transfer Protocol (TFTP) is a lightweight, bare-bones file transfer protocol used primarily for booting computers over a network (PXE Boot) or backing up router and switch configurations. Because it lacks authentication and directory listing capabilities, it is extremely fast and easy for basic firmware and BIOS systems to utilize.
Step 1: Install the TFTP Server
To begin, you need to install the TFTP server package and the xinetd daemon (which manages the TFTP service) on your CentOS Linux server. Open your terminal and run:
sudo yum install tftp-server xinetd -y
Step 2: Configure the TFTP Service
The configuration file for TFTP is managed by xinetd. Open the configuration file in a text editor:
sudo nano /etc/xinetd.d/tftp
Find the line that says disable = yes and change it to:
disable = no
Take note of the server_args line (which usually defaults to -s /var/lib/tftpboot). This dictates the root directory where your boot files or configuration backups will be stored.
Step 3: Start and Enable the Services
With the configuration updated, you must start the xinetd service and enable it to start automatically when the server boots:
sudo systemctl start xinetdsudo systemctl enable xinetd
You should also start and enable the TFTP service explicitly:
sudo systemctl start tftpsudo systemctl enable tftp
Step 4: Configure the Firewall
TFTP operates over UDP port 69. If you have firewalld running on your CentOS server, you must open this port to allow client devices to connect and download their boot images.
sudo firewall-cmd --permanent --add-service=tftpsudo firewall-cmd --reload
Step 5: Populate the Boot Directory
Your TFTP server is now active, but the root directory (/var/lib/tftpboot) is empty. You must copy your PXE boot files (such as pxelinux.0, kernel images, and initial ramdisks) into this directory. Ensure that the files have the correct read permissions so the TFTP service can serve them to connecting clients:
sudo chmod -R 755 /var/lib/tftpboot
Clients configured to network boot will now be able to request files from your CentOS TFTP server.