2.实验二、路由器的日常维护与管理(详解版)

更新时间:2024-07-05 16:27:01 阅读量: 综合文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

实验二、路由器的日常维护与管理

1、 实验目的

通过本实验可以:

1) 掌握路由接口IP地址的配置及接口的激活 2) 掌握telnet的使用及配置 3) 熟悉CDP的使用及配置

4) 了解基本的debug调试命令 5) 理解并实现设备之间的桥接 6) 绘制基本的网络拓扑图

7) 掌握数据通信的可达性测试 8) 掌握路由器的密码恢复步骤 9) 熟悉TFTP服务器的使用

10) 掌握路由器配置文件的备份与恢复

11) 掌握路由器IOS文件的备份、升级和恢复

2、 拓扑结构

路由器的日常维护与管理拓扑

3、 实验需求

1) 设置主机名,并关闭域名解析、关闭同步、关闭控制台超时 2) 使用相关命令查看当前配置信息,并保存当前的配置文件

3) 桥接PC到机架路由器,配置路由器接口的IP地址,开启接口并测试路由器与

本机的连通性,开启debug观察现象 4) 使用TFTP传送文件,分别实现拷贝路由器的配置文件到TFTP服务器和从TFTP

服务器导入配置文件到路由器

a) 将当前配置文件保存到本机,并在本机打开并修改所保存的配置文件 b) 将当前配置文件保存到同学电脑

c) 将保存在本机的配置文件导入所使用的设备 d) 将同学保存的配置文件导入所使用的设备 e) 注意观察导入配置文件时设备提示信息的变化 5) 使用TFTP备份路由器的IOS文件 6) IOS文件的升级和灾难恢复 7) 路由器的密码恢复

8) 使用CDP发现邻居设备,实现telnet远程登入到邻居设备

9) 用主机名绑定IP,实现telnet主机名与telnet IP一致的效果

10) 实现GNS3模拟器与本机之间的桥接,并将模拟器的配置文件保存到本机

4、 参考配置

1. 配置基本命令

设置主机名、关闭域名解析、同步、控制台超时 Router>enable

Router#config terminal

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#hostname r14//命名主机

r14(config)#no ip domain-lookup//关闭域名解析 r14(config)#line console 0

r14(config-line)#logging synchronous //关闭日志同步 r14(config-line)#exec-timeout 0 0//关闭控制台超时 r14(config-line)#end r14#

2.

查看当前配置信息,并保存当前的配置文件

r14#show running-config //查看当前运行的配置文件 Building configuration...

Current configuration : 420 bytes !

version 12.2

service timestamps debug uptime service timestamps log uptime no service password-encryption !

hostname r14 ! !

ip subnet-zero ! !

no ip domain-lookup !

call rsvp-sync ! ! ! ! ! !

! !

interface FastEthernet0/0 no ip address shutdown duplex auto speed auto !

ip classless ip http server ! ! !

dial-peer cor custom ! ! ! !

line con 0

exec-timeout 0 0 logging synchronous line aux 0 line vty 0 4 ! end r14#

r14#write //将配置写入NVRAM

Warning: Attempting to overwrite an NVRAM configuration previously written

by a different version of the system image.

Overwrite the previous NVRAM configuration?[confirm]//以后有出现confirm按Enter键确认即可,该处提示是否写入NVRAM? Building configuration... [OK]//说明写入NVRAM成功了

r14#copy running-config startup-config//保存当前配置文件到启动配置文件

Destination filename [started-config]? Erase flash: before copying? [confirm]

Erasing the flash filesystem will remove all files! Continue? [confirm] Erasing device... eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...erasedee Erase of flash: complete

Verifying checksum... OK (0x9885)

707 bytes copied in 1.352 secs (523 bytes/sec) r14#

【思考1】write跟copy running-config startup-config这两条命令的执行的结果相同么?

3.

桥接PC到机架路由器

(1) 到机房,用一根直连线来连接需要桥接的路由器和我们PC所在网络的交换机。 (2) 在路由器上配置接口的IP地址,开启接口,并测试路由器与本机的连通性

