1.安装TFTP
简单文件传输协议(Trivial File Transfer Protocol,TFTP)是一种基于UDP协议在客户端和服务器之间进行简单文件传输的协议,端口号为69。
tftp-server 服务程序,tftp是用于连接测试的客户端工具,xinetd 是管理服务 ,xinetd服务可以用来管理多种轻量级的网络服务,而且具有强大的日志功能。
[root@dsrw vsftpd]# 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.
AppStream 2.6 MB/s | 3.2 kB 00:00
-BaseOS 2.7 MB/s | 2.7 kB 00:00
依赖关系解决。
================================================================================
软件包 架构 版本 仓库 大小
================================================================================
Installing:
tftp x86_64 5.2-24.el8 AppStream 42 k
tftp-server x86_64 5.2-24.el8 AppStream 50 k
xinetd x86_64 2:2.3.15-23.el8 AppStream 135 k
事务概要
================================================================================
安装 3 软件包
总计:227 k
安装大小:397 k
确定吗?[y/N]: y
下载软件包:
运行事务检查
事务检查成功。
运行事务测试
事务测试成功。
运行事务
准备中 : 1/1
Installing : xinetd-2:2.3.15-23.el8.x86_64 1/3
运行脚本 : xinetd-2:2.3.15-23.el8.x86_64 1/3
Installing : tftp-server-5.2-24.el8.x86_64 2/3
运行脚本 : tftp-server-5.2-24.el8.x86_64 2/3
Installing : tftp-5.2-24.el8.x86_64 3/3
运行脚本 : tftp-5.2-24.el8.x86_64 3/3
验证 : tftp-5.2-24.el8.x86_64 1/3
验证 : tftp-server-5.2-24.el8.x86_64 2/3
验证 : xinetd-2:2.3.15-23.el8.x86_64 3/3
Installed products updated.
已安装:
tftp-5.2-24.el8.x86_64 tftp-server-5.2-24.el8.x86_64
xinetd-2:2.3.15-23.el8.x86_64
完毕!
2.创建在xinetd服务程序中对应的tftp配置文件
(对应的配置文件默认不存在,参见示例文件/usr/share/doc/xinetd/sample.conf)。-c:上传文件
[root@dsrw vsftpd]# 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 -c
disable =no
per_source =11
cps =100 2
flags =IPv4
}
3.重启xinetd服务并将它添加到系统的开机启动项中,该端口号加入到防火墙的允许策略中
[root@dsrw vsftpd]# systemctl restart tftp
[root@dsrw vsftpd]# systemctl enable tftp
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.
[root@dsrw vsftpd]# systemctl restart xinetd
[root@dsrw vsftpd]# systemctl enable xinetd
[root@dsrw vsftpd]# firewall-cmd --zone=public --permanent --add-port=69/udp
success
[root@dsrw vsftpd]# firewall-cmd --reload
Success
4.测试tftp服务下载功能
TFTP的根目录为/var/lib/tftpboot,tftp命令中可用的参数以及作用如下:
?:帮助信息
put:上传文件
get:下载文件
verbose:显示详细的处理信息
status:显示当前的状态信息
binary:使用二进制进行传输
ascii:使用ASCII 码进行传输
timeout:设置重传的超时时间
quit:退出
[root@dsrw vsftpd]# echo "Welcome to dsrw.com" > /var/lib/tftpboot/dsrw.txt
[root@dsrw ~]# tftp 192.168.10.2
tftp> get dsrw.txt
tftp> quit
[root@dsrw ~]# ls
公共 视频 文档 音乐 anaconda-ks.cfg initial-setup-ks.cfg
模板 图片 下载 桌面 dsrw.txt
5.测试tftp服务上传功能
在服务器上设置目录权限
[root@dsrw ~]# chmod 777 /var/lib/tftpboot -R
客户机测试
[root@dsrw ~]# echo "Welcome to dsrw.cn" > dsrwcn.txt
[root@dsrw ~]# tftp 192.168.10.2
tftp> dsrwcn.txt
在服务器上查看
[root@dsrw ~]# ls /var/lib/tftpboot
dsrwcn.txt
[root@dsrw ~]# cat /var/lib/tftpboot/dsrwcn.txt
Welcome to dsrw.cn
6.可以在服务器上关闭防火墙测试
[root@dsrw ~]# systemctl stop firewalld
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END
请登录后查看评论内容