tftp简介:
TFTP(Trivial File Transfer Protocol,简单文件传输协议)是TCP/IP协议族中的一个用来在客户机与服务器之间进行简单文件传输的协议,提供不复杂、开销不大的文件传输服务。端口号为69,TFTP是一个传输文件的简单协议,它基于UDP协议而实现,但是我们也不能确定有些TFTP协议是基于其它传输协议完成的。此协议设计的时候是进行小文件传输的。因此它不具备通常的FTP的许多功能,它只能从文件服务器上获得或写入文件,不能列出目录,不进行认证,它传输8位数据。
安装具体步骤:
一.安装tftp服务器
首先,我们使用rpm命令检查一下,在我们的Linux服务器上是否安装了tftp服务器软件包!
我之前有安装过,,,
如果没有安装,可以用yum来自动下载安装tftp命令:
二.配置并启动tftp服务
service tftp
{
disable = no #加入这一项
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftp -c #修改这一项,这里-s指tftp服务器 的根目录,-c指能创建文件
disable = yes
per_source = 11
cps = 100 2
flags = IPv4
}
三.开启xinetd服务
接下来用netstat查看69端口
四.SELinux策略修改
如果系统开启SELinux的话,tftp客户端在下载的时候可能会被阻止。如果是这样,我们可以使用下面命令将他临时关掉:
这里0表示设置SeLinux为permissive模式,1代表设置SELinux为enforcing模式
可以使用getenforce命令查看linux状态,这里我主要是将SELinux设为彻底禁用了。将SELINUX设为禁用方法如下:
[zoulei@localhost ~]$ sudo vim /etc/sysconfig/selinux
This file controls the state of SELinux on the system.
SELINUX= can take one of these three values:
enforcing - SELinux security policy is enforced.
permissive - SELinux prints warnings instead of enforcing.
disabled - No SELinux policy is loaded.
SELINUX=disabled #此处设置为disabled即可
SELINUXTYPE= can take one of these two values:
targeted - Targeted processes are protected,
mls - Multi Level Security protection.
SELINUXTYPE=targeted
五,防火墙策略修改
系统开启了防火墙也有可能会阻止tftp客户端的下载,我们可以在防火墙规则中使能tftp,只需要使能tftp所使用的69端口即可。
输入:
sudo /sbin/iptables -I INPUT -p tcp –dport 69 -j ACCEPT
sudo /sbin/iptables -I INPUT -p udp –dport 69 -j ACCEPT
sudo /sbin/iptables -I INPUT -p tcp –dport 80 -j ACCEPT
sudo /sbin/iptables -I INPUT -p tcp –dport 21 -j ACCEPT
sudo /sbin/iptables -I INPUT -p tcp –dport 22 -j ACCEPT
保存:
[zoulei@localhost ~]$ sudo /etc/rc.d/init.d/iptables save
iptables: Saving firewall rules to /etc/sysconfig/iptables:[ OK ]
如果要重启防火墙,输入以下命令:
[zoulei@localhost ~]$ sudo service iptables restart
iptables: Setting chains to policy ACCEPT: filter [ OK ]
iptables: Flushing firewall rules: [ OK ]
iptables: Unloading modules: [ OK ]
iptables: Applying firewall rules: [ OK ]
查看防火墙状态:
[zoulei@localhost ~]$ sudo service iptables status
Table: filter
Chain INPUT (policy ACCEPT)
num target prot opt source destination
1 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:22
2 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:21
3 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:80
4 ACCEPT udp – 0.0.0.0/0 0.0.0.0/0 udp dpt:69
5 ACCEPT tcp – 0.0.0.0/0 0.0.0.0/0 tcp dpt:69
Chain FORWARD (policy ACCEPT)
num target prot opt source destination
Chain OUTPUT (policy ACCEPT)
num target prot opt source destination
也可使用sudo service iptables stop关闭防火墙。
注意:如果我们希望系统在启动的时候就不要启动防火墙,那么我们应该使用ntsysv命令来关闭防火墙服务,同时我们还可以设置让系统启动的时候就开启tftp服务:
[zoulei@localhost ~]$ sudo ntsysv
[ ] ip6tables
[ ] iptables
[*] tftp
[*] xinetd
六.tftp命令下载测试
接着安装busybox里的tftp客户端命令:
上面两幅图片引用我室友的文档,,,
使用busybox里的tftp命令测试:
ps:图中红色箭头表示已经成功下载tt.txt文件
到这里tftp服务器就安装好了。。。