Ubuntu 14.04建tftp服务器的安装、设置、调试

Ubuntu 14.04 搭建tftp服务器的安装、设置、调试

第一步:先说明一下ubuntu默认root是禁用的,所以先要创建root用户,这样以后不用再sudo了:
 
$ su root
 
输入密码获取获取管理员账户操作

相关阅读:

Ubuntu下tftp服务搭建 http://www.linuxidc.com/Linux/2012-08/67933.htm

TFTP服务器配置 http://www.linuxidc.com/Linux/2012-07/64785.htm

Ubuntu Linux配置TFTP下载服务器 http://www.linuxidc.com/Linux/2010-12/30394.htm

Ubuntu 11.10 配置tftp Server http://www.linuxidc.com/Linux/2012-05/60808.htm

tfpt安装方法http://blog.chinaunix.net/uid-10769062-id-4049229.html

第二步:安装服务
 
安装tftp-hpa  tftpd-hpa  xinetd
 
# apt-get install tftp-hpa tftpd-hpa xinetd

第三步:在创建文件夹/tftpboot  (这个是服务器的文件交换目录,将来客户机获取服务器文件时就是从这个文件夹中获取的),并且修改这个文件夹的权限为777
 
#mkdir /tftpboot
 
#chmod -R 777 /tftpboot

第四步:修改tftp配置文件,如果没有就创建,我喜欢用vim
 
#vim  /etc/xinetd.d/tftp

文件内容为:
 
service tftp
          {
              disable        = no
              socket_type    = dgram
              protocol        = udp
              wait            = yes
              user            = root
              server          = /usr/sbin/in.tftpd
              server_args    = -s /tftpboot                //此处文件目录就是上面说道的服务器文件交换目录
              source          = 11
              cps            = 100 2
              flags =IPv4
          }

第五步:修改inetd.conf文件或xinetd.conf文件
 
# vim /etc/inetd.conf

一般这个文件在打开的时候里面是有内容的,只要在最后添加下面内容即可:
 
tftp  dgram    udp    wait    nobody    /usr/sbin/tcpd
 /usr/sbin/in.tftpd  /tftpboot                          //此处文件目录就是上面说道的服务器文件交换目录 


对于比较新的版本的linux,没有inetd.conf文件,则修改/etc/xinetd.conf

defaults
  6 {
  7
  8 # Please note that you need a log_type line to be able to use log_on_success
  9 # and log_on_failure. The default is the following :
 10 # log_type = SYSLOG daemon info
 11
 12 }
 13
 14 #includedir /etc/xinetd.d
 15 tftp dgram udp wait nobody /usr/sbin/tcpd /usr/sbin/in.tftpd /tftpboot


第六步:修改tftpd-hpa文件
 # vim /etc/default/tftpd-hpa
 
内容为:
 
#RUN_DAEMON="no"
 #OPTIONS="-s /home/zyp/tftpboot -c -p -U tftpd"
 
TFTP_USERNAME="tftp"
 TFTP_DIRECTORY="/tftpboot"                    //此处文件目录就是上面说道的服务器文件交换目录
 TFTP_ADDRESS="0.0.0.0:69"
 TFTP_OPTIONS="-l -c -s"

第七步:重启服务
 
# service tftpd-hpa restart
 
# sudo /etc/init.d/xinetd reload
 
# sudo /etc/init.d/xinetd restart

第八步:本地测试
 

(1)在/tftpboot 下创建测试文件test,并修改test的文件权限
 
          #cd /tftpboot
 
          #touch test
 
          #chmod 777 test
 
(2)测试一下 tftp服务:
 
          #cd /
 
          #tftp 127.0.0.1
 
          tftp>get test
 
          tftp>q
 
          #ls
 
查看当前目录,发现test 文件已在当前目录,此时tftp搭建成功!

附:tftp与ftp的区别

TFTP是一个传输文件的简单协议,它其于UDP协议而实现,但是我们也不能确定有些TFTP协议是基于其它传输协议完成的。此协议设计的时候是进行小文件传输的。因此它不具备通常的FTP的许多功能,它只能从文件服务器上获得或写入文件,不能列出目录,不进行认证,它传输8位数据。传输中有三种模式:netascii,这是8位的ASCII码形式,另一种是octet,这是8位源数据类型;最后一种mail已经不再支持,它将返回的数据直接返回给用户而不是保存为文件。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章