歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> 配置Ubuntu的tftp服務

配置Ubuntu的tftp服務

日期:2017/3/3 14:00:48   编辑:Linux技術

tftp(Trivial File Transfer Protocol,簡單文件傳輸協議)是TCP/IP協議族中的一個用來在客戶機與服務器之間進行簡單文件傳輸的協議,它提供不復雜、開銷不大的文件傳輸服務,端口號為69。

我們在做ARM-Linux嵌入式開發中,經常需要用到tftp在Linux服務端和開發板間進行進行文件傳輸,因為我所使用的是Ubuntu,所以下面主要介紹Ubuntu下如何啟動、配置tftp服務。

Step1:安裝tftp相關軟件包 包括 xinetd(用於管理tftp),tftpd(服務端),tftp(客戶端)

[code]sudo apt-get install xinetd tftpd tftp
也可以安裝openbsd-inetd代替xinetd,據說debian5.0不用xinetd進行管理,而是用openbsd-inetd。

[code]sudo apt-get install openbsd-inetd tftpd tftp
Step2:建立配置文件

如果上一步安裝的是xinetd,則在/etc/xinetd.d/下建立一個配置文件tftp,打開該文件並輸入如下內容,保存退出。

[code]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
}
其中,/tftpboot就是我們的tftp服務文件目錄,也就是說,以後用tftp命令上傳或下載文件的位置就是/tftpboot目錄。

如果上一步安裝的是openbsd-inetd,則不需要新建配置文件,直接打開文件 /etc/inetd.conf 進行修改即可。

修改格式如下:

[code]<service_name>  <sock_type> <proto> <flags> <user>  <server_path>   <args>
我們只需把原來的

[code]tftp    dgram   udp wait    nobody  /usr/sbin/tcpd  /usr/sbin/in.tftpd  /srv/tftp
修改為如下,即可。(最後的參數/tftpboot就是tftp服務文件目錄,可根據實際情況修改)

[code]tftp    dgram   udp wait    root    /usr/sbin/in.tftpd  /usr/sbin/in.tftpd -s /tftpboot
Step3:建立tftp服務文件目錄,並更改其權限

執行如下命令:

[code]sudo mkdir /tftpboot
sudo chmod 777 /tftpboot -R
Step4:重新啟動tftp服務

如果Step1安裝的是xinetd,則輸入如下命令:

[code]sudo /etc/init.d/xinetd restart
如果Step1安裝的是openbsd-inetd,則輸入如下命令:

[code]sudo /etc/init.d/openbsd-inetd restart
至此,我們在Ubuntu下的tftp服務已經安裝、配置、啟動完成了。

【tips:如果是在開發板上通過U-Boot提供的tftp命令來與tftp服務端進行文件傳輸,則只需連接網線,並設置好ipaddr、serverip、gateway、netmask即可。】

Copyright © Linux教程網 All Rights Reserved