sudo apt-get install tftpd-hpa tftp-hpa
打開/etc/default/tftpd-hpa
修改設(shè)置如下:
#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是自己設(shè)定的目錄,可以根據(jù)情況修改。
選項參考
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服務(wù)器就啟動了,下面可以做一個測試
4. cd /tftpboot
touch test
建立一個文件
5. cd /home/usrname
登錄另一個目錄
6. tftp 192.168.0.59
換成自己的ip
> get /tftpboot/test
如果能夠得到文件,那么就成功了。
安裝過程中出現(xiàn)的問題及原因
現(xiàn)象一:
tftp> get test.log
Transfer timed out.
原因:
tftpd服務(wù)沒有啟動
現(xiàn)象二:
tftp> get test.log
Error code 2: Only absolute filenames allowed
原因:
在/etc/xinetd.d/tftpd中設(shè)置的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"
設(shè)置的時候只要將server_args=改為你自己設(shè)定的服務(wù)器文件夾就行了
現(xiàn)象三:
tftp> put ex070416.log
Error code 1: File not found
原因:
指定的文件不存在;或tftpd啟動參數(shù)中沒有指定-c選項,允許上傳文件