TFTP ( Trivial File Transfer Protocol ) Server and Client Configurations
Tags: networking, protocol, tftp
Published: 2023-03-27 20:43:36

> ##  What is TFTP ?


  Trivial File Transfer Protocol (TFTP) is a simple file 
  transfer protocol that allows a client to retrieve or 
  transfer files from a server.
 
  It is a UDP-based protocol that uses port 69 for 
  communication. 

  TFTP supports only two transfer modes: "netascii" and 
  "octet." Netascii mode is used for transferring text files, 
  while octet mode is used for transferring binary files.



> ##  Advantages of TFTP

1. **Lightweight**: TFTP is designed to be lightweight, meaning 
   it uses fewer system resources than other file transfer 
   protocols such as network switches and 
   routers.

2. **Simple**: TFTP has a simple packet format and supports only 
   two transfer modes, making it easy to implement and use. 
   

3. **Fast**: TFTP uses the User Datagram Protocol (UDP) instead 
   of Transmission Control Protocol (TCP), which makes it 
   faster than other protocols.

4. **Easy to configure**: TFTP is easy to configure and does not 
   require complex setup or authentication. 

5. **Widely supported**: TFTP is widely supported by many network 
   devices, including routers, switches, and firewalls. 

6. **Low overhead**: TFTP has a low overhead, meaning it uses 
   minimal network bandwidth and system resources. 

> ##  Disadvantages of TFTP

1. **No authentication**: TFTP does not provide any authentication mechanisms, which means that anyone who has access to the TFTP server can download or upload files to it. 

2. **Slow transfer speeds**: TFTP uses UDP (User Datagram Protocol), which does not provide any error-checking or congestion control mechanisms. This can lead to slower transfer speeds.

3. **Limited file size**: TFTP has a maximum file size limit of 32 MB, which makes it unsuitable for transferring large files.

4. **No encryption**: TFTP does not provide any encryption mechanisms, which means that data transferred using TFTP can be intercepted and read by third parties. 



> ## **How can we configure TFTP server in Ubuntu?**

**Step 1**: Open the terminal and update the package lists for apt

```
sudo apt update
```

**Step 2**: Install the TFTP server software on the PC that will act as the server using the following command:

```
sudo apt install tftpd-hpa
```

**Step 3**: Check the status of the TFTP daemon service called "tftpd-hpa" on a Linux system

```
sudo systemctl status tftpd-hpa
```
**Step 4** : Open and edit the configuration file for the TFTP daemon service called "tftpd-hpa" on a Linux system

```
sudo gedit /etc/default/tftpd-hpa
```

**Step 5** : Make tftp Folder

```
sudo mkdir /tftp
```

**Step 6** : Change the ownership of the directory "/tftp" to the user and group "tftp" on a Linux system.

```
sudo chown tftp:tftp /tftp
```

**Step 7** : Restart the TFTP daemon service called "tftpd-hpa" on a Linux system.

```
sudo systemctl restart tftpd-hpa
```

> ## **How can we configure TFTP Client in Ubuntu?**

**Step 1** : 

```
sudo apt install tftp-hpa
```

**If you got errrors run below commands**

```
sudo lsof /var/lib/dpkg/lock
sudo lsof /var/lib/apt/lists/lock
sudo lsof /var/cache/apt/archives/lock

sudo rm /var/lib/apt/lists/lock
sudo rm /var/cache/apt/archives/lock
sudo rm /var/lib/dpkg/lock

sudo kill -9 <process_id>

```

> ## Server Command 

```
ip a show
```

> ## Client Command 

**Step 1** : Start a TFTP client session with a TFTP server located at the specified IP address.

```
sudo tftp <<server's ip_address>>
```
**Step 2** : Download a file called "server.txt" from a remote TFTP server to the local system.

```
get server.txt
```

> ## Server Command

Upload a file called "client.txt" from the local system to a remote TFTP server.

```
put client.txt
```

> ## **Conclusion**

Overall, TFTP is a simple and lightweight protocol that is suitable for transferring small files in a low-security environment. However, it may not be the best choice for transferring sensitive or large files, or for use in high-security environments where data privacy is a concern.