TFTP简单文件传输协议

2026-02-27 19:06:54

1、[root@linuxprobe ~]# yum install tftp-server tftp 

Loaded plugins: langpacks, product-id, subscription-manager 

………………省略部分输出信息……………… 

Installing:  

tftp x86_64 5.2-11.el7 rhel 35 k 

tftp-server x86_64 5.2-11.el7 rhel 44 k 

Installing for dependencies: 

xinetd x86_64 2:2.3.15-12.el7 rhel 128 k 

Transaction Summary 

================================================================================

Install 2 Packages (+1 Dependent package) 

Total download size: 207 k 

Installed size: 373 k 

Is this ok [y/d/N]: y

Downloading packages: 

………………省略部分输出信息……………… 

Installed: 

tftp.x86_64 0:5.2-11.el7 tftp-server.x86_64 0:5.2-11.el7 

Dependency Installed: 

 xinetd.x86_64 2:2.3.15-12.el7 

 Complete!

2、在红帽RHEL7系统中TFTP服务是基于xinetd服务程序来管理的,xinetd服务可以用于管理需要的Linux系统服务,并且还提供有了强大的日志功能,简单来说,当咱们安装TFTP简单文件传输协议的软件包后,还需要在xinetd服务程序中开启一下,将默认的禁用(disable)参数修改为no:

[root@linuxprobe ~.d]# vim /etc/xinetd.d/tftp 

service tftp 

{        

                   socket_type                   = dgram        

                   protocol                        = udp

                   wait                               = yes

                   user                               = root         

                   server                            = /usr/sbin/in.tftpd        

                   server_args                   = -s /var/lib/tftpboot        

                   disable                          = no        

                   per_source                    = 11       

                   cps                                = 100 2       

                   flags                              = IPv4

3、然后同学们记得要重启xinetd服务并添加到开机启动项中,这样保证咱们的TFTP服务也能在服务器重启后依然开启,当然为了更加严谨一些,有些系统的防火墙默认没有允许UDP协议的69端口,因此再手动的将其端口号加入到允许策略中吧:

[root@linuxprobe ~]# systemctl restart xinetd 

[root@linuxprobe ~]# systemctl enable xinetd 

[root@linuxprobe ~]# firewall-cmd --permanent --add-port=69/udp 

success 

[root@linuxprobe ~]# firewall-cmd --reload 

 success

4、TFTP简单文件传输服务的根目录在/var/lib/tftpboot,因此咱们可以用刚刚安装好的tftp命令来尝试获取一下文件,亲身体验一下TFTP带来咱们的超简单文件传输过程,当然TFTP协议的玩法还不止于此,咱们还会在第19章中将TFTP服务与其他软件相搭配,组合出一套完整的自动化部署系统方案呢~

[root@linuxprobe ~]# echo "i love linux" > /var/lib/tftpboot/readme.txt[root@linuxprobe ~]# tftp 192.168.10.10 

tftp> get readme.txt 

tftp> quit 

[root@linuxprobe ~]# ls 

anaconda-ks.cfg Documents initial-setup-ks.cfg Pictures readme.txt Videos 

Desktop Downloads Music Public Templates 

[root@linuxprobe ~]# cat readme.txt 

 i love linux

猜你喜欢