CCNA实验手册 下载本文

内容发布更新时间 : 2024/5/22 16:22:19星期一 下面是文章的全部内容请认真阅读。

180 秒 Serial0/0 is administratively down, line protocol is down Encapsulation HDLC Sending CDP packets every 60 seconds Holdtime is 180 seconds Serial0/1 is administratively down, line protocol is down

百思学网络,领先科技 -16- HTTP://WWW.BESTXUE.CN

Encapsulation HDLC Sending CDP packets every 60 seconds Holdtime is 180 seconds

以上通过 show cdp interface 发现 R1 有 E0/0 , S0/0 , S0/1 共 3 个接口打开了 CDP 协议. R1#show cdp neighbors //显示 CDP 邻居 Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater Device ID Local Intrfce Holdtme Capability Platform Port ID SW1 Eth 0/0 171 S I WS-C2950 0/1 设备名字 本地接口 保持时间 Switch IGMP 型号 对端接口 R1#show cdp entry * //显示所有邻居详细信息,包括对方接口 IP 地址和 IOS 软件版本------------------------- Device ID: SW1 Entry address(es):IP address: 11.1.1.2 Platform: cisco WS-C2950-24, Capabilities: Switch IGMP Interface: Ethernet0/0, Port ID (outgoing port): FastEthernet0/1 Holdtime : 163 sec Version : Cisco Internetwork Operating System Software IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA10a, RELEASE SOFTWARE (fc2) Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Tue 24-Jul-07 17:37 by antonino R1#show cdp traffic //显示 CDP 包,出和进入的包数量 CDP

counters : Total packets output: 12, Input: 11 Hdr syntax: 0, Chksum error: 0, Encaps failed: 0 No memory: 0, Invalid packet: 0, Fragmented: 0 CDP version 1 advertisements output: 0, Input: 0 CDP version 2 advertisements output: 12, Input: 11 2. 在 SW1 上验证 CDP SW1#show cdp ? entry Information for specific neighbor entry interface CDP interface status and configuration neighbors CDP neighbor entries traffic CDP statistics | Output modifiers SW1#show cdp interface FastEthernet0/1 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60

seconds Holdtime is 180 seconds FastEthernet0/2 is down, line protocol is down Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds FastEthernet0/3 is down, line protocol is down Encapsulation ARPA

百思学网络,领先科技 -17- HTTP://WWW.BESTXUE.CN

Sending CDP packets every 60 seconds Holdtime is 180 seconds …… ……… SW1#show cdp neighbors Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I - IGMP, r - Repeater, P – Phone Device ID Local Intrfce Holdtme Capability Platform Port ID SW2 Fas 0/24 143 S I WS-C2950-2Fas 0/24 SW2 Fas 0/23 143 S I WS-C2950-2Fas 0/23 R1 Fas 0/1 176 R S I 2610 Eth 0/0 SW1#show cdp entry * Device ID: SW2 Entry address(es): IP address: 11.1.1.3 Platform: cisco WS-C2950-24, Capabilities: Switch IGMP Interface: FastEthernet0/24, Port ID (outgoing port): FastEthernet0/24 Holdtime : 129 sec Version : Cisco Internetwork Operating System Software IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version

12.1(22)EA10a, RELEASE SOFTWARE (fc2) Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Tue 24-Jul-07 17:37 by antonino------------------------- Device ID: SW2 Entry address(es): IP address: 11.1.1.3 Platform: cisco WS-C2950-24, Capabilities: Switch IGMP Interface:

FastEthernet0/23, Port ID (outgoing port): FastEthernet0/23 Holdtime : 128 sec Version : Cisco Internetwork Operating System Software

IOS (tm) C2950 Software (C2950-I6K2L2Q4-M), Version 12.1(22)EA10a, RELEASE SOFTWARE (fc2) Copyright (c) 1986-2007 by cisco Systems, Inc. Compiled Tue 24-Jul-07 17:37 by antonino Device ID: R1 Entry address(es): IP address: 11.1.1.1 Platform: Cisco 2600, Capabilities: Router Switch IGMP Interface: FastEthernet0/1, Port ID (outgoing port): Ethernet0/0 Holdtime : 160 sec Version : Cisco IOS Software, 3600 Software (C2600-JK9O3S-M), Version 12.4(5), RELEASE SOFTWARE (fc3) Technical Support: http://www.cisco.com/techsupport Copyright (c) 1986-2005 by Cisco Systems, Inc. Compiled Mon 31-Oct-05 21:24 by alnguyen SW1#show cdp traffic CDP

