installation
sudo apt-get install xinetd
sudo apt-get install tftp tftp-hpa tftpd-hpa
Configuration
The configuration /etc/xinetd.d/tftp
file (create it if you don’t have one) is as follows:
service tftp {
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/tftpboot -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
port = 69
}
Where /var/tftpboot
is the server directory.
Modify the /etc/default/tftpd-hpa
file as follows:
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/var/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"
Create a server directory /var/tftpboot
:
sudo mkdir /var/tftpboot
Modify the directory permissions as follows:
chmod 777 /var/tftpboot
Turn off the Windows firewall, the firewall of WSL2 is shared with Windows, and there is no need to operate Linux.
Start service
sudo service xinetd start #也可使用`restart`
sudo service tftpd-hpa start
Use to netstat -a | grep tftp
check whether the service is turned on:
test
/var/tftpboot
Create a file in the server directory test
with the content hello
.
Use the command to tftp 127.0.0.1
enter the tftp operation interface, use get test
, and then use to q
exit, check whether there are files in the current directory and check whether the test
contents are the same. The same indicates that the setup is successful.