安裝套件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-1

接下來將tftp設定開機啟動並檢查是否加入xinetd

chkconfig tftp on

chkconfig xinetd on

chkconfig --list | grep "xinetd\|tftp"

server xinted start

netstat -tlnup | grep ':69'

tftp

重啟服務

/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 test1
Connected 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

By tony

自由軟體愛好者~喜歡不斷的思考各種問題,有新的事物都會想去學習嘗試 做實驗並熱衷研究 沒有所謂頂天的技術 只有謙虛及不斷的學習 精進專業,本站主要以分享系統及網路相關知識、資源而建立。 Github http://stnet253.github.io

發佈留言

發佈留言必須填寫的電子郵件地址不會公開。 必填欄位標示為 *

這個網站採用 Akismet 服務減少垃圾留言。進一步了解 Akismet 如何處理網站訪客的留言資料