【系统移植】TFTP服务器环境搭建

TFTP(Trivial File Transfer Protocol)即简单文件传输协议,是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务,端口号为69。 

Ubuntu和开发板之间用TFTP协议传输文件时,Ubuntu为TFTP服务器,开发板为客户端 。

1、检查是否安装TFTP服务器

$ dpkg -s tftpd-hpa

如果显示如下信息,则表示未安装:

dpkg-query: package 'tftpd-hpa' is not installed and no information is available
Use dpkg --info (= dpkg-deb --info) to examine archive files.

2、安装TFTP服务器,前提是确保Ubuntu能正常访问外网

$ sudo apt-get update
$ sudo apt-get upgrade
$ sudo apt-get install tftpd-hpa tftp-hpa

再执行步骤一的命令,如显示如下,则代表安装完成:

Package: tftpd-hpa
Status: install ok installed
Priority: optional
Section: net
Installed-Size: 113
Maintainer: Ubuntu Developers <ubuntu-devel-discuss@lists.ubuntu.com>
Architecture: amd64
Source: tftp-hpa
Version: 5.2+20150808-1.4build1
Replaces: atftpd, tftp-server, tftpd
Provides: tftp-server
Depends: libc6 (>= 2.38), libwrap0 (>= 7.6-4~), adduser, debconf (>= 0.5) | debconf-2.0
Suggests: pxelinux
Conflicts: atftpd, tftp-server, tftpd
Conffiles:
 /etc/init.d/tftpd-hpa 6be1795d3a8f511fce8ea16cb04a34a0
 /etc/init/tftpd-hpa.conf 3cbc30e20e9dfc201999978cddb03170
Description: HPA's tftp server
 Trivial File Transfer Protocol (TFTP) is a file transfer protocol, mainly to
 serve boot images over the network to other machines (PXE).
 .
 tftp-hpa is an enhanced version of the BSD TFTP client and server. It
 possesses a number of bugfixes and enhancements over the original.
 .
 This package contains the server.
Homepage: http://git.kernel.org/cgit/network/tftp/tftp-hpa.git
Original-Maintainer: Ron Lee <ron@debian.org>

 3、修改TFTP配置文件

执行以下代码,打开配置文件:

$ sudo vi /etc/default/tftpd-hpa

将内容更新为:

注:TFTP_DIRECTORY tftp 服务器的工作目录,即客户端要下载的文件需要放到该目录下.

4、创建服务器工作目录并设置为最高的权限 

$ sudo mkdir /tftpboot
$ sudo chmod 777 /tftpboot

5、重启 tftp 服务,使配置生效

$ sudo service tftpd-hpa restart
注:以后每次重新打开 ubuntu, 若要使用 tftp 都需要重启,如果不能使用tftp,很可能是没有重启。

6、本地测试是否配置成功 

首先cd到tftpboot目录,touch一个测试文件test.txt,再cd到家目录

$ cd /tftpboot/
$ sudo touch test.txt
$ cd 

使用tftp命令登录本机,并用get命令获取test.txt文件,最后输入q退出,最后执行ls命令,看是否能在当前目录下看到test.txt文件,如果能看到,则代表测试成功:

$ tftp localhost
tftp> get test.txt
tftp> q
$ ls
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

一起学嵌入式啊

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值