Deploy TFTP service under Linux

1. Introduction to TFTP service

TFTP is the abbreviation of Trivial File Transfer Protocol, which is a simple file transfer protocol . It is a protocol based on the UDP protocol for simple file transfer between the client and the server. It is suitable for low-cost and uncomplicated applications.

The TFTP protocol is specially designed for small file transfer. It can only obtain files from the server or write files to the server, but cannot list directories or perform authentication. TFTP protocol transmission is initiated by the client

The interaction process between client and server is shown in the following diagram:
insert image description here

2. Deploy TFTP service under Linux

2.1 Install TFTP service

  • Ubuntu networking, install xinetd (extended internet daemon) hosting service
sudo apt-get install xinetd

insert image description here

  • Query whether there is a xinetd.conf file under /etc/, if not, create a new one yourself, modify the content as follows
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/
defaults
{
    
    

}
#表示告诉xinetd要包含的文件或目录是/etc/xinetd.d
includedir /etc/xinetd.d
  • Create a linux/tftp folder and give it readable, writable and executable permissions (777)
mkdir -p /home/andyxi/linux/tftp
sudo chmod 777 /home/andyxi/linux/tftp/
  • Install tftp-hpa (client) and tftpd-hpa (server) service programs
sudo apt-get install tftp-hpa tftpd-hpa
  • Open the tftpd-hpa configuration file /etc/default/tftpd-hpa, and set the tftp directory created above as the TFTP server working directory
TFTP_DIRECTORY="/home/andyxi/linux/tftp"

⏩ Create the /etc/xinetd.d/tftp configuration file and add the following content. If there is no xinetd.d subdirectory in the /etc folder, you can create it yourself

server tftp
{
    
    
  socket_type = dgram
  wait = yes
  disable = no
  user = root
  protocol = udp
  server = /usr/sbin/in.tftpd
  server_args = -s /home/andyxi/linux/tftp -c 
  #log_on_success += PID HOST DURATION
  #log_on_failure += HOST
  per_source = 11
  cps =100 2
  flags =IPv4
}
  • Restart the tftpd-hpa service
sudo service tftpd-hpa restart
  • Restart the xinetd service
sudo service xinetd restart

2.2 TFTP test

Here, Ubuntu is used as the TFTP server, and the Linux development board is used as the client for TFTP testing. Make sure the network environment is normal, Ubuntu, Windows and the development board can ping each other

  • Create the test.c file in the /home/andyxi/linux/tftp directory of ubuntu
cd /home/andyxi/linux/tftp
vi test.c
  • Execute the tftp command on the development board to copy the test.c file in the TFTP working directory of the virtual machine to the development board
tftp -g -r test.c 192.168.10.100
  • If the file is successfully transferred to the development board, it means that the TFTP service is deployed successfully

Guess you like

Origin blog.csdn.net/Chuangke_Andy/article/details/127479449