TFTP介紹
TFTP:Trivial File Transfer Protocol ,是一種用于傳輸文件的簡單高級協議,是文件傳輸協議(FTP)的簡化版本。用來傳輸比文件傳輸協議(FTP)更易于使用但功能較少的文件
TFTP和FTP的區別
1、安全性區別
FTP支持登錄安全,具有適當的身份驗證和加密協議,在建立連接期間需要與FTP身份驗證通信
TFTP是一種開放協議,缺乏安全性,沒有加密機制,與TFTP通信時不需要認證
2、傳輸層協議的區別
FTP使用TCP作為傳輸層協議,TFTP使用UDP作為傳輸層協議
3、使用端口的區別
FTP使用2個端口:TCP端口21,是個偵聽端口;TCP端口20或更高TCP端口1024以上用于源連接
TFTP僅使用一個具有停止和等待模式的端口:端口69/udp
4、RFC的區別
FTP是基于RFC 959文檔,帶有其他RFC涵蓋安全措施;TFTP基于RFC 1350文檔
5、執行命令的區別
FTP有許多可以執行的命令(get,put,ls,dir,lcd)并且可以列出目錄等
TFTP只有5個指令可以執行(rrq,wrq,data,ack,error)
安裝和使用TFTP
安裝包:
- tftp-server #服務器包
- tftp #客戶端包
范例:安裝并使用tftp下載文件
#安裝tftp服務器包
[root@centos8 ~]#dnf install tftp-server -y
[root@centos8 ~]#rpm -ql tftp-server
/usr/lib/.build-id
/usr/lib/.build-id/8c
/usr/lib/.build-id/8c/6921a9fb21d66da4fb299d516bce9ee6afea34
/usr/lib/systemd/system/tftp.service
/usr/lib/systemd/system/tftp.socket
/usr/sbin/in.tftpd #tftp主程序
/usr/share/doc/tftp-server
/usr/share/doc/tftp-server/CHANGES
/usr/share/doc/tftp-server/README
/usr/share/doc/tftp-server/README.security
/usr/share/man/man8/in.tftpd.8.gz
/usr/share/man/man8/tftpd.8.gz
/var/lib/tftpboot
#啟動服務
[root@centos8 ~]#systemctl enable --now tftp.service
Created symlink /etc/systemd/system/sockets.target.wants/tftp.socket → /usr/lib/systemd/system/tftp.socket.
[root@centos8 ~]#ss -nulp|grep tftp
UNCONN 0 0 *:69 *:* users:(("in.tftpd",pid=10100,fd=0),("systemd",pid=1,fd=32))
#準備測試文件
[root@centos8 ~]#cp /etc/fstab /var/lib/tftpboot/f1.txt
[root@centos8 ~]#mkdir /var/lib/tftpboot/dir
[root@centos8 ~]#cp /etc/password /var/lib/tftpboot/dir/f2.txt
#安裝tftp客戶端包
[root@centos7 ~]#yum -y install tftp
#客戶端通過tftp測試下載文件
[root@centos7 ~]#tftp 10.0.0.8
tftp> ls
?Invalid command
tftp> help
tftp-hpa 5.2
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
literal toggle literal mode, ignore ':' in file name
status show current status
binary set mode to octet
ascii set mode to netascii
rexmt set per-packet transmission timeout
timeout set total retransmission timeout
? print help information
help print help information
tftp> get f1.txt
tftp> get dir/f2.txt
tftp> quit
[root@centos7 ~]#ls
anaconda-ks.cfg f1.txt f2.txt
#以下在tftp服務器執行,當用戶下載文件后,可以觀察到服務器端自動打開in.tftpd主程序
[root@centos8 tftpboot]#ps aux|grep in.tftp
root 1276 0.0 0.2 14912 1720 ? Ss 12:03 0:00 /usr/sbin/in.tftpd -s /var/lib/tftpboot
root 1282 0.0 0.1 12108 960 pts/0 R+ 12:04 0:00 grep --color=auto in.tftp
本文鏈接:http://www.avtobanya.com/36137.html
網友評論comments