counters : Total packets output: 223, Input: 200 Hdr syntax: 0, Chksum error: 0, Encaps failed: 0 No memory: 0, Invalid packet: 0, Fragmented: 0 CDP version 1 advertisements output: 0, Input: 0 CDP version 2 advertisements output: 223, Input: 200 3. 在 SW2 上验证 CDP SW2#show cdp neighbors

百思学网络,领先科技 -18- HTTP://WWW.BESTXUE.CN

Capability Codes: R - Router, T - Trans Bridge, B - Source Route Bridge S - Switch, H - Host, I -

IGMP, r - Repeater, P - Phone Device ID Local Intrfce Holdtme Capability Platform Port ID SW1 Fas 0/24 165 S I WS-C2950-2Fas 0/24 SW1 Fas 0/23 165 S I WS-C2950-2Fas 0/23 SW2# 4. 改变 CDP 发包(sending)周期和保持(holdtime)时间 1. 默认时间为: R1#show cdp interface Ethernet0/0 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds 2. 改变 CDP 发包和保持时间 R1(config)#cdp timer 5 //周期为 5 秒 R1(config)#cdp holdtime 15 //保持时间为 15 秒 R1#show cdp interface Ethernet0/0 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 5 seconds Holdtime is 15 seconds 3. 关闭 CDP R1(config)#no cdp run //全局关闭 CDP(意味着所有接口关闭了 CDP 协议) R1(config)#end

R1#show cdp interface % CDP is not enabled R1# 在全局上启用了 cdp run 后可以在指定接口关闭 CDP 协议. R1(config)#cdp run R1(config)#int e0/0 R1(config-if)#no cdp enable //在接口模式关闭 CDP R1(config-if)#end R1#show cdp interface //在接口 E0/0 关闭了 CDP 后没有发现 E0/0 接口相关参数 Serial0/0 is administratively down, line protocol is down Encapsulation HDLC

Sending CDP packets every 5 seconds Holdtime is 15 seconds Serial0/1 is administratively down, line protocol is down Encapsulation HDLC Sending CDP packets every 5 seconds Holdtime is 15 seconds 百思学网络,领先科技 -19- HTTP://WWW.BESTXUE.CN

实验6. 学会使用 Ping、Traceroute、Telnet、SSH (测试和网络连接的小工具) 功能描述:

??使用 Ping 命令是用于检测网络设备可达性,它使用 ICMP 有 echo 信息来决定远程设备是否可 用,与远程主机通信来回的延迟 delay,或是数据包的丢失情况. ??使用 Traceroute 跟踪从源到目的地所经过的路径。 ??使得 telnet , ssh (Secure Shell)远程控制设备.

1. 使用 PING 命令 注:本实验使用 R1,R2,R3,SW1 四台设备测试,配置好 R1,R2,R3,SW1 的 IP 地址,检查接口状 态为 up 后再测试。 在 R1 上测试到 R2,R3 的连通性 R1#ping 12.1.1.2 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 12.1.1.2, timeout is 2 seconds: !!!!! //5 个!表明网络是通的 Success rate is 100 percent (5/5), round-trip

min/avg/max = 4/4/8 ms R1#ping 13.1.1.3 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 13.1.1.3, timeout is 2 seconds: !!!!! //5 个!表明网络是通的 Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms

配置SW1的IP和网关 Interface vlan 1 Ip address 11.1.1.2 255.255.255.0 No shutdown Ip default-gateway 11.1.1.1 配置SW2的IP和网关 Interface vlan 1 Ip address 11.1.1.3 255.255.255.0 No shutdown Ip default-gateway 11.1.1.1

R1#

百思学网络,领先科技 -20- HTTP://WWW.BESTXUE.CN

在 SW1 上检查到 R1 的连通性: SW1#ping 11.1.1.1 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to 11.1.1.1, timeout is 2 seconds: !!!!! //5 个!表明网络是通的 Success rate is 100 percent (5/5), round-trip min/avg/max = 4/4/8 ms SW1# 通常在路由器或是交换机里使用 ping 命令时常碰到的问题。 ? 叹号(!):表示成功收到响应信息. ? 句号(.):表示在等待应答超时. ? U:表示目标主机不可达. ? Q:表示目标主机繁忙. ? M:代表不能分片