r14(config)#interface e0

r14(config-if)#ip add 172.16.16.14 255.255.0.0 //配置接口地址,必须与本机地址配置在同一网段 r14(config-if)#no shutdown r14(config-if)#end r14#debug ip icmp

ICMP packet debugging is on 【说明】路由器上的配置

C:\\Users\\Liyandi>ping 172.16.16.14 正在 Ping 172.16.16.14 具有 32 字节的数据:

来自 172.16.16.14 的回复: 字节=32 时间=10ms TTL=255 来自 172.16.16.14 的回复: 字节=32 时间=33ms TTL=255 来自 172.16.16.14 的回复: 字节=32 时间=160ms TTL=255 来自 172.16.16.14 的回复: 字节=32 时间=88ms TTL=255 172.16.16.14 的 Ping 统计信息:

数据包: 已发送 = 4,已接收 = 4,丢失 = 0 (0% 丢失), 往返行程的估计时间(以毫秒为单位): 最短 = 10ms,最长 = 160ms,平均 = 72ms 【说明】PC机上测试与路由器的连通性 r14(config)#

00:50:40: ICMP: echo reply sent, src 172.16.16.14, dst 172.16.10.108

//向172.16.10.108(我的PC的ip地址)发送应答包 r14(config)#

00:50:41: ICMP: echo reply sent, src 172.16.16.14, dst 172.16.10.108 r14(config)#

00:50:42: ICMP: echo reply sent, src 172.16.16.14, dst 172.16.10.108 00:50:43: ICMP: echo reply sent, src 172.16.16.14, dst 172.16.10.108 r14(config)#

【说明】路由器上的debug信息 r14#ping 172.16.10.108

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.10.108, timeout is 2 seconds: !!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/22/36 ms r14#

00:55:47: ICMP: echo reply rcvd, src 172.16.10.108, dst 172.16.16.14 00:55:47: ICMP: echo reply rcvd, src 172.16.10.108, dst 172.16.16.14 00:55:47: ICMP: echo reply rcvd, src 172.16.10.108, dst 172.16.16.14 00:55:47: ICMP: echo reply rcvd, src 172.16.10.108, dst 172.16.16.14 00:55:47: ICMP: echo reply rcvd, src 172.16.10.108, dst 172.16.16.14 r14#

【说明】路由器上的debug信息 【思考2】高亮部分的意思?

【说明】桥接可以简单的理解为实现PC与路由器之间可以直接使用以太网进行通信,桥接在以后的学习过程中会经常用到,一定要掌握!

4.

使用TFTP软件传送文件

(1) 安装TFTP软件

使用Cisco TFTP Server,这里使用下载好的Cisco TFTP Server绿色汉化版,解压后双击TFTPServer.exe运行程序,效果如图所示:

【说明】使用TFTP服务器的时候,只要把TFTP软件打开就行了,这里要特别要注意下,TFTP软件打开后不能关闭!如果关闭就没办法使用了。 (2) 将当前配置文件保存到本机

r14#copy running-config tftp:

Address or name of remote host []? 172.16.10.108 Destination filename [r14-confg]? !!

434 bytes copied in 10.056 secs (43 bytes/sec) r14#

【说明】高亮显示分别是保存当前配置文件到TFTP服务器,输入TFTP服务器的IP地址,是否对保存的配置文件进行重命名(这里使用默认的名字),你可以对它进行重命名也可以按默认方式保存,两个”!”号说明已经成功保存配置文件,也可以通过TFTP服务器显示来查看是否保存成功,如下图:

(3) 打开并修改所保存的配置文件

在TFTP的接收文件的文件夹下,可以使用windows自带的记事本程序打开配置文件,如图所示:

然后可以手动修改配置文件,并保存,这里我们将配置文件中路由器的命名由原来的r14修改成rr14以示区别之前的配置文件。 (4) 将当前配置文件保存到同学的PC上

操作很简单,这里不进行示范了,只需在配置时将TFTP主机的地址改成同学的地址就可以了,其他操作不变。 (5) 将保存在本机的配置导入所使用的设备

