linux tftp配置 (Ubuntu18.04)


    1. 安裝tftp客戶端和服務器
      sudo apt-get install tftp-hpa tftpd-hpa xinetd
      tftp-hpa是客戶端
      tftpd-hpa是服務器
    2. 配置文件
    3. sudo vim /etc/xinetd.d/tftp
       1 service tftp
       2 {
       3         socket_type     = dgram
       4         protocol        = udp
       5         wait            = yes
       6         user            = sen            #使用服務器的用戶名
       7         server          = /home/aishanliang/tftp_share            #這里選擇服務器資源路徑
       8         server_args     = -s /tftp -c
       9         disable         = no
      10         per_source      = 11
      11         cps             = 100 2
      12         flags           = IPv4
      13 }
    4. sudo vim /etc/default/tftpd-hpa
      1 TFTP_USERNAME="tftp"
      2 TFTP_DIRECTORY="/home/aishanliang/tftp_share"        #這里選擇服務器資源路徑
      3 TFTP_ADDRESS=":69"
      4 TFTP_OPTIONS="--secure"        #暫未研究,這里使用默認不改動
    5. 創建服務器資源文件夾
      sudo mkdir /home/sen/tftp_share

                     6.使用chmod命令為該目錄設置最寬松的權限。

                         sudo chmod -R 777 tftp_share

                         sudo chown -R nobody tftp_share

                   7.重啟服務

       sudo service tftpd-hpa restart

       sudo /etc/init.d/xinetd restart

      8.測試

      

  •         檢測是否ping得通
  •         若有防火牆則關閉

           sudo ufw disable

  •         檢測tftp是否啟動

           netstat -a|grep tftp
        當結果顯示 : udp 0 0 *:tftp : 則啟動tftp服務了

  •         在/home/sen/tftp_share創建文件並寫進測試信息

          touch test
          echo “hello” > test
          cat test

  •         ifconfig查看當前虛擬機IP

        假設是192.168.13.59
        在虛擬機的另一個文件夾用tftp下載tftp服務器資源文件夾的test文件

 

       用ls命令查看當前文件夾,若能看到test則tftp配置成功。

  1. tftp與開發板的傳輸:在Ubuntu安裝完tftp后,就可以在開發板上用tftp命令下載文件了。
  • tftp -g -r < filename > < ip address >

方法二:

1. 安裝
$ apt-get install tftp-hpa tftpd-hpa
 
2. 建立目錄
$ mkdir /tftpboot # 這是建立tftp傳輸目錄。
$ sudo chmod 0777 /tftpboot
$ sudo touch test.txt # test.txt文件最好輸入內容以便區分
 
3. 配置
# vi /etc/default/tftpd-hpa
TFTP_USERNAME="tftp"
TFTP_DIRECTORY="/tftpboot" # 這里是你的tftpd-hpa的服務目錄,這個想建立在哪里都行
TFTP_ADDRESS="0.0.0.0:69"
TFTP_OPTIONS="-l -c -s" # 這里是選項,-c是可以上傳文件的參數,-s是指定tftpd-hpa服務目錄,上面已經指定
 
4. 重啟服務
$ sudo service tftpd-hpa restart # 啟動服務,這里要注意,采用的獨立服務形式。
 
5. 測試
# cd /home
# tftp localhost  #localhost 表示本機
tftp>get test.txt  //test.txt 是之前在 /tftpboot 目錄下新建的文件
tftp>put test1.txt //test1.txt 是在 /home 目錄下新建的文件
tftp>q
退出后,在/home目錄下會有一個test.txt文件,在/tftpboot 目錄下有test1.txt,表示tftp服務器安裝成功!

更多Ubuntu相關信息見Ubuntu 專題頁面 http://www.linuxidc.com/topicnews.aspx?tid=2

本文永久更新鏈接地址http://www.linuxidc.com/Linux/2016-07/133255.htm


免責聲明!

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



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