(fragment). ? ?:表示未知数据包类型. ? & :表示数据包已没有生存期(lifetime) 2.使用 traceroute 命令,检查从源到目的地经过的路由器的个数.(或是数据包经过的路径) 注:本实验先确认 R2 到 33.1.1.3 是否有路由,和 R3 是否有到 12.1.1.2 的路由,可以用 show ip route 命令 检查,如果没有,分别在 R1,R2,R3 上配置路由: R1: ip route 33.1.1.0 255.255.255.0 13.1.1.3 R2: ip route 0.0.0.0 0.0.0.0 12.1.1.1 R3: ip route 0.0.0.0 0.0.0.0 13.1.1.1 在 R2 上使用 traceroute 命令〆 R2#traceroute 33.1.1.3 Type escape sequence to abort. Tracing the route to

33.1.1.3 1 12.1.1.1 4 msec 4 msec 4 msec 2 13.1.1.3 4 msec 4 msec * 从以上可以看出从 R2 到达

33.1.1.3 经过了 12.1.1.1 和 13.1.1.3 两个路由器 3〃在 PC 上是使用的是 tracert 命令(路由器或是交换机使用的是 traceroute): 例如:跟踪从 PC 到厦门电信 DNS(202.101.103.55)所经过的路径(所经过的路由器个数,相应 IP 地址) 百思学网络,领先科技 -21- HTTP://WWW.BESTXUE.CN 二、使用 telnet 远程控制远端设备,(包括路由器或是交换机或是防火墙等网络设备)。 Telnet 是基于 TCP 协议上的,端口号为 23

实验目的:通过控制 R1 后 , TELNET 到 R2(12.1.1.2),R3(13.1.1.3)对 R2,R3 进行远程管理. 在 R1 上配置: R1#telnet 12.1.1.2 //从 R1 TELNET 到 R2 Trying 12.1.1.2 ... Open User Access Verification Password: R2> 按 + x 把界面切换回 R1 R1#telnet 13.1.1.3 //从 R1 TELNET 到 R3 Trying 13.1.1.3 ... Open User Access Verification Password: R3> 按

x 把界面切换回 R1 R1#show sessions //在 R1 上查看打开了多少个 TELNET 会话 Conn Host Address Byte Idle Conn Name

配置SW1的IP和网关 Interface vlan 1 Ip address 11.1.1.2 255.255.255.0 No shutdown Ip default-gateway 11.1.1.1 配置SW2的IP和网关 Interface vlan 1 Ip address 11.1.1.3 255.255.255.0 No shutdown Ip default-gateway 11.1.1.1

1 12.1.1.2 12.1.1.2 0 0 12.1.1.2 * 2 13.1.1.3 13.1.1.3 0 0 13.1.1.3

R1#resume 2 //重新连接到 R3 [Resuming connection 2 to 13.1.1.3 ... ] R3>

百思学网络,领先科技 -22- HTTP://WWW.BESTXUE.CN

R1#按x 切换回 R1 R1#show session Conn Host Address Byte Idle Conn Name 1 12.1.1.2 12.1.1.2 6 10 12.1.1.2 * 2 13.1.1.3 13.1.1.3 0 0 13.1.1.3

R1#disconnect 1 //从 R1 是主动断开到 R2 的连接(断开一个 TELNET 的会话) Closing connection to 12.1.1.2 [confirm] 在 R2 上实验: R2#show users //在 R2 上查看有谁登录到 R2 路由器 Line User Host(s) Idle Location

* 0 con 0 idle 00:00:00 2 vty 0 idle 00:01:52 12.1.1.1

Interface User Mode Idle Peer Address R2#clear line 2 //发现有人 TELNET 过来,把连接清除 [confirm] [OK] R2#show users Line User Host(s) Idle Location * 0 con 0 idle 00:00:00 Interface User Mode Idle Peer Address 提示:利用 TELNET 来管理的几条命令的区别. show session //查看本路由器或是交换机主动打开了多少个 telnet 的会话 show user //查看本路由器或是交换机有谁 telnet 进来,可以显示他的 IP 地址 Disconnect //在本路由器上主动断开本路由器所打开的 telnet 会话 Clear line //清除远端连接,发现有 TELNET 的会话,把他清除 Ctrl+shift+6 x //telnet 会话的切换 Resume+会话 ID //重新再次连接,先 show session 查看会话 ID 一、 使用 SSH 远程控制远端设备,(包括路由器或是交换机或是防火墙等网络设备)。 注:SSH 是基于 TCP 协议上的,端口号为 22 配置步骤(SSH Server): 1. Configure the IP domain name 2. Generate the RSA keys 3. Configure the SSH timeout interval <可选> 4. Configure the SSH retries <可选> 5. Disable vty inbound Telnet sessions 6. Enable vty inbound SSH sessions 例子: R1#configure terminal R1(config)#ip domain-name

