TFTP(Trivial File Transfer Protocol)是TCP/IP协议族中的一个用来在服务器和客户机之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。端口号为69。
tftp命令操作如下
Usage: tftp [-4][-6][-v][-l][-m mode] [host [port]] [-c command]
下面介绍详细的服务器搭建过程。
1,安装
查看是否安装tftp软件包
[lingyun@localhost ~]$rpm -qa | grep tftp
tftp-0.49-7.el6.x86_64
tftp-server-0.49-7.el6.x86_64
如果你没有安装,就自己用yum安装一下
[lingyun@localhost ~]$sudo yum -y install tftp
2,配置tftp服务器
[lingyun@localhost ~]$sudo vim /etc/xinetd.d/tftp
下面的是我的配置,
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftp -c
disable = no
per_source = 11
cps = 100 2
flags = IPv4
}
注意:
(1)在disable一栏,一定要修改为no,否则你的tftp服务器用不了
(2)server args一栏,-s /tftp是指定tftp的根目录,-c表示能够创建文件
关闭selinux
[lingyun@localhost ~]$sudo vim /etc/sysconfig/selinux
SELINUX=disabled
SELINUXTYPE=targeted
3启动tftp服务器
[lingyun@localhost ~]$sudo service xinetd restart
Stopping xinetd: [ OK ]
Starting xinetd: [ OK ]
查看端口是否正常
[lingyun@localhost ~]$sudo netstat -nlp | grep 69
udp 0 0 0.0.0.0:69 0.0.0.0:* 14008/xinetd
unix 2 [ ACC ] STREAM LISTENING 11147 1690/gnome-session @/tmp/.ICE-unix/1690
unix 2 [ ACC ] STREAM LISTENING 11148 1690/gnome-session /tmp/.ICE-unix/1690
unix 2 [ ACC ] STREAM LISTENING 11204 1697/gconfd-2 /tmp/orbit-gdm/linc-6a1-0-77f033b75534
4,测试是否能够使用
测试下载
[lingyun@localhost ~]$ ls /tftp/
mytext
[lingyun@localhost ~]$ ls
fl2440 u-boot-2010.09.bak vim_conf.zip
[lingyun@localhost ~]$ tftp 192.168.1.79
tftp> get mytext
tftp> q
[1]+ Stopped tftp 192.168.1.79
[lingyun@localhost ~]$ ls
fl2440 mytext u-boot-2010.09.bak vim_conf.zip
测试上传
[lingyun@localhost ~]$ ls /tftp/
mytext
[lingyun@localhost ~]$ ls
fl2440 mytext u-boot-2010.09.bak vim_conf.zip
[lingyun@localhost ~]$ tftp 192.168.1.79
tftp> put vim_conf.zip
tftp> q
[4]+ Stopped tftp 192.168.1.79
[lingyun@localhost ~]$ ls /tftp/
mytext vim_conf.zip