一、TFTP簡介
TFTP(Trivial File Transfer Protocol,簡單文件傳輸協議)是TCP/IP協議族中的一個用來在客戶機與服務器之間進行簡單文件傳輸的協議,提供不復雜、開銷不大的文件傳輸服務。TFTP承載在UDP上,使用69號端口。提供不可靠的數據流傳輸服務,不提供存取授權與認證機制,使用超時重傳方式來保證數據的到達。與FTP相 比,TFTP的大小要小的多。
TFTP與FTP的區別
1、TFTP --簡單文件傳輸協議,udp,69;
2、FTP --文件傳輸協議,tcp,20,21;
3、TFTP傳輸速度比FTP快,但是相對沒有FTP安全。
二、TFTP實驗環境
一台裝有TFTP服務器軟件的電腦,交換機(或者路由器)設備,以太網線;
三、TFTP配置過程
- 配置主機、設備ip地址;
- 使用copy命令;
四、下面將在模擬器中來看一下系統bin文件的TFTP備份過程
1、拓撲圖
2、設置服務器的IP地址192.168.1.2, 子網掩碼255.255.255.0;
3、設置交換機的虛接口IP地址192.168.1.1, 子網掩碼255.255.255.0;
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int vlan 1
Switch(config-if)#ip add 192.168.1.1 255.255.255.0
Switch(config-if)#no shut
%LINK-5-CHANGED: Interface Vlan1, changed state to up
Switch(config-if)#
4、顯示交換機flash目錄;
Switch#dir
Directory of flash:/
1 -rw- 3058048 <no date> c2950-i6q4l2-mz.121-22.EA4.bin
64016384 bytes total (60958336 bytes free)
Switch#
說明:交換機里有一個名為“c2950-i6q4l2-mz.121-22.EA4.bin”的文件。
5、在升級前先備份該文件;
Switch#copy flash: tftp: //從flash中復制到tftp服務器中
Source filename []?c2950-i6q4l2-mz.121-22.EA4.bin //要復制的源文件名
Address or name of remote host []? 192.168.1.2 //目標服務器地址
Destination filename [c2950-i6q4l2-mz.121-22.EA4.bin]? c2950.bin //目標文件名
.!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 3058048 bytes]
3058048 bytes copied in 4.953 secs (617000 bytes/sec)
6、下面到TFTP服務器上去看是否有了這個文件?
進入服務器,單擊配置,選擇TFTP,在右邊的文件列表中可以看到c2950.bin。說明文件已經寫入TFTP服務器了。
7、現在要實現從TFTP服務器上傳升級bin文件;
1)首先在交換機上刪除c2950-i6q4l2-mz.121-22.EA4.bin這個文件;
Switch#delete c2950-i6q4l2-mz.121-22.EA4.bin
Delete filename [c2950-i6q4l2-mz.121-22.EA4.bin]? //回車
Delete flash:/c2950-i6q4l2-mz.121-22.EA4.bin? [confirm] //回車
Switch#dir
Directory of flash:/
No files in directory
64016384 bytes total (64016384 bytes free)
Switch#
交換機flash的目錄中已經沒有文件了。在此,先將bin文件刪除了。請注意:在現實中如果空間足夠的話,不要刪除bin文件。
8、從TFTP服務器中下載升級文件;
Switch#copy tftp: flash: //從tftp服務器到交換機flash
Address or name of remote host []? 192.168.1.2 //源主機IP地址
Source filename []? c2950.bin //源文件名稱
Destination filename [c2950.bin]? c2950-i6q4l2-mz.121-22.EA4.bin //目標文件名稱
Accessing tftp://192.168.1.2/c2950.bin....
Loading c2950.bin from 192.168.1.2: !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
[OK - 3058048 bytes]
3058048 bytes copied in 4.907 secs (623201 bytes/sec)
下載完成
9、使用dir顯示文件
Switch#dir Directory of flash:/ 2 -rw- 3058048 <no date> c2950-i6q4l2-mz.121-22.EA4.bin 64016384 bytes total (60958336 bytes free)
Switch#
說明:文件又下載到了交換機的flash中。
10、在完成系統升級后,要reload重啟系統;
Switch#
Switch#reload
Proceed with reload? [confirm] //回車
C2950 Boot Loader (C2950-HBOOT-M) Version 12.1(11r)EA1, RELEASE SOFTWARE (fc1)
Compiled Mon 22-Jul-02 18:57 by miwang
Cisco WS-C2950-24 (RC32300) processor (revision C0) with 21039K bytes of memory.
2950-24 starting...
Base ethernet MAC Address: 0030.A35C.4165
Xmodem file system is available.
Initializing Flash...
flashfs[0]: 1 files, 0 directories
flashfs[0]: 0 orphaned files, 0 orphaned directories
flashfs[0]: Total bytes: 64016384
flashfs[0]: Bytes used: 3058048
flashfs[0]: Bytes available: 60958336
flashfs[0]: flashfs fsck took 1 seconds.
...done Initializing Flash.
Boot Sector Filesystem (bs:) installed, fsid: 3
Parameter Block Filesystem (pb:) installed, fsid: 4
Loading "flash:/c2950-i6q4l2-mz.121-22.EA4.bin"...
########################################################################## [OK]
Restricted Rights Legend
Use, duplication, or disclosure by the Government is
subject to restrictions as set forth in subparagraph
(c) of the Commercial Computer Software - Restricted
Rights clause at FAR sec. 52.227-19 and subparagraph
(c) (1) (ii) of the Rights in Technical Data and Computer
Software clause at DFARS sec. 252.227-7013.
cisco Systems, Inc.
170 West Tasman Drive
San Jose, California 95134-1706
Cisco Internetwork Operating System Software
IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1)
Copyright (c) 1986-2005 by cisco Systems, Inc.
Compiled Wed 18-May-05 22:31 by jharirba
Cisco WS-C2950-24 (RC32300) processor (revision C0) with 21039K bytes of memory.
Processor board ID FHK0610Z0WC
Running Standard Image
24 FastEthernet/IEEE 802.3 interface(s)
63488K bytes of flash-simulated non-volatile configuration memory.
Base ethernet MAC Address: 0030.A35C.4165
Motherboard assembly number: 73-5781-09
Power supply part number: 34-0965-01
Motherboard serial number: FOC061004SZ
Power supply serial number: DAB0609127D
Model revision number: C0
Motherboard revision number: A0
Model number: WS-C2950-24
System serial number: FHK0610Z0WC
Cisco Internetwork Operating System Software
IOS (tm) C2950 Software (C2950-I6Q4L2-M), Version 12.1(22)EA4, RELEASE SOFTWARE(fc1)
Copyright (c) 1986-2005 by cisco Systems, Inc.
Compiled Wed 18-May-05 22:31 by jharirba
Press RETURN to get started!
%LINK-5-CHANGED: Interface FastEthernet0/1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
Switch>en
Switch#show running-config
Building configuration...
Current configuration : 970 bytes
!
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
ip name-server 0.0.0.0
!
!
interface FastEthernet0/1
!
...
!
interface Vlan1
no ip address
shutdown
!
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
!
end
Switch#
此時系統將重裝bin文件
11、重新顯示配置內容,會發現原來的設置都沒了。證明重傳成功了。
Switch>en
Switch#show running-config
Building configuration...
Current configuration : 970 bytes
!
version 12.1
no service timestamps log datetime msec
no service timestamps debug datetime msec
no service password-encryption
!
hostname Switch
!
ip name-server 0.0.0.0
!
!
interface FastEthernet0/1
!
...
!
interface Vlan1
no ip address
shutdown
!
!
line con 0
!
line vty 0 4
login
line vty 5 15
login
!
!
end
Switch#
五、FTP方式備份與還原網絡設備系統
FTP由於使用的是tcp可靠傳輸模式,速度沒有tftp快,但是有了用戶名和密碼,相對比tftp要安全些。
六、FTP實驗環境
FTP服務器、路由器、以太網線纜;
七、配置過程
1、配置服務器和路由器的ip地址;
2、在ftp服務器中新建用戶名和密碼;
3、在路由器中指定與ftp服務器中用戶名、密碼相關聯;
4、使用copy命令即可。
八、實驗步驟
實驗拓撲
1、設置FTP服務器的IP地址192.168.1.2, 子網掩碼255.255.255.0;
2、設置路由器Fa0/0的IP地址192.168.1.1, 子網掩碼255.255.255.0;
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int fa0/0
Router(config-if)#ip add 192.168.1.1 255.255.255.0
Router(config-if)#no shut
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#exit
3、在FTP服務器中新建用戶名和密碼;
4、在路由器中指定與ftp服務器中用戶名、密碼相關聯;
Router(config)#ip ftp ? password Specify password for FTP connections username Specify username for FTP connections Router(config)#ip ftp use Router(config)#ip ftp username david ? <cr> Router(config)#ip ftp username david Router(config)#ip ftp pass Router(config)#ip ftp password ? <0-7> Encryption type (0 to disable encryption, 7 for proprietary LINE LINE The password Router(config)#ip ftp password 123456 Router(config)#end
5、顯示路由器flash目錄;
Router#dir Directory of flash:/ 3 -rw- 33591768 <no date> c1841-advipservicesk9-mz.124-15.T1.bin 2 -rw- 28282 <no date> sigdef-category.xml 1 -rw- 227537 <no date> sigdef-default.xml 64016384 bytes total (30168797 bytes free) Router#cop
6、在升級前先備份該文件;
Router#copy fl
Router#copy flash: ?
ftp: Copy to ftp: file system
running-config Update (merge with) current system configuration
startup-config Copy to startup configuration
tftp: Copy to tftp: file system
Router#copy flash: ft
Router#copy flash: ftp:
Source filename []? c1841-advipservicesk9-mz.124-15.T1.bin
Address or name of remote host []? 192.168.1.2
Destination filename [c1841-advipservicesk9-mz.124-15.T1.bin]? c1841.bin
Writing c1841-advipservicesk9-mz.124-15.T1.bin...
[OK - 33591768 bytes]
33591768 bytes copied in 346.13 secs (97000 bytes/sec)
Router#
Router#
Router#
7、到FTP服務器上去看是否有了這個文件;
有c1841.bin文件了,說明備份成功。
8、還原升級和TFTP升級方法類似,不再贅述。