cisco.com R1(config)#crypto key generate rsa general-keys modulus 512 R1(config)#ip ssh timeout 120 R1(config)#ip ssh authentication-retries 4 R1(config)#username cisco password cisco

百思学网络,领先科技 -23- HTTP://WWW.BESTXUE.CN

R1(config)#line vty 0 4 R1(config-line)#transport input none R1(config-line)#transport input ssh R1(config-line)#login local R1(config-line)#end 配置步骤(SSH Client): 以 secure CRT 为例: 在提示中输入用户名 cisco 密码 cisco 即可远程控制. 注:用 SSH 代替 TELNET 的好处,SSH 的会话过程是加密的,而 TELNET 的会话过程是明文 百思学网络,领先科技 -24- HTTP://WWW.BESTXUE.CN

实验7. CISCO 路由器,交换机密码恢复 一、CISCO 常用几条命令〆 ? show

version 检查配置寄存器的值,硬件配置,IOS 版本 ? show flash 检查 Flash 中的 IOS,或是 flash 大小,使用情况(占用多少,剩下多少) ? show startup-config 检查 NVRAM 中的启动配置文件(已保存后的配置) ? show running-config 检查 RAM 中的文件(当前所运行的配置) 二、路由器密码的恢复 2600 系列路由器步骤: 使用 console 控制路由器: 1、启动路由器,60 秒内按下 ctrl+break 键 2、rommon>confreg 0x2142 3、rommon>reset 4、router#copy startup-config running-config 5、router(config)#no enable secrect //可以删除密码也可以更改,这里为删除 6、router(config-line)#no enable password 7、router#copy

running-config startup 8、router(config)#config-register 0x2102 9、router#reload //可选命令 2500 系列路由器步骤: 1、启动路由器,60 秒内按下 ctrl+break 键 2、>o/r 0x2142 3、>i 其余步骤跟 2610 一样 三、交换机密码的恢复.(以 CISCO 2950 交换机为例) 使用 console 控制交换机: 重起交换机:按 MODE 键进入到 switch:模式 如下 C2950 Boot Loader (C2950-HBOOT-M) Version 12.1(11r)EA1, RELEASE SOFTWARE (fc1) Compiled Mon 22-Jul-02 17:18 by antonino WS-C2950-24 starting... Base ethernet MAC Address: 00:13:1a:9a:2b:80 Xmodem file system is available. The system has been interrupted prior to initializing the flash filesystem. The following commands will initialize the flash filesystem, and finish loading the operating system

software: flash_init load_helper boot switch: flash_init //初始化 flash: Initializing Flash... flashfs[0]: 4 files, 1 directories flashfs[0]: 0 orphaned files, 0 orphaned directories flashfs[0]: Total bytes: 7741440

百思学网络,领先科技 -25- HTTP://WWW.BESTXUE.CN

flashfs[0]: Bytes used: 3090944 flashfs[0]: Bytes available: 4650496 flashfs[0]: flashfs fsck took 6 seconds. ...done initializing flash. Boot Sector Filesystem (bs:) installed, fsid: 3 Parameter Block

Filesystem (pb:) installed, fsid: 4 switch: load_helper //加载帮助 switch: dir flash: //查看 flash:内容 Directory of flash:/ 2 -rwx 736 vlan.dat 3 -rwx 3086336

c2950-i6q4l2-mz.121-22.EA2.bin 5 -rwx 1558 config.text //交换机启动时应用的配置 6 -rwx 5 private-config.text 4650496 bytes available (3090944 bytes used)

switch: rename flash:config.text flash:config-old.txt //重命名 config.text switch: reset //重起交换机 Are you sure you want to reset the system (y/n)?y System resetting... 重起交换机后由于交换机不会再应用配置文件,因为刚才已把配置文件的名字更改。交换机会进入到配置 的对话模式. --- System Configuration Dialog --- Would you like to enter the initial configuration dialog? [yes/no]: n Switch#dir Directory of flash:/ 2 -rwx 736 Mar 01 1993 00:19:14 +00:00 vlan.dat 3 -rwx 3086336 Jan 01 1970 01:12:26 +00:00 c2950-i6q4l2-mz.121-22.EA2.bin

5 -rwx 1558 Mar 01 1993 02:36:44 +00:00 config-old.txt 6 -rwx 5 Mar 01 1993 02:36:44 +00:00 private-config.text

7741440 bytes total (4650496 bytes free) Switch#copy config-old.txt

running-config Destination filename [running-config]? 1558 bytes copied in 1.152 secs (1352 bytes/sec) sw#config t Enter configuration commands, one per line. End with CNTL/Z. sw(config)#line console 0 sw(config-line)#no pass cisco //清除 console 口密码 sw(config)#no enable secret //清除 enable 密码

