Linux中TFTP使用详解

FTP协议简介
TFTP是用来下载远程文件的最简单网络协议,它其于UDP协议而实现。

linux服务器端tftp-server的配置
1、安装tftp服务器
需要安装xinetd(守护tftp)、tftp和tftp-server 3个软件
1)如果能上网,通过yum安装:
sudo yum install xinetd
sudo yum install tftp
sudo yum install tftp-server
2、配置tftp服务器
修改/etc/xinetd.d/tftp文件,将其中的disable=yes改为disable=no。开启TFTP服务
主要是设置TFTP服务器的根目录,开启服务。修改后的文件如下:
service tftp
{     socket_type            =dgram
       protocol                  =udp
       wait                        =yes
       user                        =root
       server                     =/usr/sbin/in.tftpd
       server_args             =-s /home/mike/tftpboot -c
       disable                    =no
       per_source             =11
       cps                         =100 2
       flags                       =IPv4
}
说明:修改项server_args= -s     <path>    -c,其中<path>处可以改为你的tftp-server的根目录

参数-s指定chroot,-c指定了可以创建文件
3、启动tftp服务器并关闭防火墙

RedHat7+

systemctl disable firewall;systemctl stop firewall

systemctl enable xinetd;systemctl start xinetd

Redhat7-
/etc/init.d/iptables stop        //关闭防火墙
sudo /sbin/service xinetd start
或service xinetd restart
/etc/init.d/xinetd start
看到启动[OK]就可以了
4、查看tftp服务是否开启
netstat -a | grep tftp
显示结果为
udp 0 0 *:tftp *:*
表明服务已经开启,就表明tftp配置成功了。
5、tftp使用
复制一个文件到tftp服务器目录,然后在主机启动tftp软件,进行简单测试。

登陆
tftp 192.168.1.2
tftp>get <download file>
tftp>put <upload file>
tftp>q
6、tftp命令用法如下
tftp     your-ip-address
【进入TFTP操作】
connect:连接到远程tftp服务器
mode:文件传输模式
put:上传文件
get:下载文件
quit:退出
verbose:显示详细的处理信息
tarce:显示包路径
status:显示当前状态信息
binary:二进制传输模式
ascii:ascii传送模式
rexmt:设置包传输的超时时间
timeout:设置重传的超时时间
help:帮助信息
?:帮助信息
7、如果出现“AVC Denial, click icon to view”的错误,并不能传输文件
修改/etc/sysconfig/selinux,将SELINUX设定为disable
使用命令setenforce 0让selinux配置文件生效

引用:

http://blog.sina.com.cn/s/blog_6e5e78bf0100qvmi.html

原文地址:https://www.cnblogs.com/xiaochina/p/5699232.html