Lab 2 路由器的基本管理 1
实验目的 1. 理解 TFTP 服务的特点与作用与配置 2. 掌握 TFTP 服务的配置 3. 掌握使用 TFTP 上传进行 IOS 备份的方法 4. 掌握使用 TFTP 下载进行 IOS 恢复 / 更新的方法 5. 掌握使用 TFTP 进行配置文件的备份与恢复的方法 6. 掌握路由器密码恢复的基本方法 R&S 1-2
实验内容 1 通过 TFTP 进行 IOS 备份 恢复 / 更新 ( 注 : 实验室中进行 ) R&S 1-3
知识要点 1:IOS 备份与恢复方式 R&S 1-4
物理连接 R&S 1-5
TFTP Server 软件的安装 准备 1. 从 http://solarwinds.net 上免费下载 SolarWinds TFTP Server 软件 ; 2. 下载后安装 ; 3. 运行该软件 R&S 1-6
TFTP Server 软件的安装 准备 ( 续 ) R&S 1-7
保证路由器和计算机间的 IP 可达 R2(config)#int g0/0 R2(config-if)#no shutdown R2(config-if)#ip address 172.16.0.2 255.255.0.0 R2(config-if)#exit // 以上在路由器的以太网接口配置 IP 地址, 并启用接口 R2#ping 172.16.0.100 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 172.16.0.100, timeout is 2 seconds:!!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 1/1/4 ms // 测试从 R2 到 PC(TFTP 服务器 ) 的 IP 可达 R&S 1-8
确定 TFTP 服务器有足够的空间 FLASH RAM TFTP Server Router# show flash System flash directory: File Length Name/status 1 5848552 c2600-i-mz.122-8.t1.bin [5848616 bytes used, 10928600 available, 16777216 total] 16384K bytes of processor board System flash (Read/Write) Router# ping tftp_address...!!!!! (On the TFTP server, for example, a UNIX host) dir c2600-i-mz.122-8.t1.bin R&S 1-9
备份 IOS 到 TFTP 服务器 (Backup IOS ) FLASH RAM copy flash tftp TFTP Server Router# show flash System flash directory: File Length Name/status 1 5848552 c2600-i-mz.122-8.t1.bin [5848616 bytes used, 10928600 available, 16777216 total] 16384K bytes of processor board System flash (Read/Write) Router# copy flash tftp Source filename [c2600-i-mz.122-8.t1.bin]? Address or name of remote host []? 10.1.1.2 Destination filename [c2600-i-mz.122-8.t1.bin]?!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! Router# R&S 1-10
备份 IOS 到 TFTP 服务器的相关注释 R2#show flash: CompactFlash directory: File Length Name/status 1 41205996 c2800nm-adventerprisek9-mz.124-11.t1.bin [41206060 bytes used, 23019216 available, 64225276 total] 62720K bytes of ATA CompactFlash (Read/Write) // 先查看 flash 中的 IOS 大小, 文件名等 R2#copy flash:c2800nm-adventerprisek9-mz.124-11.t1.bin tftp: // 把 IOS 备份到 TFTP 服务器上 Address or name of remote host [ ]? 172.16.0.100 // 回答 TFTP 服务器的 IP 地址 Destination filename [c2800nm-adventerprisek9-mz.124-11.t1.bin]? // 回答文件名 默认时和源文件名是一样的, 不建议修改文件名, 因为 IOS 文件名包含了 IOS 的版本 特征等信息!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!( 此处省略 ) // 备份成功后可以在 c:\tftp-root 目录下找到该文件 R&S 1-11
从 TFTP 服务器恢复 IOS FLASH RAM copy tftp flash Router# copy tftp flash IP address or name of remote host [255.255.255.255]? 10.1.1.2 Name of tftp filename to copy into flash []? c2600-i-mz.122-8.t1.bin copy c2600-i-mz.122-8.t1.binfrom10.1.1.2 into flash memory? [confirm] <Return> xxxxxxxx bytes available for writing without erasure. erase flash before writing? [confirm] <Return> Clearing and initializing flash memory (please wait)####...## Loading from 10.1.1.2:!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!(text omitted) [OK - 324572/524212 bytes] Verifying checksum... VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV VVVVVV(text omitted) Flash verification successful. Length = 1804637, checksum = 0xA5D3 TFTP Server R&S 1-12
知识要点 2: 配置文件的流动 R&S 1-13
备份配置文件到 TFTP 服务器 running-config Network server R1#copy running-config tftp Address or name of remote host []? 10.1.1.2 Destination filename [r1-confg]?!! 691 bytes copied in 0.725 secs R2#copy running-config tftp: // 把内存中的配置文件备份到 TFTP 服务器上 Address or name of remote host [ ]? 172.16.0.100 // 回答 TFTP 服务器的 IP 地址 Destination filename [r2-confg]? // 回答文件名, 默认时为 路由器名 -confg!! 1381 bytes copied in 0.452 secs (3055 bytes/sec) // 备份成功, 共 1381 字节, 可以在 c:\tftp-root 目录下找到该文件, 是一个纯文本的文件 可以用写字板打开, 而用记事本打开则格式会出现问题 R&S 1-14
通过捕获文本的方式进行配置文件的备份 : 采用 复制 粘贴 备份配置文件 1. 可以简单地在终端窗口中, 执行 show runningconfig 命令显示当前的配置, 在终端窗口中复制全部配置, 粘贴到某文本文件中 2. 如果是在 Windows 自带的超级终端窗口中复制 粘贴配置, 会有 ---more--- 等字样, 要记得删除这些字符 R&S 1-15
从 TFTP 下载配置文件 Network server running-config R1#copy tftp running-config Address or name of remote host []? 10.1.1.2 Source filename []? r1-confg Destination filename [running-config]? Accessing tftp://10.1.1.2/r1-confg... Loading r1-confg from 10.1.1.2 (via FastEthernet0/0):! [OK - 691/1024 bytes] 691 bytes copied in 0.854 secs R&S 1-16
实验内容 2 路由器的密码恢复 ( 注 : 在实验室中进行 ) R&S 1-17
配置寄存器 (config-register) 组成 寄存器组成 :4 位 16 进制表示 :0xABCD 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 A B C D 实例 2 1 0 2 D: 启动域 C: 使得系统软件忽略 NVRAM 中的内容, 关键位为 6 该位值为 0, 当路由器启动后会从 NVRAM 里面的配置文件调到 RAM 里运行 该位值为 1, 路由器启动后会忽略 NVRAM 的配置 A: 关键位为 13, 网络启动次数 : 值为 1 5 次, 值为 0 无数次 Console 口速率设定表 12 11 速率 0 0 9600 0 1 4800 1 0 1200 1 1 2400 R&S 1-18
配置寄存器启动域 R&S 1-19
路由器密码破解步骤 R&S 1-20
实验步骤 2: 关闭路由器电源并重新开机 1. 关闭路由器电源并重新开机, 当控制台出现启动过程, 赶快按 Ctrl+Break 键中断路由器的启动过程, 进入 rommon 模式 2. rommon 1>confreg 0x2142 // 改变配置寄存器的值为 0x2142, 这会使得路由器开机时不读取 NVRAM 中的配置文件 3. rommon 2 > i // 重启路由器 路由器重启后会直接进入到 setup 配置模式, 用 Ctrl+C 或者回答 n, 退出 setup 模式 R&S 1-21
实验步骤 3: 修改密码 Router>enable Router#copy startup-config running-config Destination filename [running-config]? 661 bytes copied in 0.625 secs // 把配置文件从 NVRAM 中拷贝到 RAM 中, 在此基础上修改密码 R2#configure terminal R2(config)#enable password cisco // 以上把密码改为自己的密码, 如果还配置别的密码则一起把它们修改了 R&S 1-22
实验步骤 4: 恢复寄存器值 R2(config)#config-register 0x2102 // 以上把寄存器的值恢复为正常值 0x2102 R2(config)#exit R2#copy running-config startup-config Destination filename [startup-config]? Building configuration... [OK] R2#reload // 把路由器的各个接口一一打开, 保存配置, 重启路由器, 检查路由器是否正常 R&S 1-23
实验内容 3 路由器的 IOS 恢复 ( 注 : 在实验室中进行, 选做 ) R&S 1-24
知识要点 : 路由器查找 IOS 的详细流程 R&S 1-25
实验环境准备 : 故意删除 flash 中的 IOS R2#show flash: CompactFlash directory: File Length Name/status 1 41205996 c2800nm-adventerprisek9-mz.124-11.t1.bin [41206060 bytes used, 23019216 available, 64225276 total] 62720K bytes of ATA CompactFlash (Read/Write) // 显示 flash 中的 IOS R2#delete flash:c2800nm-adventerprisek9-mz.124-11.t1.bin Delete filename [c2800nm-adventerprisek9-mz.124-11.t1.bin]? Delete flash:c2800nm-adventerprisek9-mz.124-11.t1.bin? [confirm] // 以上是删除 flash 的 IOS, 模拟 FLASH 中的 IOS 丢失或者 IOS 升级失败 R&S 1-26
恢复 IOS 步骤 1-- 设置变量 1. 请确认 IOS 已经放在 c:\ TFTP-Root 目录下 路由器丢失了 IOS 后, 开机将自动进入 rommon 模式 2. rommon 2 > IP_ADDRESS=172.16.0.2 3. rommon 3 > IP_SUBNET_MASK=255.255.0.0 4. rommon 4 > DEFAULT_GATEWAY=172.16.0.100 5. rommon 5 > TFTP_SERVER=172.16.0.100 6. rommon 6 > TFTP_FILE=c2800nm-adventerprisek9- mz.124-11.t1.bin // 要恢复 IOS, 需要配置一些变量的值, 主要是路由器的 IP 地址 掩码等 DEFAULT_GATEWAY 胡乱地指向 TFTP 服务器 请注意变量名的大小写 R&S 1-27
恢复 IOS 步骤 2-- 下载 IOS rommon 8 > tftpdnld // 开始从 tftp 恢复 IOS IP_ADDRESS: 172.16.0.2 IP_SUBNET_MASK: 255.255.0.0 DEFAULT_GATEWAY: 172.16.0.100 TFTP_SERVER: 172.16.0.100 TFTP_FILE: c2800nm-adventerprisek9-mz.124-11.t1.bin TFTP_VERBOSE: Progress TFTP_RETRY_COUNT: 18 TFTP_TIMEOUT: 7200 TFTP_CHECKSUM: Yes TFTP_MACADDR: 00:19:55:66:63:20 GE_PORT: Gigabit Ethernet 0 GE_SPEED_MODE: Auto Invoke this command for disaster recovery only. WARNING: all existing data in all partitions on flash will be lost! Do you wish to continue? y/n: [n]: y // 回答 y 开始从 tftp 服务器上恢复 IOS, 根据 IOS 的大小, 通常需要十几分钟 R&S 1-28
恢复 IOS 步骤 13 -- 重启路由器 Receiving c2800nm-adventerprisek9-mz.124-11.t1.bin from 172.16.0.100!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ( 此处省略 )!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! File reception completed. Validating checksum. Copying file c2800nm-adventerprisek9-mz.124-11.t1.bin to flash. Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee e // 从 tftp 服务器接收了 IOS 后, 会进行校验 rommon 9 > i // 重启路由器 R&S 1-29