歡迎來到Linux教程網
Linux教程網
Linux教程網
Linux教程網
Linux教程網 >> Linux基礎 >> Linux技術 >> Linux系統中tftp命令使用詳解

Linux系統中tftp命令使用詳解

日期:2017/8/19 9:45:24   编辑:Linux技術

  Linux系統中tftp命令主要是傳輸文件用的。下面由學習啦小編為大家整理了linux系統中tftp命令使用詳解,希望對大家有幫助!

  Linux系統中tftp命令使用詳解

  語法

  tftp [主機名稱或IP地址]

  操作說明:

  connect:連接到遠程tftp服務器

  mode:文件傳輸模式

  put:上傳文件

  get:下載文件

  quit:退出

  verbose:顯示詳細的處理信息

  tarce:顯示包路徑

  status:顯示當前狀態信息

  binary:二進制傳輸模式

  ascii:ascii 傳送模式

  rexmt:設置包傳輸的超時時間

  timeout:設置重傳的超時時間

  help:幫助信息

  ? :幫助信息

  linux系統中tftp命令詳解實例

  連接遠程服務器"218.28.188.288",然後使用put 命令下載其中根目錄下的文件"README",可使用命令如下:

  tftp 218.28.188.288 #連接遠程服務器

  連接服務器之後可進行相應的操作,具體如下:

  $ tftp 218.28.188.228 #連接遠程服務器

  tftp> ? #使用?,參考幫助

  Commands may be abbreviated. Commands are: #幫助命令列表

  connect connect to remote tftp

  mode set file transfer mode

  put send file

  get receive file

  quit exit tftp

  verbose toggle verbose mode

  trace toggle packet tracing

  status show current status

  binary set mode to octet

  ascii set mode to netascii

  rexmt set per-packet retransmission timeout

  timeout set total retransmission timeout

  ? print help information

  tftp>get README #遠程下載README文件

  getting from 218.28.188.288 to /home/cmd

  Recived 168236 bytes in 1.5 seconds[112157 bit/s]

  tftp>quit

  補充: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、配置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/mike/tftpboot -c

  disable =no

  per_source =11

  cps =100 2

  flags =IPv4

  }

  說明:修改項server_args= -s <path> -c,其中<path>處可以改為你的tftp-server的根目錄

  參數-s指定chroot,-c指定了可以創建文件。

  3、啟動tftp服務器並關閉防火牆

  RedHat7+

  systemctl disable firewall;systemctl stop firewall

  systemctl enable xinetd;systemctl start xinetd

  Redhat7-

  /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

  顯示結果為

  udp 0 0 *:tftp *:*

  表明服務已經開啟,就表明tftp配置成功了。

  5、tftp使用

  復制一個文件到tftp服務器目錄,然後在主機啟動tftp軟件,進行簡單測試。

Copyright © Linux教程網 All Rights Reserved