安裝套件tftp-hpa tftpd-hpa xinetd
yum -y install tftp tftp-server
mkdir tftproot
#chmod -R 777 /var/lib/tftpboot
vi /etc/xinetd.d/tftp
接下來將tftp設定開機啟動並檢查是否加入xinetd
chkconfig tftp on
chkconfig xinetd on
chkconfig --list | grep "xinetd\|tftp"
server xinted start
netstat -tlnup | grep ':69'
重啟服務
/etc/init.d/xinetd restart
測試上傳及下載檔案
tftp -v 192.168.1.20 -c get test1
tftp -v 192.168.1.20 -c put test2
上傳檔案錯誤問題
[root@bk-mail tmp]# tftp -v 192.168.1.20 -c put test1Connected to 192.168.1.20 (192.168.1.20), port 69
putting test1 to 192.168.1.20:test1 [netascii] Error code 1: File not found
vi /etc/xinetd.d/tftp 中 server_args 加上 -c 參數,以允許檔案上傳。
#grep server_args /etc/xinetd.d/tftp server_args = -s /var/lib/tftpboot -c //加上 -c 參數以允許檔案上傳[root@bk-mail tmp]# tftp -v 192.168.1.20 -c put test
Connected to 192.168.1.20 (192.168.1.20), port 69
putting test to 192.168.1.20:test [netascii] Error code 0: Permission denied
因為 /var/lib/tftpboot 資料夾預設權限為 755,而 Switch 預設上傳時會使用 nobody 這個帳號進行上傳的動作所導致,另外如果您有開啟 SELinux 機制的話請記得執行 restorcon 指令。
chmod -R 777 /var/lib/tftpboot
參考資料:http://www.weithenn.org/cgi-bin/wiki.pl?tftp-%E6%9E%B6%E8%A8%AD_tftp_server