简单文本传输协议(TFTP)

TFTP是一种基于UDP协议的简单文本传输协议。
特点:

  1. 命令功能不如FTP服务强大,安全性弱于FTP
  2. 采用UDP协议,占用69端口号
  3. 文件传输过程不如FTP协议可靠
  4. 不需要客户端权限认证
  5. 减少无谓的系统和网络贷款消耗,效率更高

TFTP服务部署

安装tftp软件包

[root@MyCentOS ~]# yum install tftp
Repository extras is listed more than once in the configuration
Repository PowerTools is listed more than once in the configuration
Repository centosplus is listed more than once in the configuration
上次元数据过期检查:14:15:23 前,执行于 20200812日 星期三 190742秒。
依赖关系解决。
========================================================================================================================================================================================
 软件包                                   架构                                       版本                                           仓库                                           大小
========================================================================================================================================================================================
安装:
 tftp                                     x86_64                                     5.2-24.el8                                     AppStream                                      42 k

事务概要
========================================================================================================================================================================================
安装  1 软件包

总下载:42 k
安装大小:51 k
确定吗?[y/N]: y
下载软件包:
tftp-5.2-24.el8.x86_64.rpm                                                                                                                               61 kB/s |  42 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
总计                                                                                                                                                     60 kB/s |  42 kB     00:00     
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
  准备中  :                                                                                                                                                                         1/1 
  安装    : tftp-5.2-24.el8.x86_64                                                                                                                                                  1/1 
  运行脚本: tftp-5.2-24.el8.x86_64                                                                                                                                                  1/1 
  验证    : tftp-5.2-24.el8.x86_64                                                                                                                                                  1/1 
Installed products updated.

已安装:
  tftp-5.2-24.el8.x86_64                                                                                                                                                                

完毕!

关键:还需要安装tftp-server软件包
后面操作的时候才发现还有服务器软件包没有安装

TFTP服务配置

TFTP服务是使用xinetd服务程序来管理的,xinetd服务可以用来管理多种轻量级网络服务,而且具有强大的日志功能。

配置tftp服务

tftp服务通过xinetd程序来管理,在/etc/xinetd.d/路径下配置tftp服务。

[root@MyCentOS ~]# cd /etc/xinetd.d/
[root@MyCentOS xinetd.d]# vim tftp
service tftp
{
        socket_type = dgram
        protocol    = udp
        wait        = yes
        user        = root
        server      = /usr/sbin/in.tftpd
        server_args = -s /var/lib/tftpboot  <<<<<<<<<设置tftp服务的根目录
        disable     = no    <<<<<<<<<开启tftp服务
        per_source  = 11
        cps         = 100 2
        flags       = IPv4
}

如果运行xinetd服务程序提示没有该程序,则应当先安装该程序。

重启xinetd并加入开机自启

略,见前几篇博客

设置防火墙关于tftp规则

[root@MyCentOS ~]# firewall-cmd --permanent  --zone=internal --add-port=69/udp
success
[root@MyCentOS ~]# firewall-cmd --permanent --zone=internal --add-service=tftp
success
[root@MyCentOS ~]# firewall-cmd --reload
success
[root@MyCentOS ~]# firewall-cmd --list-all
internal (active)
  target: default
  icmp-block-inversion: no
  interfaces: ens33
  sources: 
  services: cockpit dhcpv6-client ftp mdns samba-client ssh tftp
  ports: 69/udp
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: 

tftp服务的根目录在/var/lib/tftpboot路径下。

坑一、设置SELinux关于tftp的规则

在部署好以上设置后,连接tftp服务器发现还是没能成功,信息提示传输请求被拒绝。经过排查,才发现是因为SELinux关于tftp的规则还没设置。

[root@MyCentOS ~]# getsebool -a | grep tftp
tftp_anon_write --> off
tftp_home_dir --> off
[root@MyCentOS ~]# setsebool -P tftp_home_dir=on
[root@MyCentOS ~]# getsebool -a | grep tftp
tftp_anon_write --> off
tftp_home_dir --> on
[root@MyCentOS ~]# tftp 192.168.10.10
tftp> get tftptest.txt
tftp> quit
[root@MyCentOS ~]# cat tftptest.txt
this is tftp testll!

以上即为tftp部署的初步总结!

Logo

更多推荐