[关闭]
@tony-yin 2018-09-04T10:01:17.000000Z 字数 1243 阅读 1125

TFTP

NAS


Server

Install tftp & tftp-server

  1. yum y install tftp tftp-server

Install xinetd

  1. yum -y install xinetd

Create tftp-server directory

创建tftp server的根目录,该目录是服务端存放文件的目录,客户端下载和上传的文件都在该目录中。

  1. mkdir -p <path>
  2. chmod 777 <path>

Configure

vim /etc/xinetd.d/tftp:

  1. service tftp
  2. {
  3. socket_type = dgram
  4. protocol = udp
  5. wait = yes
  6. user = root
  7. server = /usr/sbin/in.tftpd
  8. server_args = -s /home/tftpboot -c
  9. disable = no
  10. per_source = 11
  11. cps = 100 2
  12. flags = IPv4
  13. }

Restart Service

  1. service xinetd restart

Localhost Test

连接本机的tftp server,尝试下载根目录下已存在的文件1.txt,下载失败

  1. [root@tony xinetd.d]# tftp localhost
  2. tftp> get 1.txt
  3. [root@tony xinetd.d]#

原因是tftp不识别localhost关键字,它只能识别IP,所以tftp后面换成本机IP即可

  1. [root@tony xinetd.d]# tftp 192.168.232.191
  2. tftp> get 1.txt
  3. tftp> put 2.txt
  4. tftp> get 3.txt
  5. Error code 1: File not found
  6. [root@tony ~]#

可以看到如果下载tftp server根目录中不存在的文件,则会报错:

  1. Error code 1: File not found

Client Test

选择单独的一台机器作客户端,进行测试。

Install tftp client

预置条件很简单,安装一个tftp客户端即可:

  1. yum install tftp

Test

客户端都出现了timeout的报错,原因是该客户端的IP和服务端IP不在一个网段

  1. [root@tony ~]# tftp 192.168.232.191
  2. tftp> get 1.txt
  3. [root@tony ~]# tftp 192.168.232.191
  4. tftp> put 4.txt
  5. client: timed out[root@tony ~]#

换一个同网段的客户端安装tftp client后测试,上传下载都正常:

  1. [root@h1 ~]# tftp 192.168.232.191
  2. tftp> get 1.txt
  3. tftp> put 1.sh
  4. tftp> q
  5. [root@tony ~]#

Refer

  1. TFTP服务器搭建与测试
  2. tftp-server服务器搭建
添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注