TFTP(Trivial File Transfer Protocol,簡單文件傳輸協議)是TCP/IP協議族中的一個用來在客戶機與服務器之間進行簡單文件傳輸的協議,提供不復雜、開銷不大的文件傳輸服務。端口號爲69。
基於UDP的tftp協議,在嵌入式Linux開發中,在很多場合都被用到,甚至是必不可少的,特別是在內核調試階段,在U-Boot下通過TFTP協議從服務器上加載內核並運行,既方便又快捷。
要使用tftp服務,服務器和客戶端都是必不可少的,tftp還可以跨平臺傳輸數據,總之,使用範圍非常廣的強大傳輸協議。
tftp 服務器搭建:
-
裝在客戶端和服務端
apt-get install tftp tftpd-hpa -
若沒有安裝守護進程 xinetd
apt-get install xinetd -
在 /etc 路徑下編輯xinetd.conf文件,沒有則創建,內容如下:
Simple configuration file for xinetd
Some defaults, and include /etc/xinetd.d/
defaults
{Please note that you need a log_type line to be able to use log_on_success
and log_on_failure. The default is the following :
log_type = SYSLOG daemon info
}
includedir /etc/xinetd.d
-
在/etc/xinetd 路徑下創建tftp文件,內容如下:
service tftp
{
socket_type = dgram
protocol = udp
wait = yes
user = root
server = /usr/sbin/in.tftpd
server_args = -s /var/tftpboot/ -c 此處爲tftp根路徑,可自行設置 -c 爲開啓上傳控制
disable = no
per_source = 11
cps = 100 2
flags = IPv4
} -
創建文件 /etc/default/tftpd-hpa ,內容如下:
TFTP_USERNAME=“tftp”
TFTP_DIRECTORY="/home/zhoudy/tftpboot"
TFTP_ADDRESS=“0.0.0.0:69”
TFTP_OPTIONS="-l -c -s" -
更改tftp根路徑的權限
chmod 777 /var/tftpboot/ -
重啓服務xinetd守護進程服務
/etc/init.d/xinetd restart -
重啓tftp服務
/etc/init.d/tftp restart
測試:
本地測試:
tftp localhost 看是否能夠進入到tftp服務界面,通過get/put來下載/上傳文件。