How to Install and Configure a TFTP Server on Ubuntu 24.04

Learn the commands for installing TFTP on Ubuntu 24.04 Linux to perform the basic transfer of files.

Trivial File Transfer Protocol (TFTP) is a lightweight alternative to standard FTP for transferring files between networked devices. Compared to FTP and HTTP, TFTP is simpler and can be operated without any complexity that we generally have in the client-server model. This is why this protocol performs basic file transfer, such as transferring configuration files and firmware updates to network devices like routers, switches, and phones. TFTP uses UDP (User Datagram Protocol) as its transport layer, making it faster but less reliable.

TFTP supports only basic commands such as read (RRQ), write (WRQ), and acknowledge (ACK). It also lacks features like directory listing, user authentication, and file permissions management.

Common Use Cases for TFTP

  • Network Booting and Firmware Upgrades
  • Used in network management systems to transfer logs, monitoring data, or configuration files
  • Useful in Embedded Systems
  • Ideal for file transfers within isolated or controlled networks

Limitations of TFTP

  • It does not support directory listings, user authentication,
  • Lack of Security: absence of encryption and authentication
  • Unreliable Over Unstable Networks
  • Fixed 512-byte block size; hence, it is not suitable for sending large files

What do we need to perform this tutorial?

  • An Ubuntu 24.04 system or earlier version such as Ubuntu 20.04, 22.04, or 23.04.
  • User with sudo access
  • To download packages, we need a stable internet connection.

Step 1: Refersh Ubuntu 24.04 Package list

On your Ubuntu system, visit the command terminal and run the given APT command to update the package list and get the latest versions of installed packages.

sudo apt update && sudo apt upgrade

Step 2: Installing the TFTP Server and Client

Now, we use the Ubuntu 24.04 default system repository to install the TFTP server and client packages available without adding any external repo.

sudo apt install tftpd-hpa tftp-hpa

Step 3: Create a Directory to store files

Let’s create a directory to save the files we need to upload or download using the TFTP server. Here are the commands and permissions needed for the directory to work.

Create a directory:

sudo mkdir -p /var/lib/tftpboot

Set Permissions:

sudo chown -R nobody:nogroup /var/lib/tftpboot
sudo chmod -R 777 /var/lib/tftpboot

Now, whatever you want to upload or download should be saved under “/var/lib/tftpboot.”

Step 3: Configure the TFTP Server

Once the installation of the server and client are completed along with the directory, let’s edit the TFTP server configuration file to add or change the configuration as given below:

Open the Configuration File:

sudo nano /etc/default/tftpd-hpa

Edit the Configuration File:

Either copy or replace the existing configuration or modify it as given below to match the following configuration:

# /etc/default/tftpd-hpa

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/lib/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="--secure"
TFTP_OPTIONS="-l -c -s"

Save and Close the File:

Save the changes and exit the text editor by pressing CTRL + X, then Y and Enter).

Step 4: Restart TFTP Server

To apply the changes we have made so far, restart the TFTP server using the given command:

sudo systemctl restart tftpd-hpa

You can also enable the service to start at boot automatically:

sudo systemctl enable tftpd-hpa

Step 5: Upload or Download files.

Now, we can test the created TFTP server to upload or download the files from the TFTP server running on Ubuntu 24.04 Linux. Well, first install the TFTP client on your local Linux machine you want to use to connect the TFTP server:

sudo apt install tftp-hpa

After that, connect the TFTP server. For example, our Ubuntu 24.04 IP address is 192.168.1.15, so to connect it, the command will be:

tftp ip-address

After establishing the connection, we can check the status of the server using the command:

status

Whereas, if you want to see what is happening while executing the command in TFTP, we can enable the “Verbose” by typing:

verbose

To download files from the remote TFTP server, use:

get myfile

Example:

get test.php

To upload or push the file to a remote TFTP server from your local PC using the client:

put myfile

Example:

put demo.php

Setting up TFTP on Ubuntu is straightforward, and we have already seen that; however, TFTP is useful only for environments where lightweight file transfers are needed. Hence, it is useful in network device configurations and PXE booting.

Other Articles:

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.