sw(config)#no enable password //清除 enable 密码 sw#write //保存 注:以上

密码删除成功,一般情况下你可以不删除,就直接更改成你想要的密码就可以。

百思学网络,领先科技 -26- HTTP://WWW.BESTXUE.CN

实验8. IOS 软件备份、升级与 NVRAM 备份 Cisco 的网际操作系统 (IOS)是思

科设备的核心,随着网络技术的不断发展,通过升级以适应不断变 化的技术,满足新的需求。 实验拓扑: 本实验目的: 1. 备份 R1 的 NVRAM(Startup-config) 2. 备份 R1 的 IOS 映像文件 3. 升级 R1 的 IOS 文件 描述: 首先保证 TFTP SERVER 和路由器是连通的。本实验中用 PC1 作为 TFTP 服务器(PC1 装上 TFTP Server 的软件就可以作为一台 TFTP Server) 一、 备份 R1 的 NVRAM(Startup-config) 步骤: 配置 R1〆 Router#conf t Router(config)#host R1 R1(config)#interface ethernet 0/0 R1(config-if)#ip address 192.168.10.99 255.255.255.0 R1(config-if)#no shutdown R1(config-if)#exit R1(config)#end 配置 PC1 的 IP 地址〆 百思学网络,领先科技 -27- HTTP://WWW.BESTXUE.CN

保证 PC1 到 R1 的连通性〆 安装 TFTP SERVER 软件(本实验使用 CISCO 的 TFTPServer) 在 R1 上使用 copy startup-config tftp:备份 NVRAM 到 TFTP SERVER R1#copy startup-config tftp: Address or name of remote host []? 192.168.10.102 Destination filename [r1-confg]? !! 710 bytes copied in 0.072 secs (9861 bytes/sec) R1# 在 TFTP SERVER 上查看已备份成功〆

TFTP服务器由此打开

百思学网络,领先科技 -28- HTTP://WWW.BESTXUE.CN

用写字板打开 r1-config 文件即可看到里面的具体配置

二、 备份 R1 的 IOS 映像文件 在 R1 上 show flash:查看映像文件的名字: R1#show flash: System flash directory: File Length Name/status 1 12991168 c2600.bin [12991232 bytes used, 3785984 available, 16777216 total] 16384K bytes of processor board System flash (Read/Write) 在 R1 上使用 copy flash: tftp:备份 IOS 的映像文件到 TFTP SERVER 百思学网络,领先科技 -29- HTTP://WWW.BESTXUE.CN

R1#copy flash: tftp Source filename []? c2600.bin Address or name of remote host []? 192.168.10.102 Destination filename [c2600.bin]?

c2600.bin !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

在 R1 上查看备份的映像文件:

三、 升级 R1 的 IOS 文件 (一)升级 R1 的 IOS 文件(在有 IOS 操作系统的情况下升级) 步骤: 查看正在运行的 IOS 映像文件: R1#show flash: System flash directory: File Length Name/status

百思学网络,领先科技 -30- HTTP://WWW.BESTXUE.CN

1 12991168 c2600.bin -----------------------------------注:正在运行的 IOS 映像文件 [12991232 bytes used, 3785984 available, 16777216 total] 16384K bytes of processor board System flash

(Read/Write) ---------注:对 FLASH 有读或是写的权限 注:在 R1 上使用命令 copy tftp flash 升级 IOS 的映像文件,必须要保证 FLASH 有足够的空间存放 IOS 的映像文件,如果 FLASH 空间不够,用命令:delete flash:c2600.bin 删除已有的 IOS 文件。注意如果 删除了 FLASH 里的映像文件后不要重启设备,也不能断电。 R1#copy tftp: flash: Address or name of remote host []? 192.168.10.102 Source filename []? c2600_new.bin Destination filename [c2600_new.bin]? Accessing tftp://192.168.10.102/c2600_new.bin... (二)升级 R1 的 IOS 文件(在没有 IOS 操作系统的情况下升级) 在路由器的 IOS 已经被删除,系统崩溃,也就是路由器当前运行在 rommon 的情况下: 升级步骤:(以 2600 路由器为例) rommon 1 > IP_ADDRESS=192.168.10.99 //设置本地 ip 地址 rommon 2 >

IP_SUBNET_MASK=255.255.255.0 //设置本地 ip 掩码 rommon 3 > DEFAULT_GATEWAY=192.168.10.102 //设置默认网关 rommon 4 >