tftp ------简要配置

来源:互联网 发布:软件安装手册模板 编辑:程序博客网 时间:2024/06/07 02:29

在向大家详细介绍tftp之前,首先让大家了解下Ubuntu tftp,然后全面介绍Ubuntu tftp,希望对大家有用。Ubuntu 团队对它的使用者公开的承诺:Ubuntu 永远免费 , 并且对于 "企业版本" 没有任何额外的费用, 在同样的自由团队上,将最好的工作成果带给每一个人。

配置Ubuntu tftp服务的步骤:

1、安装相关软件包:Ubuntu tftp(服务端),tftp(客户端),xinetd
sudo apt-get install tftpd tftp xinetd

2、建立配置文件
在/etc/xinetd.d/下建立一个配置文件tftp
sudo vi tftp
在文件中输入以下内容:
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}
保存退出

3、建立Ubuntu tftp服务文件目录(上传文件与下载文件的位置),并且更改其权限
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot -R

4、重新启动服务
sudo /etc/init.d/xinetd restart
至此Ubuntu tftp服务已经安装完成了,下面可以对其进行一下测试。(假设在当前目录下有一个测试文件test.txt)
$tftp 127.0.0.1                      
tftp> put test.txt
Sent 1018 bytes in 0.0 seconds
tftp> get test.txt
Received 1018 bytes in 0.1 seconds
tftp> quit

通过get命令,可以把当前目录下的test.txt文件,通过Ubuntu tftp上传到它的服务文件目录。这时,在/tftpboot下面会出现test.txt文件。通过put命令,可以从/tftpboot下,下载 test.txt文件。这样就验证了Ubuntu tftp服务配置的正确性。当文件上传与下载结束后,可以通过quit命令退出。严格按照以上步骤配置Ubuntu tftp服务,一般都可以成功。如果出现无法get或者put的时候,可以查看一下防火墙是否关闭。

 

如果从tftp服务器下载失败,

要确保服务器的根目录有可执行的权限。

$ chmod -R 777 tftp


使用中发现能正常下载文件,

$ tftp 192.168.1.222
tftp> get zImage
Received 1692890 bytes in 0.2 seconds

可是上传文件不成功,

提示错误:

tftp> put dic.txt
Error code 2: Access violation

求助于google, 得下面一段说明,问题解决。

The tftp man page says:

Because there is no user-login or validation within the TFTP
protocol, the remote site will probably have some sort of
file-access restrictions in place. The exact methods are
specific to each site and therefore dif ficult to document here.

So apparently the site you're trying to get the file from has some
kind of access restrictions in place. Take a look at the tftpd man
page on the remote host. The linux tftpd manual says, in part, "Due to
the lack of authentication information, tftpd will allow only publicly
readable files to be accessed. Files may be written only if they
already exist and are publicly writable."

上面主要意思就是: tftp服务器缺少必要的身份验证,

所以默认只允许下载文件,要上传文件,必须是服务器中已存在同名的文件,

且该文件权限允许被覆盖。


所以首先在服务中创建一个与要上传的文件同名的文件,并更改权限。

$ touch dic.txt

$ chmod 777 dic.txt

重新上传,成功。
tftp> put dic.txt
Sent 13770 bytes in 0.0 seconds

 

在网上看到有人配/etc/default/tftp,/etc/inetd.conf这些文件,实际上没这么复杂,用tftp和tftpd,加上xinetd监控,只需要配/etc/xinetd./tftp即可。

原创粉丝点击