Linux学习--TFTP简单文件传输协议

Linux学习–TFTP简单文件传输协议

简单文件传输协议(Trivial File Transfer Protocol,TFTP)是一种基于UDP协议在客户端和服务器之间进行简单文件传输的协议,占用的端口号为69。

一、安装相关服务程序

tftp-server是服务程序,tftp是用于连接测试的客户端工具,xinetd是管理服务

[root@localhost ~]# dnf install tftp-server tftp xinetd
Updating Subscription Management repositories.
Unable to read consumer identity
This system is not registered to Red Hat Subscription Management. You can use subscription-manager to register.
Last metadata expiration check: 0:00:05 ago on Mon 11 Oct 2021 12:26:35 AM CST.
Dependencies resolved.
====================================================================================================
 Package                   Arch                 Version                       Repository       Size
====================================================================================================
Installing:
 tftp                      x86_64               5.2-24.el8                    b                42 k
 tftp-server               x86_64               5.2-24.el8                    b                50 k
 xinetd                    x86_64               2:2.3.15-23.el8               b               135 k

Transaction Summary
====================================================================================================
Install  3 Packages

Total size: 227 k
Installed size: 397 k
Is this ok [y/N]: y
Downloading Packages:
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                            1/1 
  Installing       : xinetd-2:2.3.15-23.el8.x86_64                                              1/3 
  Running scriptlet: xinetd-2:2.3.15-23.el8.x86_64                                              1/3 
  Installing       : tftp-server-5.2-24.el8.x86_64                                              2/3 
  Running scriptlet: tftp-server-5.2-24.el8.x86_64                                              2/3 
  Installing       : tftp-5.2-24.el8.x86_64                                                     3/3 
  Running scriptlet: tftp-5.2-24.el8.x86_64                                                     3/3 
  Verifying        : tftp-5.2-24.el8.x86_64                                                     1/3 
  Verifying        : tftp-server-5.2-24.el8.x86_64                                              2/3 
  Verifying        : xinetd-2:2.3.15-23.el8.x86_64                                              3/3 
Installed products updated.

Installed:
  tftp-5.2-24.el8.x86_64      tftp-server-5.2-24.el8.x86_64      xinetd-2:2.3.15-23.el8.x86_64     

Complete!

二、再xinetd服务种配置tftp

示例文件:/usr/shar/doc/xinetd/sample.conf,在/etc/xinetd.d/目录下创建相关的配置文件,配置参数后重启xinetd、tftp服务并将其添加到开机启动项

[root@localhost ~]# cd /usr/share/doc/xinetd/
[root@localhost xinetd]# ll
total 68
-rw-r--r--. 1 root root 43799 May 10  2012 CHANGELOG
-rw-r--r--. 1 root root  2087 Feb 20  2003 COPYRIGHT
-rw-r--r--. 1 root root  1284 Jan  3  2004 empty.conf
-rw-r--r--. 1 root root  5724 Mar 31  2005 README
-rw-r--r--. 1 root root  4964 Jun 24  2003 sample.conf
[root@localhost xinetd]# vim /etc/xinetd.d/tftp
 1 service tftp
  2 {
  3         socket_type     = dgram
  4         protocol        = udp
  5         wait            = yes
  6         user            = root
  7         server          = /user/sbin/in.tftpd
  8         server_args     = -s /var/lib/tftpboot
  9         disable         = no
 10         per_source      = 11
 11         cps             = 100 2
 12         flags           = IPv4
[root@localhost xinetd]# systemctl restart tftp
[root@localhost xinetd]# systemctl enable tftp
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.
[root@localhost xinetd]# systemctl restart xinetd
[root@localhost xinetd]# systemctl enable xinetd

三、开启防火墙策略

放开UDP协议69端口

[root@localhost xinetd]# firewall-cmd --zone=public --permanent --add-port=69/udp
success
[root@localhost xinetd]# firewall-cmd --reload
success

四、连接测试

FTP的根目录为/var/lib/tftpboot

[root@localhost xinetd]# echo "我要考RHCE" > /var/lib/tftpboot/readme.txt
[root@localhost xinetd]# tftp 192.168.31.10
tftp> get readme.txt
tftp> quit
[root@localhost xinetd]# ll
total 72
-rw-r--r--. 1 root root 43799 May 10  2012 CHANGELOG
-rw-r--r--. 1 root root  2087 Feb 20  2003 COPYRIGHT
-rw-r--r--. 1 root root  1284 Jan  3  2004 empty.conf
-rw-r--r--. 1 root root  5724 Mar 31  2005 README
-rw-r--r--. 1 root root    14 Oct 11 01:06 readme.txt
-rw-r--r--. 1 root root  4964 Jun 24  2003 sample.conf
[root@localhost xinetd]# cat readme.txt 
我要考RHCE
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值