ubuntu中配置tftp服务

来源:百度文库 编辑:神马文学网 时间:2024/04/30 10:32:17

ubuntu中配置tftp服务

sudo apt-get install tftpd-hpa tftp-hpa
打开/etc/default/tftpd-hpa
修改设置如下:
#Defaults for tftpd-hpa
TFTP_USERNAME="root"
TFTP_DIRECTORY="/home/zdreamx/tftpboot"
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -s -c --secutre"

其中/home/zdreamx/tftpboot是自己设定的目录,可以根据情况修改。

选项参考
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.

启动:sudo service tftpd-hpa start



安装tftpd-hpa和tftpd-hpa

步骤:
1. sudo apt-get install tftp-hpa tftpd-hpa

2. cd /
       sudo mkdir /tftpboot
        sudo chmod 777 /tftpboot

3. sudo in.tftpd -l /tftpboot
     这样tftp服务器就启动了,下面可以做一个测试

4. cd /tftpboot
     touch test
     建立一个文件

5. cd /home/usrname
     登录另一个目录

6. tftp 192.168.0.59
     换成自己的ip

    > get /tftpboot/test

如果能够得到文件,那么就成功了。



安装过程中出现的问题及原因
现象一:
tftp> get test.log
Transfer timed out.
原因:
tftpd服务没有启动


现象二:
tftp> get test.log
Error code 2: Only absolute filenames allowed
原因:
在/etc/xinetd.d/tftpd中设置的server_args为/etc/default/tftpd-hpa
cat /etc/default/tftpd-hpa
#Defaults for tftpd-hpa
RUN_DAEMON="no"
OPTIONS="-s /home/tftpd -c -p -U 077 -u tftpd"
设置的时候只要将server_args=改为你自己设定的服务器文件夹就行了

现象三:
tftp> put ex070416.log
Error code 1: File not found
原因:
指定的文件不存在;或tftpd启动参数中没有指定-c选项,允许上传文件