天天看點

Ubuntu12.04安裝TFTP服務

1.安裝指令

$sudo apt-get install xinetd tftpd tftp
           

2.建立配置檔案

$sudo gedit /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伺服器目錄

$sudo mkdir /tftpboot
$sudo chmod 777 /tftpboot -R
           

4.重新開機TFTP服務

$sudo service xinetd restart
           

TFTP下載下傳指令格式為:get 檔案名

TFTP上傳指令格式為:put 檔案名

5.TFTP下載下傳測試

将目錄“/tftpboot”裡的test檔案下載下傳到使用者目錄裡面。

[email protected]:~$ ls
Desktop    Downloads         Music     Public     Videos
Documents  examples.desktop  Pictures  Templates
[email protected]:~$ tftp 127.0.0.1
tftp> get test
Received 21 bytes in 0.1 seconds
tftp> quit
[email protected]:~$ ls
Desktop    Downloads         Music     Public     test
Documents  examples.desktop  Pictures  Templates  Videos
           

6.TFTP上傳測試

TFTP服務預設隻能下載下傳不能上傳,如果要上傳的話,必須在目錄“/tftpboot”裡面建立名稱相同的檔案。在使用者目錄下建立hao123檔案,檔案内容寫hao123,使用put上傳指令,提示錯誤資訊“Error code 2: Access violation”。

[email protected]:~$ gedit hao123
[email protected]:~$ ls
Desktop    Downloads         hao123  Pictures  Templates  Videos
Documents  examples.desktop  Music   Public    test
[email protected]:~$ tftp 192.168.2.11
tftp> put hao123
Error code 2: Access violation
           

回到“/tftpboot”目錄,在裡面建立檔案hao123,建立後需要修改檔案權限,再次回到使用者目錄“~/”,這次可以完成檔案hao123的上傳。

tftp> quit
[email protected]:~$ cd /tftpboot
[email protected]:/tftpboot$ touch hao123
[email protected]:/tftpboot$ ls
hao123  test  test2  test2~
[email protected]:/tftpboot$ chmod 777 hao123
[email protected]:/tftpboot$ cd /home/wang
[email protected]:~$ ls
Desktop    Downloads         hao123  Pictures  Templates  Videos
Documents  examples.desktop  Music   Public    test
[email protected]:~$ tftp 192.168.2.11
tftp> put hao123
Sent 8 bytes in 0.1 seconds
           

繼續閱讀