「linux」ubuntu配置TFTP服务器配置汇总

本文详细介绍了在Ubuntu系统中配置TFTP服务器的过程,包括安装TFTP服务器、配置/etc/inetd.conf、创建TFTP服务器文件目录、启动xinetd服务、检查端口开放状态、系统重启及本地测试等步骤。

  1、首先要打开root权限的终端。

  Ubuntu 的 10.XX以上,已经可以找到root的终端,如果没有,可以使用普通的终端使用sudo命令前缀。


  2、下载并安装tftp服务器。

  sudo apt-get install tftpd tftp openbsd-inetd


  3、重新启动系统。


  4、打开终端,编辑配置文件/etc/inetd.conf

  在这个配置文件里面找到下面的位置:

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

  #楼上这一行前面没有井号,是生效的,支持中文注释,如果系统支持,也可以用sudo gedit /etc/inetd.conf来更改这个配置文件。

  #上面每一个项之间有一个空格就好了,不过为了方便大家参考,我用了大量空格隔开,无论多少个空格都无所谓的。

  #红色的/tftp是存在于根目录的文件夹,存在于根目录有一个好处,对于更改权限非常方便,更改其一个就好,如果放在/home/里面

  #可能会存在由于Ubuntu的保护或之类的,导致文件夹权限修改不正确,导致无法正常下载。

  #最后,保存配置文件并退出。


  5、创建TFTP服务器的文件目录。

  sudu mkdir tftp

  sudu chmod 777 /tftp

  如果有需要下载的文件这时可以拷贝进去,也用chmod 777命令把所有权限打开。


  6、通过下面命令启动(或重启)xinetd服务

  sudo /etc/init.d/openbsd-inetd restart


  7、查看69端口是否有打开,使用下面命令

  netstat -an |more

  打印出的东西中找到如下即可:

  udp 0 0 0.0.0.0:69 0.0.0.0:*


  8、reboot一下系统。


  9、系统重启后再使用 sudo /etc/init.d/openbsd-inetd restart 命令 重置一下状态。


     10、本机测试:

      a. 在/tftproot 下新建文件1.txt  
      b. 在其他目录下测试:
       tftp 127.0.0.1
       tftp> get 1.txt
        Received 12 bytes in 0.0 seconds
        tftp> quit

==============================================================================

#########################################################################################


ubuntu12.04下tftp配置

安装tftp-hpa   tftpd-hpa  xinetd

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

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

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

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

#vim /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文件

# vim /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禁用掉:

#vim /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测试。



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值