linux-TFTP服务

1、TFTP协议简介
TFTP,全称是 Trivial File Transfer Protocol(简单文件传输协议),基于 UDP 实现,该协议简单到只能从远程服务器读取数据或向远程服务器上传数据。

2、TFTP实战
  1>环境准备:centos7

192.168.100.101     tftp-server
192.168.100.20      tftp-client

server端和client端分别关闭防火墙,禁用selinux # systemctl disable firewall;systemctl stop firewall 修改
/etc/sysconfig/selinux,将SELINUX设定为disable,使用命令setenforce 0让selinux配置文件生效

  2>linux服务端 tftp-server 配置
  安装tftp服务器,需要安装xinetd(守护tftp)、tftp和tftp-server 3个软件

[root@tftp-server ~]# yum install xinetd tftp tftp-server -y
[root@tftp-server ~]# rpm -ql tftp-server
/etc/xinetd.d/tftp
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd
/usr/share/doc/tftp-server-5.2
/usr/share/doc/tftp-server-5.2/CHANGES
/usr/share/doc/tftp-server-5.2/README
/usr/share/doc/tftp-server-5.2/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot

#/var/lib/tftpboot为存放数据的文件,也就是说从服务器端下载文件必须放于此目录下

  修改/etc/xinetd.d/tftp文件,将其中的disable=yes改为disable=no。开启TFTP服务,启动服务。

 

  3>启动tftp服务器,并查看是否开启

[root@tftp-server ~]# systemctl enable xinetd;systemctl start xinetd
[root@tftp-server ~]# netstat -a | grep tftp
udp        0      0 0.0.0.0:tftp            0.0.0.0:*

  4>在tftp服务器目录,创建测试文件

[root@tftp-server ~]# echo hello > /var/lib/tftpboot/test

  5>客户端安装tftp包,使用tftp工具从远程服务器下载文件

[root@tftp-client ~]# yum install tftp -y
[root@tftp-client ~]# tftp 192.168.100.101
tftp> get test
tftp> q
[root@tftp-client ~]# ls
anaconda-ks.cfg test
[root@tftp-client ~]# cat test
hello

  6>tftp命令用法如下

tftp your-ip-address

进入TFTP操作:
connect:连接到远程tftp服务器
mode:文件传输模式
put:上传文件
get:下载文件
quit:退出
verbose:显示详细的处理信息
tarce:显示包路径
status:显示当前状态信息
binary:二进制传输模式
ascii:ascii传送模式
rexmt:设置包传输的超时时间
timeout:设置重传的超时时间
help:帮助信息
?:帮助信息

 

posted @ 2020-03-13 19:55  我听过  阅读(633)  评论(0编辑  收藏  举报