r14#copy tftp: running-config

Address or name of remote host []? 172.16.10.108 ? ?Invalid host address or name

%Error parsing filename (Bad file number) r14#copy tftp: running-config

Address or name of remote host []? 172.16.10.108 Source filename []? r14-confg

Destination filename [running-config]?

Accessing tftp://172.16.10.108/r14-confg...

Loading r14-confg from 172.16.10.108 (via Ethernet0): ! [OK - 435 bytes]

435 bytes copied in 5.476 secs (79 bytes/sec) rr14#

01:38:51: %SYS-5-CONFIG_I: Configured from tftp://172.16.10.108/r14-confg by console rr14#

【说明】高亮部分说明配置文件传送成功,高亮红色部分,说明配置文件成功覆盖并且生效了。

(6) 将同学保存的配置文件导入所使用的设备

这个就不用再操作了吧,相信大家都会操作了。这里就不浪费笔墨进行描述了。

【思考3】保存跟导入配置文件在实际工程项目中有什么应用吗?

5.

使用TFTP备份路由器的IOS文件

rr14#show flash //查看flash

System flash directory: File Length Name/status 1 15989548 c2501-3.bin

[15989612 bytes used, 787600 available, 16777212 total] 16384K bytes of processor board System flash (Read ONLY) rr14#copy flash tftp:

Source filename []? c2501-3.bin

Address or name of remote host []? 172.16.10.108 Destination filename [c2501-3.bin]?

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!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14#

6.

IOS文件的升级

【技术要点】在升级IOS之前要先备份IOS,以防止IOS升级失败,无论是备份还是升级都要确保你的电脑和你要升级的路由器能正常通信。

在升级IOS之前我们还是来查看下IOS的相关信息。 room-four#show flash: System flash directory: File Length Name/status 1 15989548 c2501-3.bin

[15989612 bytes used, 787600 available, 16777212 total] 16384K bytes of processor board System flash (Read ONLY) 【说明】这个flash显示read only。 在看下另外一台路由器的show flash输出: Router#sh flash System flash directory: File Length Name/status

3 50938004 c2800nm-advipservicesk9-mz.124-15.T1.bin [51193823 bytes used, 12822561 available, 64016384 total] 63488K bytes of processor board System flash (Read/Write) 【说明】这个flash显示read/write。

【思考4】read only与read/write分别代表什么意思?flash显示为read only或read/write意味着什么?

【技术要点】Cisco2500路由器比较特殊,flash内的IOS默认是只读属性,需要用命令config-register 0x2141将寄存器值改成0x2141.

【思考5】比较路由器的寄存器值0x2142与0x2141?两个寄存器值分别有什么含义?

【说明】这里简述下思科2500路由器的升级,简要操作如下: Router(config)#config-register 0x2141 //修改配置寄存器值 Router#reload

//重新启动路由器后,修改的配置寄存器值才会生效 Router(boot)#copy tftp flash

//注意,将路由器的寄存器值改成0x2141后,提示符变成了”router(boot)#”

Address or name of remote host []? 192.168.1.99 Source file name? c2500.31.bin Destination file name [c2500.31.bin]?

Accessing file 'c2500.31.bin' on 192.168.1.99...

Loading c2500.31.bin from 192.168.1.99 (via Ethernet0): ! [OK] Erase flash device before writing? [confirm]

Flash contains files. Are you sure you want to erase? [confirm] Copy 'c2500.31.bin' from server

as 'c2500.31.bin' into Flash WITH erase? [yes/no]y Erasing device...

eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee ...erased

Loading c2500.31.bin from 192.168.1.99 (via

Ethernet0): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

[OK - 15989548/16777216 bytes] Verifying checksum... OK (0x6725) Flash copy took 0:09:14 [hh:mm:ss] Router(boot)#conf t

Router(boot)(config)#config-register 0x2142 【技术要点】升级完记得要把配置寄存器值修改回来。

【说明】针对2600系列之后的路由器可以不用修改配置寄存器值,其flash的默认属性就是read/write。

