一、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配置过程
四、下面将在模拟器中来看一下系统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升级方法类似,不再赘述。