zoukankan      html  css  js  c++  java
  • 35.简单文件传输协议

    1.简单文件传输协议(Trivial File Transfer Protocol,TFTP)是一种基于UDP 协议在客户端和服务器之间进行简单文件传输的协议。顾名思义,它提供不复杂、开销不大的文件传输服务(可将其当作FTP 协议的简化版本)。

      TFTP 的命令功能不如FTP 服务强大,甚至不能遍历目录,在安全性方面也弱于FTP服务。而且,由于TFTP 在传输文件时采用的是UDP 协议,占用的端口号为69,因此文件的传输过程也不像FTP 协议那样可靠。

      但是,因为TFTP 不需要客户端的权限认证,也就减少了无谓的系统和网络带宽消耗,因此在传输琐碎(trivial)不大的文件时,效率更高。

      安装:  

    [root@localhost ~]# yum install tftp-server.x86_64 tftp
    Loaded plugins: fastestmirror, langpacks
    base                                                                             | 3.6 kB  00:00:00     
    extras                                                                           | 2.9 kB  00:00:00     
    updates                                                                          | 2.9 kB  00:00:00  
    ... ...
    Running transaction
      Installing : tftp-5.2-22.el7.x86_64                                                               1/2 
      Installing : tftp-server-5.2-22.el7.x86_64                                                        2/2 
      Verifying  : tftp-server-5.2-22.el7.x86_64                                                        1/2 
      Verifying  : tftp-5.2-22.el7.x86_64                                                               2/2 
    
    Installed:
      tftp.x86_64 0:5.2-22.el7                        tftp-server.x86_64 0:5.2-22.el7                       
    
    Complete!

      查看:  

    [root@localhost ~]# systemctl status tftp
    ● tftp.service - Tftp Server
       Loaded: loaded (/usr/lib/systemd/system/tftp.service; indirect; vendor preset: disabled)
       Active: inactive (dead)
         Docs: man:in.tftpd

      在 centos 7 系统中,TFTP 服务是使用xinetd 服务程序来管理的。xinetd 服务可以用来管理多种轻量级的网络服务,而且具有强大的日志功能。简单来说,在安装TFTP 软件包后,还需要在xinetd 服务程序中将其开启,把默认的禁用(disable)参数修改为no:

      但是:  

    [root@localhost ~]# systemctl restart xinetd
    Failed to restart xinetd.service: Unit not found.

      安装xinetd:   

    [root@localhost ~]# yum install xinetd
    Loaded plugins: fastestmirror, langpacks
    Loading mirror speeds from cached hostfile
     * base: mirror.bit.edu.cn
     * extras: mirrors.huaweicloud.com
     * updates: mirror.bit.edu.cn
    Running transaction
      Installing : 2:xinetd-2.3.15-14.el7.x86_64                                                        1/1 
      Verifying  : 2:xinetd-2.3.15-14.el7.x86_64                                                        1/1 
    
    Installed:
      xinetd.x86_64 2:2.3.15-14.el7                                                                         
    
    Complete!  
    [root@localhost ~]# systemctl status xinetd
    ● xinetd.service - Xinetd A Powerful Replacement For Inetd
       Loaded: loaded (/usr/lib/systemd/system/xinetd.service; enabled; vendor preset: enabled)
       Active: active (running) since Thu 2020-09-03 17:11:12 CST; 16s ago
      Process: 79410 ExecStart=/usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid $EXTRAOPTIONS (code=exited, status=0/SUCCESS)
     Main PID: 79411 (xinetd)
       CGroup: /system.slice/xinetd.service
               └─79411 /usr/sbin/xinetd -stayalive -pidfile /var/run/xinetd.pid  

      TFTP 的根目录为/var/lib/tftpboot。我们可以使用刚安装好的tftp 命令尝试访问其中的文件,亲身体验TFTP 服务的文件传输过程。在使用tftp 命令访问文件时,可能会用到表中的参数。  

    ?          帮助信息
    put        上传文件
    get        下载文件
    verbose    显示详细的处理信息
    status     显示当前的状态信息
    binary     使用二进制进行传输
    ascii      使用ASCII 码进行传输
    timeout    设置重传的超时时间
    quit       退出

      测试:  

    [root@localhost ~]# echo "hello" > /var/lib/tftpboot/hi.txt
    [root@localhost ~]# 
    [root@localhost ~]# tftp 10.10.64.109
    tftp> get hi.txt
    tftp> quit
    [root@localhost ~]# ll
    total 12
    -rw-------. 1 root root 1691 Sep  1 11:33 anaconda-ks.cfg
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Desktop
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Documents
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Downloads
    drwxr-xr-x. 2 root root    6 Sep  3 13:39 files
    -rw-r--r--. 1 root root    6 Sep  3 17:13 hi.txt
    -rw-r--r--. 1 root root 1739 Sep  1 11:42 initial-setup-ks.cfg
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Music
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Pictures
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Public
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Templates
    drwxr-xr-x. 2 root root   25 Sep  1 19:02 test
    drwxr-xr-x. 2 root root    6 Sep  1 11:42 Videos
    [root@localhost ~]# cat hi.txt 
    hello
  • 相关阅读:
    ubuntu docker 安装
    后缀数组小结
    后缀数组小结
    后缀数组小结
    win7下如何建立ftp服务器
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
    xgqfrms™, xgqfrms® : xgqfrms's offical website of GitHub!
  • 原文地址:https://www.cnblogs.com/xinghen1216/p/13731540.html
Copyright © 2011-2022 走看看