【技术要点】在升级ios时要注意:

1) 确保flash的属性是read/write,如果不是要对其进行修改; 2) 确保flash有足够的空间;

【思考6】能否将路由器3640系列的IOS升级到2600系列的路由器?为什么?

【技术要点】IOS的升级除了可以使用TFTP方式升级外,还可以使用如FTP等其他方式升级,不管采用FTP还是TFTP或者其他方式升级,都要建立并确保服务器与路由器之间的连通性。

【技术要点】思科TFTP服务器存在一定的缺陷,在升级较大IOS文件时容易出错,更建议使用3COM公司的”3CDaemon”。

【技术要点】升级有两种方式,分为本地升级和对远程设备的升级。 【技术要点】升级只能针对同一硬件平台的设备升级,比如不能将3600平台的IOS升级到2500的平台。

【技术要点】如果工作中不慎误删IOS,千万不要将路由器关机,可以直接使用”copy tftp flash”命令从TFTP服务器恢复IOS。

【思考7】如果因为路由器硬件,软件bug或者人为恶意或者误删除IOS导致了灾难性的后果,设备根本无法正常引导,该怎么办?

【思考8】如果升级IOS的过程中严重丢包,那么升级完后的IOS还可以正常使用吗?

7. IOS的灾难恢复

(1) 不小心删除了flash

rr14#delete flash:c2501-3.bin Delete filename [c2501-3.bin]?

Delete flash:c2501-3.bin? [confirm]^[ Delete of flash:c2501-3.bin aborted! rr14# 【说明】删除flash后,千万不要重启,直接将路由器桥接到我们的PC,将路由器的IOS导入到路由器就可以了,步骤跟备份IOS的步骤类似,如果重启了路由器,只能进行IOS的灾难恢复。

(2) IOS灾难恢复

【说明】有时因为路由器硬件,软件bug或者人为原因误删了IOS文件,导致路由器根本无法正常引导,我们一般会使用接下来介绍的两种IOS灾难恢复的方式:

【说明】设备无法正常引导的情况下会进入”rommon>”模式。

【警告】不要随意删除中心机房的路由器的IOS文件!否则后果自负!!!

1) Xmodem方式恢复

在终端界面按照如下步骤进行: 3600 / 2600 in rommon

1- rommon > b ---------- to boot first image in flash mem

2- rommon > dir flash: ---------- list the files on the device 3- rommon > meminfo ---------- to see memory information You are in rommon and

1- when \ 2- dir flash: reveals an invalid check sum.

3- So the last solution is to download an image using xmodem When in ROMMON mode, follow the procedure below Using the ROMMON confreg

utility.

rommon 2 > confreg //修改相关参数

do you wish to change the configuration? y/n [n]: y enable \

enable \ disable \ enable \ enable \

enable \

change console baud rate? y/n [n]: y //修改波特率

enter rate: 0 = 9600, 1 = 4800, 2 = 1200, 3 = 2400 4 = 19200, 5 = 38400, 6 = 57600, 7 = 115200 [7]: 7 change the boot characteristics? y/n [n]: y enter to boot: 0 = ROM Monitor

1 = the boot helper image 2-15 = boot system [0]: 0

Configuration Summary enabled are:

load rom after netboot fails console baud: 115200 boot: the ROM Monitor

do you wish to change the configuration? y/n [n]: n

You must reset or power cycle for new config to take effect rommom 2 > reset

The next step is to open a new hyperterminal with settings as follows,

Bits per second - 115200 Data bits - 8 Parity - None Stop bits - 1

Flow control - Hardware

After setting the hyperterminal you get a rommon prompt, and type the

xmodem command. Before typing an xmodem command there should be a software image

residing in your terminal or your local C drive.

rommon 2 > xmodem -c c3640-i-mz.121-7.bin //使用xmode向设备加载IOS文件

Do not start the sending program yet... File size Checksum File name

4936800 bytes (0x4b5460) 0x2dd7 c3640-i-mz.121-7.bin (bad checksum: 0x13eb)

