步驟1
配置tftp
配置tftp服務的步驟:
1、安裝相關軟件包:tftpd(服務端),tftp(客戶端),xinetd
#yum install tftp-server tftp xinetd
2、建立配置文件
在/etc/xinetd.d/下建立一個配置文件tftp
#vim 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服務文件目錄(上傳文件與下載文件的位置),並且更改其權限
#mkdir /tftpboot
#chmod 777 /tftpboot -R
4、重新啓動服務
#/etc/init.d/xinetd restart
至此tftp服務已經安裝完成了,下面可以對其進行一下測試。(假設在當前目錄下有一個測試文件test.txt)
#tftp 127.0.0.1
tftp> put test.txt
tftp> get test.txt
tftp> quit
#
通過get命令,可以把當前目錄下的test.txt文件,通過tftp上傳到它的服務文件目錄。這時,在/tftpboot下面會出現test.txt文件。通過put命令,可以從/tftpboot下,下載test.txt文件。這樣就驗證了tftp服務配置的正確性。當文件上傳與下載結束後,可以通過quit命令退出。
步驟二
嚴格按照以上步驟配置tftp服務,一般都可以成功。如果出現無法get或者put的時候,可以查看一下防火牆是否關閉。
問題一:
若出現類似提示:SELinux is preventing in.tftpd (tftpd_t) "write" to ./tftpboot (tftpdir_t).
tftp> get <filename>
tftp> put<filename>
問題二:
tftp> put <filename>
Error code 1: File not found
原因:
指定的文件不存在;
解決:
/etc/xinetd.d/tftp中的server_args指定的目錄中沒有該文件,將要下載的文件拷貝到該目錄即可,或server_args不是默認的/tftpboot,而是自己設定,但是在後面沒有指定-c選項,補上即可。