(work and tools)ubuntu安装tftp

来源:互联网 发布:模块度 复杂网络 编辑:程序博客网 时间:2024/05/24 01:38
ubuntu安装tftp server
 
1、安装相关软件包
apt-get install tftpd (服务端)
apt-get install tftp (客户端)
apt-get install xinetd
2、建立配置文件
cd /etc/xinetd.d/
vi tftp                            (/etc/xinetd.d/tftp 配置文件)
输入
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
}
存盘退出。
3、建立tftp服务文件目录
cd /
          sudo mkdir tftpboot      建立文件夹
          sudo chmod 777 tftpboot  更改文件夹权限
 
           cd /tftpboot
           sudo touch  aaa
           sudo chmod  777  aaa
 
4、从新启动服务
/etc/init.d/xinetd restart
安装完成!测试方法:
在/tftpboot 目录下随便放个文件abc,然后运行tftp 192.168.123.202 进入tftp命令行,输入get abc看看是不是能把文件下下来,如果可以就可以了,也可以put文件上去。
 
到此为止 应该可以了。
********************************************************************************************
 
Ubuntu中有三个tftp服务器:atftpd,tftpd,hpa;
安装hpa过程:
自建tftp目录:sudo mkdir /home/tftp
修改目录属性:sudo chmod 777 /home/tftp
tftpd-hpa 是一个功能增强的TFTP服务器。它提供了很多TFTP的增强功能,它已经被移植到大多数的现代UNIX系统。  
安装
使用下面的命令来安置 tftpd-hpa 服务器:
 $ sudo apt-get install tftpd-hpa
注:若server未安装xinetd则在Ubuntu9.04中会自动下载openbsd-inetd并安装,使用tftp过程中出错很多时候是因xinetd版本问题;
配置
tftp-hpa 的配置文件为 /etc/default/tftpd-hpa
 RUN_DAEMON="no"
 OPTIONS="-l -c -s /tftpboot"  
-c为可创建新文件,若无此参数,put命令则可能出现错误提示,此时只能复盖原有文件不能创建新文件;
无论何种方式配置tftp-server -c参数决定是否能正常写入数据;这里指定 tftpd 使用的目录为 /tftpboot,注意要修改目录属性:chmod 777 tftpboot
启动和停止
启动
 # /etc/init.d/tftpd-hpa start
停止
 # /etc/init.d/tftpd-hpa stop
(若无xinetd下载tftpd-hpa包过程中会自动下载openbsd-inetd并安装,其它资料中使用xinetd出现错误主要是xinetd版本的问题)
正常安装完成后编辑/etc/default/tftpd-hpa文件:
#Defaults for tftpd-hpa
RUN_DAEMON="yes"  #默认为"no",tftp不能启动;
OPTIONS="-l -c -s /home/tftp"
#/home/tftp为你设定目录,-c可创建新文件,在很多资料中执行的命令或配置tftp文件中都缺少-c这个参数,如:sudo in.tftpd -l -c -s /home/tftp,put命令会出错提示;
启动:sudo /etc/init.d/tftpd-hpa start
校验:ps -A|grep tftp
修改/home/tftp目录权限则可正常操作了;
删除服务:sudo apt-get remove tftpd-hpa tftp-hpa --purge
选项参考
OPTIONS
-l Run the server in standalone (listen) mode, rather than run from
inetd. In listen mode, the -t option is ignored, and the -a
option can be used to specify a specific local address or port
to listen to.
-a [address][:port]
Specify a specific address and port to listen to when called
with the -l option. The default is to listen to the tftp port
specified in /etc/services on all local addresses.
listen 的 ip address 和 Port
-c Allow new files to be created. By default, tftpd will only
allow upload of files that already exist. Files are created
with default permissions allowing anyone to read or write them,
unless the -p or -U options are specified.
-s (决定tftp根目录)Change root directory on startup. This means the remote host
does not need to pass along the directory as part of the trans-
fer, and may add security. When -s is specified, exactly one
directory should be specified on the command line. The use of
this option is recommended for security as well as compatibility
with some boot ROMs which cannot be easily made to include a
directory name in its request.
*****************************************************************************************
 
 
这段时间在弄三星的2440的移植,用到了tftp,我用的是ubuntu9.04,在网上看到了很多文章,但是发现很多文章讲的都很模糊,或者根本就是错的,只好自己琢磨,走了很多弯路,费牛劲终于弄出来了,为了避免同行和我一样走弯路,特把我的一些总结贴出来和大家共享,有什么不对的地方希望大家指正,大家有什么问题也可以一起探讨一下。


ubuntu 9.04下tftp 设置方法:


      1:sudo apt-get install tftp tftpd openbsd-inetd
            特别指出很多文章里用的是netkit-inetd,但是实际下载时发现
            这个软件是下不到的,特改用openbsd-inetd,实验效果不错。


      2:在根目录下创建文件夹 tftpboot
          cd /
          sudo mkdir tftpboot      建立文件夹
          sudo chmod 777 tftpboot  更改文件夹权限


      3: sudo gedit /etc/inetd.conf  修改成如下样子

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



      4: sudo gedit /etc/xinetd.d/tftp  修改成如下样子(如果没有tftp文件就创建它)

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



       5: sudo gedit /etc/default/tftpd-hpa  修改成如下样子

            RUN_DAEMON="no"

            OPTIONS="-s /tftpboot -c -p -U tftpd"


       6:sudo /etc/init.d/openbsd-inetd reload   
         sudo /etc/init.d/xinetd restart
         sudo in.tftpd -l /tftpboot

       7: 在tftpboot文件夹下新建测试文件 aaa

           cd /tftpboot
           sudo touch  aaa
           sudo chmod  777  aaa


       9: 开始测试tftp服务
           cd  /home
           tftp  192.168.1.111
           get  /tftpboot/aaa
           如果没有出现错误代码且在home目录下出现aaa文件则证明tftp
           服务建立成功


注意: 1:如果出现permission denied 错误  则是操作者权限不够,
                需要提升权限
                su  root
                输入密码后就可以正常进行tftp传输操作了

           2:如果出现Access violation错误则是文件权限没有解开,
                将要操作的文件操作权限全解开就可以了
                chmod 777 文件名()
0 0
原创粉丝点击