WARNING: All existing data in flash will be lost! Invoke this application only for disaster recovery. Do you wish to continue? y/n [n]: y

Ready to receive file c3640-i-mz.121-7.bin ...

After the above message appears u have to download the file using

xmodem,

the procedure is as follows,

1) Go to Hyperterminal, click Transfer 2) Click on send file

3) click on browse -------- look for the file name in your local \

drive

4) Below filename field is Protocol ------- change it to xmodem 5) And then clik on send After some time the router will reload itself and will ask you \ return to get stated\ Router> en Router#conf t

Enter configuration commands, one per line. End with CNTL/Z. Router(config)#conf t

Router(config)#config-register 0x2102 Router(config)#line con 0

Router(config-line)# speed 9600 --------- Change the speed of the

console port to 9600

//将波特率改回默认值9600

Then go to Hyperterminal and change baud rate to 9600 in your terminal.

Router(config-line)#ctrl z

Router #write mem //保存配置

Router #reload

【说明】使用Xmode方式是通过console线进行的升级方式,但使用console口方式升级速度很慢,很少有人采用,接下来介绍一种工作中更常用的方式。

2) TFTP广播升级方式恢复

准备工作,用网线将本机与要恢复IOS文件的路由器的以太网接口连在一起,将要恢复的IOS文件放在TFTP根目录下,然后打开TFTP服务器,打开丢失IOS文件的路由器,待路由器进入rommon模式后,进行如下操作: rommon 2 > IP_ADDRESS=192.168.1.88

rommon 3 > IP_SUBNET_MASK=255.255.255.0 rommon 4 > DEFAULT_GATEWAY=192.168.1.99 rommon 5 > TFTP_SERVER=192.168.1.99 rommon 6 > TFTP_FILE=C2600.bin //要恢复IOS,需要配置一些变量的值,即路由器的ip地址、掩码、网关、TFTP服务器的地址及要升级的IOS文件,注意变量名都是大写的。 rommon 8 > tftpdnld //开始从tftp 恢复IOS IP_ADDRESS: 192.168.1.88

IP_SUBNET_MASK: 255.255.255.0

DEFAULT_GATEWAY: 192.168.1.99 TFTP_SERVER: 192.168.1.99

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 的大小,通常需要十几分钟

Receiving C2600.bin from192.168.1.99 !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! (此处省略)

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! File reception completed.

Copying file C2600.bin to flash. Erasing flash at 0x60fc0000

Program flash location 0x60f30000 rommon 9 > i //重启路由器

8.

路由器的密码恢复

(1) 步骤1:在路由器上配置密码并保存配置文件

room-five(config)#enable secret qwertyuioasdfghddssf1234 room-five(config)#exit

room-five#copy running-config startup-config Destination filename [startup-config]? Building configuration... [OK] room-five#

【说明】故意配置一个自己也记不住的密码并保存,以供密码恢复使用 【思考9】回顾下路由器的启动顺序?

【思考10】比较running-config与startup-config的区别?

(2) 步骤2:路由器密码恢复

关闭路由器电源并重新开机,在开机的30秒内按住ctrl+break键中断路由器的启动过程,进入rommon>模式,如下:

System Bootstrap, Version 12.4(1r) [hqluong 1r], RELEASE SOFTWARE (fc1) Copyright (c) 2005 by cisco Systems, Inc.

Initializing memory for ECC

C2601 processor with 262144 Kbytes of main memory Main memory is configured to 64 bit mode with ECC enabled Readonly ROMMON initialized rommon 1>confreg 0x2142

//修改配置寄存器的值为0x2142,使路由器开机时不读取NVRAM 中的配置文件。

rommon 2 > reset

//重启路由器,路由器重启后会直接进入到setup配置模式

【技术要点】在cisco2500系列之前的路由器中,可以在rommon>提示符下输入o/r 0x2142和I分别修改配置寄存器值和重启路由器,这与在2600系列之后上面的修改寄存器值存在区别。 在setup模式输入no,进入如下: Router>enable

Router#copy startup-config running-config Destination filename [running-config]?

