How to Set Up a TFTP Server on Linux
If you are looking for a way to transfer files between two different systems, TFTP or Trivial File Transfer Protocol is an excellent choice. It is a lightweight, text-based protocol that can be easily implemented on different operating systems. In this article, we will explain how to set up a TFTP server on Linux.
Step 1: Install the TFTP Server
First, you need to install a TFTP server software on your Linux system. You can use any TFTP server software of your choice, but we will use the most popular one called ‘tftpd-hpa.’
To install ‘tftpd-hpa,’ open a terminal on your Linux system and run the following command:
“`
sudo apt-get install tftpd-hpa
“`
Note: This command is suitable for Debian-based Linux systems, including Ubuntu, Linux Mint, and Debian. If you have a different Linux distribution, you can install ‘tftpd-hpa’ from your distribution’s software repository.
Step 2: Configure the TFTP Server
The TFTP server configuration file is located at ‘/etc/default/tftpd-hpa.’ Open this file with your preferred text editor.
“`
sudo nano /etc/default/tftpd-hpa
“`
In this file, you need to set the following parameters:
**TFTP_USERNAME**: This is the user that will run the TFTP server. By default, it is set to ‘tftp’ user.
**TFTP_DIRECTORY**: This is the directory where the TFTP server stores files. By default, it is set to ‘/srv/tftp’ directory.
**TFTP_ADDRESS**: This is the IP address of the TFTP server. By default, it is set to ‘0.0.0.0,’ which means that the TFTP server listens to all available network interfaces.
**TFTP_OPTIONS**: This parameter is used to set various TFTP server options, such as binary mode, maximum file size, timeout, etc.
After making the necessary changes, save the file and close the text editor.
Step 3: Create the TFTP Directory
Next, you need to create the directory where the TFTP server stores files. By default, it is set to ‘/srv/tftp’ directory.
Create the directory using the following command:
“`
sudo mkdir /srv/tftp
“`
Change the directory ownership to the ‘tftp’ user by running the following command:
“`
sudo chown tftp:tftp /srv/tftp
“`
Step 4: Start the TFTP Server
Once you have configured the TFTP server and created the TFTP directory, you can start the TFTP server using the following command:
“`
sudo systemctl start tftpd-hpa
“`
You can check the status of the TFTP server using the following command:
“`
sudo systemctl status tftpd-hpa
“`
If everything is working correctly, you should see the ‘active (running)’ status.
To enable the TFTP server to start automatically at the system boot, run the following command:
“`
sudo systemctl enable tftpd-hpa
“`
Step 5: Test the TFTP Server
Now that you have set up the TFTP server, you can test it by transferring the files using a TFTP client.
On Windows, you can use the built-in ‘tftp’ client. Open a Command Prompt and run the following command to download a file from the TFTP server:
“`
tftp -i get
“`
On Linux, you can use the ‘tftp-hpa’ client. Open a terminal and run the following command to download a file from the TFTP server:
“`
tftp -c get
“`