tftp server config on Ubuntu

1. 配置Ubuntu tftp服务的步骤:

1、安装相关软件包:Ubuntu tftp(服务端),tftp(客户端),xinetd

sudo apt-get install tftpd tftp xinetd

2、建立配置文件
在/etc/xinetd.d/下建立一个配置文件tftp
sudo vi tftp
在文件中输入以下内容:

<span style="font-size:10px;">service tftp
{

socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /tftpboot
disable = no
per_source = 11
cps = 100 2
flags = IPv4

}</span>
保存退出

3、建立Ubuntu tftp服务文件目录(上传文件与下载文件的位置),并且更改其权限
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot -R

4、重新启动服务
sudo /etc/init.d/xinetd restart
至此Ubuntu tftp服务已经安装完成了,下面可以对其进行一下测试。(假设在当前目录下有一个测试文件test.txt)

<span style="font-size:10px;">$tftp 127.0.0.1                     
tftp> put test.txt
Sent 1018 bytes in 0.0 seconds
tftp> get test.txt
Received 1018 bytes in 0.1 seconds
tftp> quit</span>
通过get命令,可以把当前目录下的test.txt文件,通过Ubuntu tftp上传到它的服务文件目录,这时,在/tftpboot下面会出现test.txt文件。

通过put命令,可以从/tftpboot下,下载test.txt文件。

这样就验证了Ubuntu tftp服务配置的正确性。

当文件上传与下载结束后,可以通过quit命令退出。

严格按照以上步骤配置Ubuntu tftp服务,一般都可以成功。如果出现无法get或者put的时候,可以查看一下防火墙是否关闭。

2.

为了方便配置,最好用root帐户

安装tftp-hpa   tftpd-hpa  xinetd

sudo apt-get install tftp-hpa tftpd-hpa xinetd

在根目录下创建文件夹/tftpboot/root

修改目录权限chmod -R 777 /tftpboot/root

 修改tftp配置文件,如果没有就创建

#gedit /etc/xinetd.d/tftp

service tftp
         {
             disable         = no
             socket_type     = dgram
             protocol        = udp
             wait            = yes
             user            = root
             server          = /usr/sbin/in.tftpd
             server_args     = -s /tftpboot/root
             source          = 11
             cps             = 100 2
             flags =IPv4
         }

修改inetd.conf文件
# gedit /etc/inetd.conf

 tftp  dgram    udp    wait    nobody    /usr/sbin/tcpd
 /usr/sbin/in.tftpd   /tftpboot/root

其中/tftpboot/root为 tftp共享目录

修改tftpd-hpa文件
# vim /etc/default/tftpd-hpa

#RUN_DAEMON="no"
#OPTIONS="-s /tftpboot/root -c -p -U tftpd"

TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot/root"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s"


在/tftpboot/root下创建测试文件xxx

#cd /tftpboot/root

#touch xxx

#chmod 777 xxx

测试一下 tftp服务:

#cd /

#tftp 127.0.0.1

tftp>get xxx

tftp>q

#ls

查看当前目录,发现xxx文件已在当前目录

如果上述设置还不行的话,那么就要把selinux禁用掉:

#gedit /etc/selinux/config      //如果没有selinux/config这个文件,则创建。

# 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=enforcing
# SELINUXTYPE= type of policy in use. Possible values are:
#       targeted - Only targeted network daemons are protected.
#       strict - Full SELinux protection.
SELINUXTYPE=targeted

把上面的SELINUX=enforcing 改为:SELINUX=disable  禁用SeLinux
然后reboot重启PC

重启后再进行tftp测试。


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值