tftp configuration under Ubuntu

the first method

1. Install TFTP software

sudo apt-get install tftp-hpa tftpd-hpa

tftp-hpa is the client, tftpd-hpa is the server

2. Create a tftpboot directory as the server directory

sudo mkdir ~/tftpboot

Release permissions: (server directory, you need to set permissions to 777, chomd 777)

sudo chmod 777 ~/tftpboot

3. Configure TFTP server

sudo gedit /etc/default/tftpd-hpa

Change the original content to:

# /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
#TFTP_DIRECTORY="/var/lib/tftpboot"  #修改为自己需要的路径,与上面创建的目录一致
TFTP_ADDRESS="0.0.0.0:69"
#TFTP_OPTIONS="--secure"  #可以通过查看mantftpd,看各种参数的意义

change into

TFTP_DIRECTORY="/home/shenhao/tftpboot"
TFTP_OPTIONS="-l -c -s"

3. Restart the TFTP service

sudo service tftpd-hpa restart

4. Under test

$ cd ~/tftpboot echo "hello tftp service">>a.txt
$ echo "hello tftp service,put to tftp serive">>b.txt
$ tftp localhost
tftp> get a.txt
tftp> put b.txt
tftp> quit 

Where get is to get the file, put is to upload the file to the TFTP server.

The second method

Steps to configure tftp service:
1. Install related software packages
tftpd (server), tftp (client), xinetd

sudo apt-get install tftpd tftp xinetd

2. Create a configuration file
(the blue directory can be changed to other addresses, such as /home/user/tftpboot)
Create a configuration file under /etc/xinetd.d/ tftp
sudo vi tftp
Enter the following in the file:

service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}

save and exit

3. Create a tftp service file directory (the location of uploading and downloading files), and change its permissions

sudo mkdir /tftpboot
sudu chmod 777 /tftpboot

4. Restart the service

sudo /etc/init.d/xinetd restart

At this point, the tftp service has been installed, and you can test it below. (Assume there is a test file test.txt in the current directory)

$tftp 192.168.16.2 (本机的ip地址)
tftp> get test.txt
tftp> quit
$

Through the get command, you can upload the test.txt file in the current directory to its service file directory through tftp. At this time, the test.txt file will appear under /tftpboot. Through the put command, you can download the test.txt file from /tftpboot. This verifies the correctness of the tftp service configuration. When the file uploading and downloading are finished, you can exit with the quit command.

Strictly follow the above steps to configure the tftp service, generally it can be successful. If you cannot get or put, you can check whether the firewall is turned off.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325445230&siteId=291194637