简介
TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。端口号为69。
yum 安装
先查看下yum源里是否有tftp软件包
[root@localhost test]# yum list |grep tftp
syslinux-tftpboot.noarch 4.05-15.el7 base
tftp.x86_64 5.2-22.el7 base
tftp-server.x86_64 5.2-22.el7
yum安装tftp安装tftp-server
[root@localhost test]# yum install tftp-server
安装成功后,在/etc/xinetd.d
下生成配置文件tftp。
[root@localhost xinetd.d]# ls /etc/xinetd.d
chargen-dgram daytime-dgram discard-dgram echo-dgram pure-ftpd tftp time-stream
chargen-stream daytime-stream discard-stream echo-stream tcpmux-server time-dgram
[root@localhost xinetd.d]# vi /etc/xinetd.d/tftp
把disable=yes修改成no
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
}
启动tftp服务
启动tftp服务,只需要重启xinetd服务
service xinetd restart
查看69端口是否运行
[root@localhost xinetd.d]# netstat -nlp |grep 69
udp 0 0 0.0.0.0:69 0.0.0.0:* 77308/xinetd
unix 2 [ ACC ] STREAM LISTENING 18691 746/NetworkManager /var/run/NetworkManager/private-dhcp
unix 2 [ ACC ] STREAM LISTENING 16974 740/gssproxy /run/gssproxy.sock
unix 2 [ ACC ] STREAM LISTENING 16973 740/gssproxy /var/lib/gssproxy/default.sock
防火墙设置(可选)
/sbin/iptables -I INPUT -p tcp --dport 69 -j ACCEPT
/sbin/iptables -I INPUT -p udp --dport 69 -j ACCEPT
/etc/rc.d/init.d/iptables save
service iptables restart
service iptables status
测试
[root@localhost test]# echo "1111" > /var/lib/tftpboot/name.txt
[root@localhost test]# tftp 192.168.8.174
tftp> help
tftp-hpa 5.2
Commands may be abbreviated. Commands are:
connect connect to remote tftp
mode set file transfer mode
put send file
get receive file
quit exit tftp
verbose toggle verbose mode
trace toggle packet tracing
literal toggle literal mode, ignore ':' in file name
status show current status
binary set mode to octet
ascii set mode to netascii
rexmt set per-packet transmission timeout
timeout set total retransmission timeout
? print help information
help print help information
tftp> get name.txt
tftp> q
[root@localhost test]# ls |grep name.txt
name.txt