TFTPTFTP(Trivial File Transfer Protocol,简单文件传输协议),是一个基于UDP协议实现的用于在客户机和服务器之间进行简单文件传输的协议,适合于开销不大、不复杂的应用场合。TFTP协议专门为小文件传输而设计,只能从服务器上获取文件,或者向服务器写入文件,不能列出目录,也不能进行认证
使用Ubuntu 12.04.2用于TFTP服务器搭建
安装xinetd
madmanazo@ubuntu:~$ sudo apt-get install xinetd
安装tftp和tftpd
madmanazo@ubuntu:~$ sudo apt-get install tftp tftpd
建立TFTP的配置文件
madmanazo@ubuntu:~$ sudo vi /etc/xinetd.d/tftp
[sudo] password for madmanazo:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd //服务程序路径
server_args = -s /var/tftpboot/ //可以访问的tftpd服务器下的目录
disable = no //是否开机启动
per_source = 11
cps = 100 2
flags = IPv4
}
~
~
~
~
~
"/etc/xinetd.d/tftp" [New] 13L, 429C written
新建tftp服务器目录
madmanazo@ubuntu:~$ sudo mkdir /var/tftpboot
设置访问权限
madmanazo@ubuntu:~$ sudo chmod 777 /var/tftpboot
重启xinetd服务
madmanazo@ubuntu:~$ sudo /etc/init.d/xinetd restart
Rather than invoking init scripts through /etc/init.d, use the service(8)
utility, e.g. service xinetd restart
Since the script you are attempting to invoke has been converted to an
Upstart job, you may also use the stop(8) and then start(8) utilities,
e.g. stop xinetd ; start xinetd. The restart(8) utility is also available.
xinetd stop/waiting
xinetd start/running, process 7241
服务器测试
本机测试:在/var/tftpboot下面建立一个文件test,在里面输入hello world,然后保存文件
madmanazo@ubuntu:~$ sudo chmod 777 /var/tftpboot
madmanazo@ubuntu:/var/tftpboot$ vim test
hello world
~
~
~
"test" [New] 1L, 12C written
madmanazo@ubuntu:/var/tftpboot$ cat test
hello world
启动另一个终端,进行如下测试结果表示成功
madmanazo@ubuntu:~$ tftp 127.0.0.1
tftp> get test
Received 13 bytes in 0.0 seconds
tftp> q
madmanazo@ubuntu:~$ ls
Desktop Downloads iTop-4412 Music Public test
Documents examples.desktop minilinux Pictures Templates Videos
madmanazo@ubuntu:~$ cat test
hello world