Ubuntu TFTP Server安装测试

Ubuntu 9.04s & Tftpd32 (tftp client):

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.

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wyfzgy.html