1. 程式人生 > >ubuntu 配置 tftp 服務器

ubuntu 配置 tftp 服務器

行修改 color you src hide 權限 基於 這也 config

一. 安裝 tftp

  1.1. 安裝 tftp 所需的軟件。

    a. 安裝 tftp-hpa,tftpd-hpa,前者是客戶端,後者是服務程序, 在終端下輸入 sudo apt-get install tftp-hpa tftpd-hpa,安裝 tftp-hpa 和 tftpd-hpa

    b. 安裝 xinetd,在終端下輸入 sudo apt-get install xinetd,安裝好 xinetd。

  1.2. 配置/etc/xinetd.conf

    a. 進入根目錄下的 etc 文件夾(cd /etc/),首先看目錄中有沒有一個xinetd.conf 文件,如果沒有則新建一個,有的話查看內容,看是否與下面的一致,若不一致則修改,內容如下

技術分享圖片
# Simple configuration file for xinetd
#
# Some defaults, and include /etc/xinetd.d/

defaults
{

# Please note that you need a log_type line to be able to use log_on_success
# and log_on_failure. The default is the following :
# log_type = SYSLOG daemon info

}

includedir /etc/xinetd.d
~
View Code

  1.3. 配置/etc/default/tftpd-hpa

    1.3.1. 配置 tftp 服務器

      a. sudo vim /etc/default/tftpd-hpa將內容修改成

技術分享圖片
  #/etc/default/tftpd-hpa
 
  TFTP_USERNAME="tftp"
  TFTP_DIRECTORY="/tftpboot"
  TFTP_ADDRESS="0.0.0.0:69"
  TFTP_OPTIONS="-l -c -s"
View Code

      b. "/tftpboot" 這是 tftp 服務器的工作目錄,自行修改,註意,在新建工作目錄時,最好修改其權限為 777,命令 sudo chmod 777 /tftpboot

  1.4. 配置/etc/xinetd.d/tftp

    a. 然後進入 xinetd.d 文件夾(cd xinetd.d),查看是否有一個 tftp 文件,如果沒有就新建一個,如果有的話就查看內容是否與下面的一致,不一致則修改,內容如下:

技術分享圖片
  service tftp                                                                        
{
  socket_type = dgram
  wait = yes
  disable = no
  user = root
  protocol = udp
  server = /usr/sbin/in.tftpd
  server_args = -s /tftpboot
  #log_on_success += PID HOST DURATION
  #log_on_failure += HOST
  per_source = 11
  cps =100 2
  flags =IPv4
}
View Code

    b. server_args 一行是配置服務器的文件存放的位置,就是進行 tftp 傳輸的時候,都是從該文件夾中搜索文件的

  1.5. 重啟服務

    a. 重新啟動服務。sudo service tftpd-hpa restart,這也是我經常疏忽的一步,當配置好 tftp 的配置文件後,需要重新啟動一下 xinetd,在終端中輸入 sudo /etc/init.d/xinetd reload,重新加載一下進程,再輸入 sudo /etc/init.d/xinetd restart,重啟服務。記住,每次修改完配置文件後,都需要

    b. 執行次序:

技術分享圖片
sudo service tftpd-hpa restart
sudo /etc/init.d/xinetd reload
sudo /etc/init.d/xinetd restart
View Code

參考《嵌入式開發環境搭建-基於14.04.pdf》

ubuntu 配置 tftp 服務器