1071 bytes copied in 2.376 secs (451 bytes/sec) //将配置文件从NVRAM中拷贝到RAM中 room-five #configure terminal

room-five (config)#enable password cisco //修改密码

room-five (config)#config-register 0x2102 //将寄存器的值该为正常的0x2102 room-five (config)#exit

room-five#copy running-config startup-config //最后保存下

Destination filename [startup-config]? Building configuration... [OK] room-five#

【思考11】理解0x2102与0x2142的含义?

【技术要点】密码恢复的核心思想在于理解路由器的的启动顺序,以及对配置

寄存器值0x2102和0x2142的理解

9. CDP的使用及debug调试命令的使用

(1) CDP的使用

【思考12】CDP的含义及CDP的用途? 让我们看下CDP的一些配置信息 room-three#show cdp Global CDP information:

Sending CDP packets every 60 seconds Sending a holdtime value of 180 seconds Sending CDPv2 advertisements is enabled

//CDP默认是运行的,每60秒发送一次,holdtime是180秒 【思考13】holdtime 180秒的含义?

room-three#show cdp interface

FastEthernet0/0 is administratively down, line protocol is down Encapsulation ARPA

Sending CDP packets every 60 seconds Holdtime is 180 seconds

Serial1/0 is administratively down, line protocol is down Encapsulation HDLC

Sending CDP packets every 60 seconds Holdtime is 180 seconds

【说明】show cdp interface可以显示哪些接口运行CDP协议

Room-three#show cdp neighbors

【说明】show cdp neighbors可以查看邻居的信息

1) Device ID:表示邻居设备的主机名,图示的连接邻居是room-four; 2) Local interface:表明自身的哪个接口跟邻居连接,图示是serial1/1 3) Holdtme:接收到邻居发送的CDP消息,采用倒计时,图示是168 4) Capability:表明邻居是说明设备,图示邻居设备是路由器; 5) Platform:表明邻居的硬件平台,图示邻居是3640;

6) Port ID:指明自身连接对方的接口,图示是serial1/1口;

room-three#show cdp neighbors detail ------------------------- Device ID: room-four Entry address(es): IP address: 12.1.1.2

Platform: Cisco 3640, Capabilities: Router Switch IGMP

Interface: Serial1/1, Port ID (outgoing port): Serial1/1 Holdtime : 164 sec

Version :

Cisco IOS Software, 3600 Software (C3640-IK9O3S-M), Version 12.4(10), RELEASE SOFTWARE (fc1)

Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2006 by Cisco Systems, Inc. Compiled Wed 16-Aug-06 04:04 by prod_rel_team

advertisement version: 2 VTP Management Domain: ''

room-three#

【说明】show cdp neighbor detail可以查看邻居设备的详细信息。

room-three(config)#int f0/0

room-three(config-if)#no cdp enable

//在f0/0接口上关闭CDP,其他接口还运行CDP(接口性关闭) room-three(config-if)#exit room-three(config)#no cdp run

//在整个路由器上关闭CDP(全局性关闭) room-three(config)#

【思考14】CDP可以发现直连邻居以外的设备吗?

【思考15】一台思科路由器和一台思考交换机之间接入一台华为交换机,那么在思科路由器上能否用CDP发现另外一台思科交换机? 【思考16】在接口开启但没配置IP地址的情况下,能用CDP发现直连邻居吗?请通过实验验证。

【思考17】四台思科设备连在一起,在未知它们如何连接的情况下,能否用CDP找出它们之间是怎么连接的?如果能给出你的思路?如果条件允许请在真实设备上调试。

(2) debug调试命令的使用

在room-three路由器上开启debug: room-three#debug ip packet IP packet debugging is on room-three#

远程登入到room-three观察现象,如下显示: room-three#

*Mar 1 02:12:31.067: IP: tableid=0, s=12.1.1.2 (Serial1/1), d=12.1.1.1 (Serial1/1), routed via RIB

*Mar 1 02:12:31.071: IP: s=12.1.1.2 (Serial1/1), d=12.1.1.1 (Serial1/1), len 44, rcvd 3

