Setup TFTP Server on Ubuntu: Easy Guide to Configure, Start & Test

TFTP (Trivial File Transfer Protocol) is a simple, lightweight file transfer protocol that operates over UDP. It is commonly used in environments where minimal overhead is needed, such as:

Unlike FTP or SCP, TFTP doesn’t require authentication and is ideal for local network use. In this guide, we’ll walk through how to install, configure, and run a TFTP server on Ubuntu.


✅ Step 1: Install TFTP Server Package

Ubuntu uses tftpd-hpa as a popular and stable TFTP server daemon.

sudo apt update
sudo apt install tftpd-hpa -y

Explanation:

  • tftpd-hpa is a high-performance TFTP server implementation.
  • The -y flag auto-confirms the installation.

After this, the service will be installed but may not be configured yet.


📁 Step 2: Create TFTP Root Directory

By default, TFTP stores and serves files from /var/lib/tftpboot. You can use this or define your own.

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

Explanation:


⚙️ Step 3: Configure TFTP Settings

Edit the default configuration file:

sudo nano /etc/default/tftpd-hpa

Update the file with the following content:

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

Explanation of options:

  • TFTP_USERNAME: runs TFTP as this user.
  • TFTP_DIRECTORY: sets the root directory.
  • TFTP_ADDRESS: binds to all interfaces on port 69.
  • --secure: limits access to the root directory.
  • --create: allows uploading files using put.

🔁 Step 4: Restart and Enable the TFTP Server

sudo systemctl restart tftpd-hpa
sudo systemctl enable tftpd-hpa

Explanation:

To check the server status:

sudo systemctl status tftpd-hpa

You should see Active: active (running).


✏️ Step 5: Test TFTP Server with Client

🖼 Upload File to Server (PUT)

First, install the TFTP client:

sudo apt install tftp -y

Create a test file:

echo "Hello from client" > hello.txt

Upload file to server:

tftp localhost
tftp> put hello.txt
tftp> quit

Check server directory:

ls -l /var/lib/tftpboot

📥 Download File from Server (GET)

tftp localhost
tftp> get hello.txt
tftp> quit

Explanation:
These simple commands verify that both upload (put) and download (get) work.


🔒 Optional: Adjust Firewall Settings (UFW)

If you’re using a firewall like UFW, allow port 69/UDP:

sudo ufw allow 69/udp

🧠 Common Mistakes and Fixes

IssueFix/Explanation
Permission denied on uploadUse --create in config and set 777 permissions on TFTP root
Connection timeoutEnsure server is running and port 69/UDP is open
File not found on getFile must exist and be readable by tftp user
tftp: command not foundInstall client using sudo apt install tftp

🧪 Use Case: Transfer Firmware to a Router

TFTP is widely used in flashing OpenWRT or DD-WRT firmware:

  1. Place the .bin file into /var/lib/tftpboot
  2. Connect the router and your PC on same network
  3. Use router’s firmware recovery or bootloader to pull file via TFTP

TFTP is simple, fast, and effective—especially for embedded systems, PXE booting, and network hardware. While it’s not secure for Internet use, it’s perfect for LAN environments where speed and simplicity matter.

With just a few steps, you can have a fully working TFTP server on Ubuntu ready to serve files to any client on your network.

Have you used TFTP to flash devices or configure networks? Share your workflow or any helpful scripts in the comments!

1 thought on “Setup TFTP Server on Ubuntu: Easy Guide to Configure, Start & Test”

Leave a Comment