ubuntu tftp服務的步驟配置

原文鏈接:http://os.51cto.com/art/201001/176508.htm

 

 

在向大家詳細介紹tftp之前,首先讓大家瞭解下Ubuntu tftp,然後全面介紹Ubuntu tftp,希望對大家有用。Ubuntu 團隊對它的使用者公開的承諾:Ubuntu 永遠免費 , 並且對於 "企業版本" 沒有任何額外的費用, 在同樣的自由團隊上,將最好的工作成果帶給每一個人。

配置Ubuntu tftp服務的步驟:

1、安裝相關軟件包:Ubuntu tftp(服務端),tftp(客戶端),xinetd
sudo apt-get install tftpd tftp xinetd

2、建立配置文件
在/etc/xinetd.d/下建立一個配置文件tftp
sudo vi 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、建立Ubuntu tftp服務文件目錄(上傳文件與下載文件的位置),並且更改其權限
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot -R

4、重新啓動服務
sudo /etc/init.d/xinetd restart
至此Ubuntu tftp服務已經安裝完成了,下面可以對其進行一下測試。(假設在當前目錄下有一個測試文件test.txt)
$tftp 127.0.0.1                      
tftp> put test.txt
Sent 1018 bytes in 0.0 seconds
tftp> get test.txt
Received 1018 bytes in 0.1 seconds
tftp> quit

通過get命令,可以把當前目錄下的test.txt文件,通過Ubuntu tftp上傳到它的服務文件目錄。這時,在/tftpboot下面會出現test.txt文件。通過put命令,可以從/tftpboot下,下載 test.txt文件。這樣就驗證了Ubuntu tftp服務配置的正確性。當文件上傳與下載結束後,可以通過quit命令退出。嚴格按照以上步驟配置Ubuntu tftp服務,一般都可以成功。如果出現無法get或者put的時候,可以查看一下防火牆是否關閉。

 

如果從tftp服務器下載失敗,

要確保服務器的根目錄有可執行的權限。

$ chmod -R 777 tftp


使用中發現能正常下載文件,

$ tftp 192.168.1.222
tftp> get zImage
Received 1692890 bytes in 0.2 seconds

可是上傳文件不成功,

提示錯誤:

tftp> put dic.txt
Error code 2: Access violation

求助於google, 得下面一段說明,問題解決。

The tftp man page says:

Because there is no user-login or validation within the TFTP
protocol, the remote site will probably have some sort of
file-access restrictions in place. The exact methods are
specific to each site and therefore dif ficult to document here.

So apparently the site you're trying to get the file from has some
kind of access restrictions in place. Take a look at the tftpd man
page on the remote host. The linux tftpd manual says, in part, "Due to
the lack of authentication information, tftpd will allow only publicly
readable files to be accessed. Files may be written only if they
already exist and are publicly writable."

上面主要意思就是: tftp服務器缺少必要的身份驗證,

所以默認只允許下載文件,要上傳文件,必須是服務器中已存在同名的文件,

且該文件權限允許被覆蓋。


所以首先在服務中創建一個與要上傳的文件同名的文件,並更改權限。

$ touch dic.txt

$ chmod 777 dic.txt

重新上傳,成功。
tftp> put dic.txt
Sent 13770 bytes in 0.0 seconds

 

在網上看到有人配/etc/default/tftp,/etc/inetd.conf這些文件,實際上沒這麼複雜,用tftp和tftpd,加上xinetd監控,只需要配/etc/xinetd./tftp即可。

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章