*Mar 1 02:12:31.079: IP: tableid=0, s=12.1.1.1 (local), d=12.1.1.2 (Serial1/1), routed via FIB

*Mar 1 02:12:31.083: IP: s=12.1.1.1 (local), d=12.1.1.2 (Serial1/1), len 44, sending

【说明】通过debug我们可以对网络产生的数据包进行分析,在实验环境下,通过debug命令的输出对我们分析解决网络故障是非常有帮助的。上述的提示信息说明了什么呢?

room-three#undebug all

All possible debugging has been turned off room-three#

【说明】debug开启后要记得关闭,基于debug命令产生的大量数据输出,我们在现网中一般不会也不能随便开debug命令,建议在实验环境下要尝试解读debug命令的输出,对我们进一步学习是非常有帮助的。

10. 实现本机telnet到模拟器

(1) 配置telnet密码

room-three(config)#line vty 0 4

//进入路由器的VTY虚拟终端下,”vty 0 4”表示vty 0到vty 4,共5个虚拟终端,即最多只允许同时打开5个虚拟终端线路 room-three(config-line)#password yucedu //以上是配置vty密码,即telnet密码 room-three(config-line)#login

//与配置console密码类似,启用密码验证 room-three(config-line)#exit room-three(config)#

(2) 在本机通过telnet访问路由器

在CMD窗口界面下,输入telnet 路由器的IP地址即可,如图:

【思考18】telnet是基于TCP还是UDP实现的?

【思考19】telnet密码是以明文还是以密文在网络中传输的?如何验证?

11. 用主机名绑定IP

room-four(config)#ip host room-three 12.1.1.1 //将主机名room-three与ip地址12.1.1.1进行绑定 room-four(config)#exit room-four#telnet 12.1.1.1 Trying 12.1.1.1 ... Open

User Access Verification Password: ??

room-four#telnet room-three

Trying room-three (12.1.1.1)... Open User Access Verification Password: ??

【思考20】三台路由器R1、R2、R3,只在R1上设置主机名绑定,R2和R3可以直接使用R1上的主机名绑定条目进行远程登录吗?为什么? 12. 实现GNS3模拟器与本机之间的桥接

(1) 打开GNS3

(2) 拖一台路由器跟主机到界面 (3) 配置路由器跟主机

【说明】路由器的接口配置

【说明】PC的接口配置

【技术要点】要添加一个本机已经配置了IP地址的接口 R1(config)#int f0/0

R1(config-if)#ip add 172.16.16.15 255.255.0.0 R1(config-if)#no sh R1(config-if)#end

00:00:35: %SYS-5-CONFIG_I: Configured from console by console

00:00:36: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up

00:00:37: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up R1#ping 172.16.10.108

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 172.16.10.108, timeout is 2 seconds: .!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 8/11/16 ms R1#

【思考21】能不能将PC与R1的serial接口做桥接?为什么?请通过实验验证。

5、 实验回放

1) 是否实现本机桥接到模拟器? 2) 是否掌握PC与机架设备的桥接?

3) 是否实现配置路由器的ip地址,并实现主机可以ping通路由器? 4) 是否掌握telnet的使用及配置?

5) 是否实现本机远程登入到路由器?

6) 是否实现使用debug命令调试网络信息? 7) 是否掌握CDP命令的使用?

8) 是否理解路由器的开机过程?

9) 是否理解路由器的配置寄存器值0x2102和0x2142的作用? 10) 是否熟悉路由器密码恢复的步骤?

11) 是否成功进行并实现路由器的密码恢复? 12) 是否实现本机与路由器之间的互ping? 13) 是否掌握TFTP服务器的使用?

14) 是否实现拷贝配置文件到TFTP服务器? 15) 是否实现导入配置文件到路由器?

16) 是否实现备份IOS文件到TFTP服务器? 17) 是否实现IOS文件的恢复和升级? 18) 是否理解IOS文件灾难恢复的方法?

本文来源:https://www.bwwdw.com/article/gae.html

Top