1、安裝相關(guān)軟件包:Ubuntu tftp(服務(wù)端),tftp(客戶端),xinetd
root@xf:/# apt-get install tftpd tftp xinetd
正在讀取軟件包列表... 完成
正在分析軟件包的依賴關(guān)系樹
正在讀取狀態(tài)信息... 完成
下列【新】軟件包將被安裝:
tftp tftpd xinetd
升級了 0 個軟件包,新安裝了 3 個軟件包,要卸載 0 個軟件包,有 0 個軟件包未被升級。
需要下載 185kB 的軟件包。
解壓縮后會消耗掉 578kB 的額外空間。
獲取:1 http://mirrors.sohu.com/ubuntu/ karmic/universe tftp i386 0.17-17ubuntu1 [17.6kB]
獲?。? http://mirrors.sohu.com/ubuntu/ karmic/main xinetd i386 1:2.3.14-7ubuntu2 [151kB]
獲取:3 http://mirrors.sohu.com/ubuntu/ karmic/universe tftpd i386 0.17-17ubuntu1 [16.5kB]
下載 185kB,耗時 2秒 (79.6kB/s)
選中了曾被取消選擇的軟件包 tftp。
(正在讀取數(shù)據(jù)庫 ... 系統(tǒng)當(dāng)前共安裝有 173693 個文件和目錄。)
正在解壓縮 tftp (從 .../tftp_0.17-17ubuntu1_i386.deb) ...
選中了曾被取消選擇的軟件包 xinetd。
正在解壓縮 xinetd (從 .../xinetd_1%3a2.3.14-7ubuntu2_i386.deb) ...
選中了曾被取消選擇的軟件包 tftpd。
正在解壓縮 tftpd (從 .../tftpd_0.17-17ubuntu1_i386.deb) ...
正在處理用于 man-db 的觸發(fā)器...
正在處理用于 ureadahead 的觸發(fā)器...
正在設(shè)置 tftp (0.17-17ubuntu1) ...
正在設(shè)置 xinetd (1:2.3.14-7ubuntu2) ...
* Stopping internet superserver xinetd
[ OK ]
* Starting internet superserver xinetd
[ OK ]
正在設(shè)置 tftpd (0.17-17ubuntu1) ...
Note: xinetd currently is not fully supported by update-inetd.
Please consult /usr/share/doc/xinetd/README.Debian and itox(8).
2、建立配置文件
在/etc/xinetd.d/下建立一個配置文件tftp
sudo vim tftp
在文件中輸入以下內(nèi)容:
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
log_on_success += PID HOST DURATION
log_on_failure += HOST
}
保存退出。
3、建立Ubuntu tftp服務(wù)文件目錄(上傳文件與下載文件的位置),并且更改其權(quán)限
sudo mkdir /tftpboot
sudo chmod 777 /tftpboot -R
4、重新啟動服務(wù)
sudo /etc/init.d/xinetd restart
至此Ubuntu tftp服務(wù)已經(jīng)安裝完成了,下面可以對其進(jìn)行一下測試。(在當(dāng)前目創(chuàng)建2.c,在tftpboot目錄下創(chuàng)建1.c和2.c,且
tftpboot目錄下2.c權(quán)限為777)
執(zhí)行g(shù)et命令時,保證tftpboot目錄下的文件權(quán)限為777,
執(zhí)行put命令時,必須先在tftpboot目錄下新建一個和上傳文件同名的文件且權(quán)限為777.
root@xf:/home# tftp 127.0.0.1
tftp> get 1.c
Received 7 bytes in 0.1 seconds
tftp> put 2.c
Sent 10 bytes in 0.0 seconds
tftp> quit
root@xf:/home# ls
1.c 2.c ubuntu-10.10下編譯環(huán)境的搭建.txt xiaofeng
root@xf:/home# cd /tftpboot/
1.c 2.c
---引自于http://blog.csdn.net/xiaomeiqing/archive/2011/03/24/6273160.aspx