TFTP是用来下载远程文件的最简单网络协议,它其于UDP协议而实现
1.首先安装TFTP客户端软件和TFTP服务器端软件
[shaocongshuai@localhost ~]$ sudo yum install -y tftp
[shaocongshuai@localhost ~]$ sudo yum install -y tftp-server
2.修改启动配置文件不管使用的是哪一种super-server,inetd或者xinetd,默认情况下TFTP服务是禁用的,所以要修改文件来开启服务。修改文件/etc/xinetd.d/tftp,主要是设置TFTP服务器的根目录,开启服务。修改后的配置文件如下:
1 # default: off
2 # description: The tftp server serves files using the trivial file transfer
3 # protocol. The tftp protocol is often used to boot diskless
4 # workstations, download configuration files to network-aware printers,
5 # and to start the installation process for some operating systems.
6 service tftp
7 {
8 socket_type = dgram
9 protocol = udp
10 wait = yes
11 user = root
12 server = /usr/sbin/in.tftpd
13 server_args = -s /home/shaocongshuai/tftp -c //这里-s指定tftp服务器的目录,-c为指定为可以创建文件
14 disable = no
15 per_source = 11
16 cps = 100 2
17 flags = IPv4
18 }
3.创建tftp根目录,关闭防火墙,启动tftp-server (防火墙、xinetd服务也可以在ntsysv 下设置)
# mkdir -m 777 /home/shaocongshuai/tftp/
#/etc/init.d/iptables stop //关闭防火墙
#service xinetd restart //重启 xinetd 服务重启xinetd服务,因为TFTP服务受控与xinetd, xinetd是管服务的服务,它是不开端口的。
验证一下TFTP是否起来了:
[shaocongshuai@localhost ~]$ sudo netstat -tunap | grep :69
出现下面的信息代表已经启动了
udp 0 0 0.0.0.0:69 0.0.0.0:* 1665/xinetd
4.selinux策略修改
如果系统开启SELinux的话,tftp客户端在下载的时候可能会被阻止。 如果是这样, 我们
可以使用下面命令将他临时关掉
[shaocongshuai@localhost ~]$ getenforce
Permissive
这里的/usr/sbin/setenforce 0设置SELinux为permissive模式;
# 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 - SELinux is fully disabled.
SELINUX=disabled
# SELINUXTYPE= type of policy in use. Possible values are:
# targeted - Only targeted network daemons are protected.
# strict - Full SELinux protection.
SELINUXTYPE=targeted
Disabled
[shaocongshuai@localhost ~]$ sestatus
SELinux status: disabled
4.tftp的使用
#tftp 192.168.1.93 登陆到tftp server
>get filename 从tftp server根目录获取文件
>put filename 上传文件到tftp server根目录>q 离开