Linux中tftp安裝及使用筆記


tftp命令用在本機和tftp服務器之間使用TFTP協議傳輸文件。

TFTP是用來下載遠程文件的最簡單網絡協議,它其於UDP協議而實現。

linux服務器端tftp-server的配置
1、安裝tftp服務器 需要安裝xinetd(守護tftp)、tftp和tftp-server 3個軟件 1)如果能上網,通過yum安裝:
sudo yum install xinetd
sudo yum install tftp
sudo yum install tftp-server
2)如果不能上網,可以直接安裝提供的rpm包:
rpm -ivh xinetd-2.3.14-18.fc9.i386.rpm 
rpm -ivh tftp-0.48-3.fc9.i386.rpm 
rpm -ivh tftp-server-0.48-3.fc9.i386.rpm
2、配置tftp服務器
修改/etc/xinetd.d/tftp文件,將其中的disable=yes改為disable=no。開啟TFTP服務
主要是設置TFTP服務器的根目錄,開啟服務。修改后的文件如下:
service tftp
{     socket_type            =dgram
       protocol              =udp
       wait                  =yes
       user                  =root
       server                =/usr/sbin/in.tftpd
       server_args           =-s /home/walt740/tftpboot -c
       disable               =no
       per_source            =11
       cps                   =100 2
       flags                 =IPv4
}

說明:修改項server_args= -s -c,其中<path>處可以改為你的tftp-server的根目錄,參數-s指定chroot,-c指定了可以創建文件。
3、啟動tftp服務器並關閉防火牆

CentOS 7+:
systemctl disable firewall;systemctl stop firewall
systemctl enable xinetd;systemctl start xinetd
CentOS 7-:
/etc/init.d/iptables stop //關閉防火牆 
sudo /sbin/service xinetd start 
或 
service xinetd restart 
/etc/init.d/xinetd start

看到啟動[OK]就可以了

4、查看tftp服務是否開啟
netstat -a | grep tftp
顯示結果為
udp6       0      0 [::]:tftp               [::]:* 
表明服務已經開啟,就表明tftp配置成功了。

5、tftp命令用法如下
tftp     your-ip-address
【進入TFTP操作】
connect:連接到遠程tftp服務器
mode:文件傳輸模式
put:上傳文件
get:下載文件
quit:退出
verbose:顯示詳細的處理信息
tarce:顯示包路徑
status:顯示當前狀態信息
binary:二進制傳輸模式
ascii:ascii傳送模式
rexmt:設置包傳輸的超時時間
timeout:設置重傳的超時時間
help:幫助信息
?:幫助信息

6、命令使用 Linux向Windows直接傳文件/取文件

tftp 192.168.1.107
tftp> put 123.txt
tftp> get 456.txt

tftp Error code 0: Permission denied解決辦法

【錯誤】Error code 0: Permission denied,是因為tftpboot文件夾沒有權限,或者是要上傳和下載的文件沒有權限。

【解決】修改權限

sudo chmod 777 -R /tftpboot

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM