第 1 章 实验拓扑 终端服务器配置 访问 Cisco 路由器的方法 通过 Console 口访问路由器 通过 Telnet 访问路由器 终端访问服务器 本书实验拓扑 实验 1: 通过 Console 口访问路由

Size: px
Start display at page:

Download "第 1 章 实验拓扑 终端服务器配置 访问 Cisco 路由器的方法 通过 Console 口访问路由器 通过 Telnet 访问路由器 终端访问服务器 本书实验拓扑 实验 1: 通过 Console 口访问路由"

Transcription

1

2 第 1 章 实验拓扑 终端服务器配置 访问 Cisco 路由器的方法 通过 Console 口访问路由器 通过 Telnet 访问路由器 终端访问服务器 本书实验拓扑 实验 1: 通过 Console 口访问路由器 实验 2: 通过 Telnet 访问路由器 实验 3: 配置终端访问服务器 终端访问服务器配置命令汇总 21 第 2 章路由器基本配置 路由器及 IOS 简介 路由器简介 IOS 简介 CDP 协议介绍 实验 1:CLI 的使用与 IOS 基本命令 实验 2: 配置文件的备份和 IOS 的备份 实验 3: 密码恢复和 IOS 的恢复 实验 4:CDP 路由器基本配置命令汇总 42 第 3 章静态路由 静态路由与默认路由 静态路由介绍 默认路由介绍 ip classless 实验 1: 静态路由 实验 2: 默认路由 实验 3:ip classless 静态路由命令汇总 52 第 4 章 RIP RIP 概述 RIPv 实验 1:RIPv1 基本配置 实验 2: 被动接口与单播更新 实验 3: 使用子网地址 RIPv 实验 4:RIPv2 基本配置 实验 5:RIPv2 手工汇总 实验 6:RIPv2 认证和触发更新 实验 7: 浮动静态路由 实验 8:ip default-network RIP 命令汇总 79 第 5 章 EIGRP EIGRP 概述 实验 1:EIGRP 基本配置 EIGRP 负载均衡 汇总和认证 实验 2:EIGRP 负载均衡 实验 3: EIGRP 路由汇总 实验 4:EIGRP 认证 EIGRP 命令汇总 97

3 第 6 章单区域 OSPF OSPF 概述 实验 1: 点到点链路上的 OSP 实验 2: 广播多路访问链路上的 OSPF OSPF 认证 实验 3: 基于区域的 OSPF 简单口令认证 实验 4: 基于区域的 OSPF MD5 认证 实验 5: 基于链路的 OSPF 简单口令认证 实验 6: 基于链路的 OSPF MD5 认证 实验 7:default-informtion originate OSPF 命令汇总 122 第 7 章 HDLC 和 PPP HDLC 和 PPP 简介 HDLC 介绍 PPP 介绍 实验 1:HDLC 和 PPP 封装 实验 2:PAP 认证 实验 3: CHAP 认证 HDLC PPP 命令汇总 130 第 8 章帧中继 帧中继简介 什么是帧中继 帧中继的合理性 DLCI 帧中继术语 LMI 帧中继映射 子接口 实验 1: 把一台 Cisco 路由器配置为帧中继交换机 实验 2: 帧中继基本配置和帧中继映射 实验 3: 帧中继上的 RIP 实验 4: 帧中继点到多点子接口 实验 5: 帧中继点到点子接口 帧中继命令汇总 151 第 9 章 ACL ACL 概述 实验 1: 标准 ACL 实验 2: 扩展 ACL 实验 3: 命名 ACL 实验 4: 基于时间 ACL 实验 5 动态 ACL 实验 6: 自反 ACL ACL 命令汇总 165 第 10 章 DHCP DHCP 概述 实验 1:DHCP 基本配置 实验 2: DHCP 中继 DHCP 命令汇总 173 第 11 章 NAT 实验 1: 静态 NAT 配置 174

4 11.3 实验 2: 动态 NAT 实验 3:PAT 配置 NAT 命令汇总 180 第 12 章交换机基本配置 交换机简介 实验 1: 交换机基本配置 实验 2: 交换机端口安全 实验 3: 交换机的密码恢复 实验 4: 交换的 IOS 恢复 交换机基本配置命令汇总 190 第 13 章 VLAN,Trunk 和 VTP VLAN,Trunk 和 VTP 简介 VLAN Trunk VTP EtherChannel 实验 1: 划分 VLAN 实验 2:Trunk 配置 实验 3:VTP 配置 实验 4:EtherChannel 配置 VLAN Trunk 和 VTP 命令汇总 205 第 14 章 STP STP 简介 基本 STP PVST Portfast Uplinkfast Backbonefast RSTP MST STP 防护 实验 1:STP 和 PVST 实验 2:Portfast,Uplinkfast,Backbonefast 实验 3:RSTP 实验 4:MST 实验 5:STP 保护 STP 命令汇总 223 第 15 章 VLAN 间路由 VLAN 间路由简介 单臂路由 层交换 实验 1: 单臂路由实现 VLAN 间路由 实验 2:3 层交换实现 VLAN 间路由 VLAN 间路由命令汇总 228 第 16 章网关冗余和负载平衡 网关冗余和负载平衡简介 HSRPHSRP 是 Cisco 的专有协议 VRRP GLBP 实验 1:HSRP 实验 2:VRRP 实验 3:GLBP 237

5 16.5 网关冗余及负载平衡命令汇总 242 第 17 章帧中继上的 OSPF 实验 1; 帧中继环境下的 NBMA 模式 实验 2: 帧中继环境下 BMA 模式 实验 3: 帧中继环境下的点到点模式 实验 4: 帧中继环境下点到多点模式 帧中继上的 OSPF 命令汇总 256 第 18 章多区域 OSPF 多区域 OSPF 概述 OSPF 路由器类型 LSA 类型 区域类型 实验 1: 多区域 OSPF 基本配置 多区域 OSPF 高级配置 实现 2:OSPF 手工汇总 实验 3 OSPF 末节区域和完全末节区域 实验 4:OSPF NSSA 区域 OSPF 虚链路 实验 5: 不连续区域 0 的虚链路 实验 6: 远离区域 0 的虚链路 OSPF 命令汇总 279 第 19 章 IS-IS IS-IS 概述 IS-IS 特点 术语 实验 1: 集成 IS-IS 的基本配置 实验 2: 多区域集成的 IS-IS 帧中继上集成 IS-IS 实验 3:NBNA 上集成的 IS-IS 实验 4: 帧中继上点到点子接口下集合成的 IS-IS IS-IS 命令汇总 300 第 20 章路由重分布 路由重分布概述 实验 1:RIP,EIGRP 和 OSPF 重分布 实验 2:IS-IS 和 OSPF 重分布 路由重分布命令汇总 312 第 21 章路由优化 路由优化概述 实验 1: 用分布控制列表控制路由更新 策略路由 实验 2: 基于源 ip 地址的策略路由 实验 3: 基于报文大小的策略路由 实验 4: 基于应用的策略路由 路由优化命令汇总 323 第 22 章 IPv IPv6 概述 IPV6 优点 IPv6 地址 IPv6 路由 实验 1:IPv6 静态路由 326

6 实验 2:IPV6 RIPng 实验 3:OSPFv 实验 4.IPv6 EIGRP IPv6 命令汇总 344 第 23 章 组播 组播简介 实验 1:PIM Dense 实验 2:PIM Sparse-Dense 组播命令汇总 355 第 24 章 BGP BGP 概述 BGP 特征 BGO 属性 BGP 路由判定 实验 1:IBGP 和 EBGP 基本配置 实验 2;BGP 地址聚合 用 BGP 属性控制选路 实验 3; 用 BGP Origin 属性控制选路 实验 4: 用 BGP AS-PATH 属性控制选路 实验 5: 用 BGP LOCAL_PREF 属性控制选路 实验 6: 用 BGP Weight 属性控制选路 实验 7: 用 MED 属性控制选路 实验 8: 路由反射器 (RR) 配置 实验 9:BGP 联邦配置 实验 10:BGP 团体配置 BGP 命令汇总 397 第 25 章 QoS QoS 简介 QoS 优先级队列 自定义队列 基于类的加权公平队列 低延迟队列 加权随机早期检测 CAR 实验 1:PQ 实验 2:CQ 实验 3:WFQ 实验 4:CBWFQ 实验 5:LLQ 实验 6:WRED 实验 7:CAR 实验 8:NBAR QoS 命令汇总 414 第 1 章实验拓扑 终端服务器配置 本章将首先简要介绍如何从计算机上访问路由器以对它们进行配置, 通常可以通过 Console 口或者 Telnet 来连接路由器 随后本章了本书中一直要用到的网络拓扑, 并将详细介绍如何配置终端服务器以达到方便控制各个路由器和

7 交换机的目的 1.1 访问 Cisco 路由器的方法 路由器没有键盘和鼠标, 要初始化路由器需要把计算机的串口和路由器的 Console 口进行连接 访问 Cisco 路由器的方法还有 Telnet Web Browser 和网络管理软件 ( 如 Cisco Works) 等, 本节讨论前 2 种 通过 Console 口访问路由器 计算机的串口和路由器的 Console 口是通过反转线 (Rollover) 进行连接的, 反转线的一端接在路由器的 Console 口上, 另一端接到一个 DB9-RJ45 的转接头上,DB9 则接到计算机的串口上, 如图 1-1 所示 所谓的反转线就是线两端的 RJ45 接着上的是反的, 如图 1-2 所示 计算机和路由器连接好后, 就可以使用各种各样的终端软件配置路由器了 图 1-1 图 通过 Telnet 访问路由器 如果管理员不在路由跟前, 可以通过 Telnet 远程配置路由器, 当然这需要预先在路由器上配置了 IP 地址和密码, 并保

8 证管理的计算机和路由之间是 IP 可达的 ( 简单讲就是能 ping 通 ) Cisco 路由器通常支持多人同时 Telnet, 每一个用户称为一个虚拟终端 (VTY) 第一个用户为 vty 0, 第二个用户为 vty 1, 依次类推, 路由器通过达 vty 终端访问服务器 稍微复杂一点的实验就会用到多台路由器或者交换机, 如果通过计算机的串口和它们连接, 就需要经常性拔插 Console 线 终端访问服务器可以解决这个问题, 连接图如图 1-3 所示 终端访问服务器实际上就是有 8 个或者 16 个异步口的路由器, 从它引出多条连接线到各个路由器上的 Console 口 使用时, 首先登录到终端访问服务器, 然后从终端访问服务器再登录到各个路由器 图 本书实验拓扑 为了完成各种实验, 需要构建不同的拓扑, 这将会花费大量的时间 我们设计了一个功能强大的网络拓扑, 如图 1-4 所示 ( 图中不包含终端服务器 ), 本书所有的实验均可以使用该拓扑完成 ; 该拓扑还可以满足 CCNA 和 CCNP 的绝大多数实验, 以及 CCIE 的部分实验 拓扑中的路由器和交换机均通过终端访问服务器来进行控制, 每个拓扑可以满足 1~7 人共同操作 图 1-4 中 4 台路由器 (R1~R4) 均为 Cisco2821 路由器, 也可以采用 Cisco2821 路由器 ( 差别在于 Cisco2821 的以太网接口为千兆口, 而 Cisco2801 的以太网接口为百兆口 ),IOS 采用 c2800nm-adventerprisek9-mz t1.bin; 交换机 S1 和 S2 为 Catalyst 3560,IOS 采用 c3560-ipbasek9-mz seb4.bin;s3o 为 Catalyst 2950,IOS 采用 C2950-i6q412-mz EA2c.bin 在该拓扑中,4 台路由器之间通过串行链路进行连接 同时, 所有路由器的 g0/0 以太网接口和交换机 S1 进行连接 ;g0/1 以太网接口则和交换机 S2 进行连接 交换机 S1 和 S2 之间通过 f0/13 和 f0/14 进行连接 ; 交换机 S3 的 f0/1 接口连接到

9 S1 的 f0/15 上,f0/2 接口连接到 S2 的 f0/15 上 计算机 PC1 和 PC2 连接到交换机 S1 的 f0/5 和 f0/6 上 ; 计算机 PC3 和 PC4 则连接到交换机 S2 的 f0/5 和 f0/6 上 图 1-4 图 4-1 中的计算机应该有 2 个网上 ( 图中没有画出 ), 其中一个网上和终端服务器连接, 另一网卡和图 1-4 中的交换机连接 终端服务器可以 Cisco2509, 也可以采用带有 8 个或 16 个异步模块的路由器 1.2 实验 1: 通过 Console 口访问路由器 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 计算机的串口和路由器 Console 口的连接方法 ; 2 使用 Windows 系统自带的超级终端软件配置路由器 ; 3 路由器的开机 2. 实验拓扑

10 图 实验步骤 11 步骤 1: 开机如图 1-1 所示, 连接好计算机 COM1 口和路由器的 Console 口, 路由器开机

11 12 步骤 2: 打开超级终端在 Windows 中的 开始 程序 附件 通信 菜单下打开 超级终端 程序, 出现图 1-5 窗口 在 名称 对话框中输入名称, 例如 Router ; 按 确定 按钮 出现图 1-6 窗口时, 在 连接时使用 下拉菜单中选择计算机的 COM1 口, 按 确定 按钮 图 1-5 图 步骤 3: 设置通信参数通常路由器出厂时, 波特率为 9600bps, 因此在图 1-7 窗口中, 单击 不愿为默认值 按钮设置超级终端的通信参数 ; 再单击 确定 按钮 按 回车 键, 看看超级终端窗口上是否出现路由器提示符或其他字符, 如果出现提示符或者其他字符, 则说明计算机已经连接到路由器, 我们可以开始配置路由器了

12 图 步骤 4: 路由器开机关闭路由器电源, 稍后重新打开电源, 观察路由器的开机过程, 如下所述 : System Bootstrap,Version 12.4(1r)[hqluong 1r],RELEASE SOFTWARE(fc1) // 以上显示 BOOT ROM 的版本 Copyright(c)2005by Cisco Systems,Inc. Initializing memory for ECC C2821 processor with Kbytes of main memory Main memory is configured to 64 bit mode with ECC enabled // 以上显示路由器的内存大小 Readonly ROMMON initialized Program load compleate,entry point ;0x8000f000,size;0x274bf4c Self decompressing the image; ###################################################################################################### ##############################[OK] // 以上是 IOS 解压过程 Smart Init is enabled Smart init is sizing iomem ID MEMORY_REQ TYPE 0x003DA000 C2821 Mainboard 0x Onboard VPN 0x000021B8 Onboard USB 0x002C29F0 public buffer pools 0x public particle pools

13 TOTAL; 0x00B13BF8 ( 此处省略 ) A summary of U.S.laws governing Cisco cryptographic products may be found at; http;// If you require further assistance please contact us by sending to export@cisco.com Installed image archive Cisco 2821(revision49.46)with249856K/12288Kbytes of memory. // 内存大小 Processor board ID FHK 1039F21Q 2 Gigabit Ethernet interfaces // 两个千兆位以太网接口 2 Low-speed serial(sync/async)interfaces // 两个低速串行口 ( 同步 / 异步 ) 1 Virtual Provate Network(VPN)Module // 一个 VPN 网络模块 DRAM configuration is 64 bits wide with parity enabled 239Kbyest of non- volatile configuration memory. //NVRAM 的大小 62720Kbytes of ATA conmpactflash(read/write) //FLASH 卡的大小 ---System Configration Dialog--- Continue with configuration dialog? [yes/no]; // 以上提示是否进入配置对话模式? 我们回答 n 结束该模式 4. 实验调试 如果超级终端无法连接到路由器, 请按照以下顺序检查 : 1 检查计算机和路由器之间的连接是否松动, 并确保路由器已经开机 ; 2 在图 1-6 中, 是否选择了正确的计算机 COM 口 ; 3 是否按照图 1-7 设置正确的通信参数 ; 4 如果仍无法排除故障, 而路由器非出厂设置, 可能是路由器的通信波特率被修改为非 9 600bps, 则如图 1-8 所示, 逐一测试通信速率 ; 图 1-8

14 5 用计算机的另一 COM 口和路由器的 Console 口连接, 或者确保计算机的 COM 口正常 ; 6 和供应商联系 1.3 实验 2: 通过 Telnet 访问路由器 要通过 Telnet 访问路由器, 需要先通过 Console 口对路由器进行基本配置, 如 IP 地址和密码等 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 配置路由器以太网接口的 IP 地址, 并打开接口 ; 2 配置路由器的 enable 密码和 vty 密码 ; 3Tetnet 程序的使用 2. 实验拓扑 图 实验步骤 (1) 步骤 1: 配置路由器以太网接口 IP 地址 Router>enable Router# // 以上是进入路由器的特权模式 Router#configure terminal Enter configuration commands,one rper line. End with CNTL/Z. Router(config)# // 以上是进入路由器的配置模式 Router(config)#interface g0/0 Router(config-if)# // 以上是进入路由器的以太网口 g0/0 接口, g0/0 接口中 g 表示 GigabitEthernet,0/0 表示是第 0 个插槽中的第 0 个接口.S0/0/0 则表示为第 2 个插槽中的第 0 个模块上的第 0 个串行接口 Router(config-if)#ip address

15 // 以上是配置接口的 IP 地址 Router(config-if)#no shutdown // 以上是打开接口, 默认路由器的所有接口都是关闭的, 这一点和交换机有很大差别 Router(config-if)#end // 退出配置模式 (2) 步骤 2: 配置路由器密码 Router#conf terminal Router#(config)line vty 0 4 // 以上是进入路由器的 VTY 虚拟终端下 vty 0 4 表示 vty 0 到 vty 4, 共 5 个虚拟终端 Router(config-line)#password CISCO Router(config-line)#login // 以上是配置 vty 的密码, 即 Telnet 密码 Router(config-line)#exit Router(config)#enable password CISCO // 以上是配置进入到路由器特权模式的密码 Router(config)#end (3) 步骤 3; 通过 Telnet 访问路由器在计算机上配置网卡的 IP 地址为 / , 打开 DOS 命令行窗口. 首先测试计算机和路由器的 IP 连通性, 再 Telnet 远程登录. 如下所述 ; C;\>ping Pinging with 32 bytes of data; Reply from ;bytes=32 time<1ms TTL=255 Reply from ;bytes=32 time<1ms TTL=255 Reply from ;bytes=32 time<1ms TTL=255 Reply from ;bytes=32 time<1ms TTL=255 Ping Statistics for ; Packets; Sent=4,Received=4,Lost=0(0%lo Approximate round trip times in milli-seconds; Minimum=0ms,Maximum=0ms,Average=0ms // 以上表明计算机能 ping 通路由器 C;\>telnet //Telnet 路由器以太网卡上的 IP 地址 Uer Access Verification Password; Router>enable Password; Router#exit // 输入 vty 的密码 Cisco 输入 enable 的密码 Cisco, 能正常进入路由器的特权模式

16 4. 实验调试 如果无法从计算机上 ping 通路由器, 依照以下步骤进行 ; 1 检查计算机 交换机 路由器之间的连接是否松动 : 2 检查连接线是否是直通线 : 3 检查计算机的网卡和 IP 地址是否正常 : 4 在路由器上, 检查以太网接口是否正常 Router#show int g0/0 GigabitEthernet0/0 is up,line protocol is up Hardware is MV96340 Ethernet,address is n828(bia b828) Internet address is /16 应该看到两个 up, 否则检查路由器和交换机之间的连接 1.4 实验 3: 配置终端访问服务器 使用终端访问服务器 ( 就是插有异步模块的路由器 ) 可以避免我们在同时配置多台路由器时频繁拨插 Console 线, 为了方便使用终端服务器, 我们可以制作一个简单的菜单 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 配置终端访问服务器, 并制作一个简单的菜单 : 2 使用终端访问服务器控制路由器 2. 实验拓扑 3. 实验步骤 (1) 步骤 1: 终端服务器的基本配置 Router(config)#hostname Terminal-Server // 以上是配置终端服务器的主机名 如图 1-10

17 Terminal-Server(config)#enable secret ccielab // 以上是配置进入特权模式的密码, 防止他人修改终端服务器的配置 Terminal-Server(config)#no ip domain-lookup // 以上禁止路由器查找 DNS 服务器, 防止我们输入错误命令时的长时间等待 Terminal-Server(config)#line vty 0? <1-15> Last Line Number <cr> // 查看该路由器支持多少 vty 虚拟终端, 可以看到支持 0~15 Terminal-Server(config)#line vty 0 15 Terminal-Server(config-line)#no login Terminal-Server(config-line)#logging synchronous Terminal-Server(config-line)#no exec-timeout Terminal-Server(config-line)#exit // 以上允许任何人不需密码就可以 Telnet 该终端服务器, 并且即使长时间不输入命令也不超时自动 Logout 出来 Terminal-Server#conf t Enter configuration commands,one per line. End with CNTL/Z Terminal-Server(config)#interface f0/0 Terminal-Server(config-if)#ip address Terminal-Server(config-if)#no shutdown Terminal-Server(config-if)#exit // 以上配置以太网接口的 IP 地址 / , 并打开接口 Terminal-Server(config)#no ip routing // 由于终端服务不需要路由功能, 所以关闭路由功能, 这时终端服务器相当于一台计算机 Terminal-Server(config)#ip default-gateway // 配置网关, 允许他人从别的网段 Tetlnet 该终端服务器 (2) 步骤 2: 配置线路, 制作简易菜单 Terminal-Server#show line Tty Typ Tx/Rx A Modem Roty AccO AccI Uses Noise Overruns Int * 0 CTY /0 - * 33 Tty 9600/ /717 - * 34 Tty 9600/ /823 - * 35 Tty 9600/ /736 - * 36 Tty 9600/ /767 - * 37 Tty 9600/ / * 38 Tty 9600/ / * 39 Tty 9600/ / Tty 9600/ /0-41 Tty 9600/ /0 -

18 42 Tty 9600/ /0-43 Tty 9600/ /0-44 Tty 9600/ /0-45 Tty 9600/ /0-46 Tty 9600/ /0-47 Tty 9600/ /0-48 Tty 9600/ /0-65 Aux 9600/ /0 - * 66 Vty /0 - * 67 Vty /0 - * 68 Vty /07 - * 69 Vty /0 - * 70 Vty /0-71 Vty /0-72 Vty /0-73 Vty /0-74 Vty /0-75 Vty /0-76 Vty /0-77 Vty /0-78 Vty /0-79 Vty /0-80 Vty /0-81 Vty /0 - // 以上是查看终端服务器上异步模块的各异步口所在的线路编号,tty 表示的就是异步模块, 该终端服务器模块有 16 个接口, 线路编号为 33~48, 我们这里实际上只用了 33~39. 记住线路的编号, 后面需要根据这些编号进行配置 Terminal-Server#conf t Enter configuration commands,one per line. End with CNTL/Z Terminal-Server(config)#line Terminal_Server(config-line)#transport input all // 进入线路模式下, 线路允许所有传入, 实际上我们只允许 Telnet 进入即可 Terminal_Server(config-line)#exit Terminal_Server(config)#int loopback0 Terminal_Server(config-if)#ip address // 以上 Loopback0 接口的 IP 地址,Loopback 接口是一个逻辑上的接口, 路由器上可以任意创建几乎无穷多的 Loopback 接口, 该接口可以永远是 UP 的 Loopback 接口经常用于测试等 Terminal_Server(config-if)#exit Terminal_Server(config)#ip host R Terminal_Server(config)#ip host R Terminal_Server(config)#ip host R

19 Terminal_Server(config)#ip host R Terminal_Server(config)#ip host S Terminal_Server(config)#ip host S Terminal_Server(config)#ip host S Terminal_Server(config)#exit // 从终端服务器控制各路由器, 是通过 Telnet 实现的, 此时 Telnet 的端口号为线路编号加上 2000, 例如 Line33, 其端口号为 2033, 如果要控制 line33 线路上连接的路由器, 我们可以采用, Telnet 命令 然而这样命令很长, 为了方便, 所以我们使用 ip host 命令定义一系列的主机名, 这样可以直接输入 R1 控制 line33 线路上连接的路由器 Terminal_Server(config)#alias exec cr1 clear line 33 Terminal_Server(config)#alias exec cr2 clear line 34 Terminal_Server(config)#alias exec cr3 clear line 35 Terminal_Server(config)#alias exec cr4 clear line 36 Terminal_Server(config)#alias exec cs1 clear line 37 Terminal_Server(config)#alias exec cs2 clear line 38 Terminal_Server(config)#alias exec cs3 clear line 39 Terminal_Server(config)# // 以上定义了一系列的命令别名, 例如 cr1 = clear line 33, clear line 命令的作用是清除线路 Terminal_Server(config)#privilege exec level 0 clear line Terminal_Server(config)#privilege exec level 0 clear // 以上是使得我们在用户模式下也能使用 clear line 和 clear 命令 Terminal_Server(config)## Enter TEXT message. End with the character # ********************************** R R1 cr clear line 33 R R2 cr clear line 34 R R3 cr clear line 35 R R4 cr clear line 36 S S1 cs clear line 37 S S2 cs clear line 38 S S3 cs clear line 39 *********************************** # // 以上是制作一个简单的菜单, 提醒用户 : 要控制 R1 路由器可以使用 R1 命令 ( 大小写不敏感 ); 要清除 R1 路由器所在的线路, 可以使用 cr1 命令 我们是利用路由器的 Banner Motd 功能实现的, 该功能使得我们 Telnet 到路由器后, 就显示以上简单菜单

20 (3) 步骤 3: 测试能否从终端服务器控制各路由器和交换机在计算机上配置网卡的 IP 地址为 / , 并打开 DOS 命令行窗口 首先测试计算机和路由器的 IP 连通性, 再 Telnet 远程登录 如下所述 : C;\Documents and Settings\longkey>ping Pinging with 32 bytes of data; Reply from ;bytes=32 time<1ms TTL=255 Reply from ;bytes=32 time<1ms TTL=255 Reply from ;bytes=32 time<1ms TTL=255 Reply from ;bytes=32 time<1ms TTL=255 Ping Statistics for ; Packets; Sent=4,Received=4,Lost=0(0%lo Approximate round trip times in milli-seconds; Minimum=0ms,Maximum=0ms,Average=0ms // 以上表明计算机能 ping 通路由器 C;\Documents and Settings\longkey>Telnet ********************************** R R1 cr clear line 33 R R2 cr clear line 34 R R3 cr clear line 35 R R4 cr clear line 36 S S1 cs clear line 37 S S2 cs clear line 38 S S3 cs clear line 39 *********************************** //Telnet 到 , 出现简易菜单 Terminal-Server>cr1 [confirm] [OK] Terminal-Server> // 先用 cr1 命令清除线路 33, 该线路上连接了路由器 R1 Terminal-Server>r1 Trying R1( ,2033) Open ********************************** R R1 cr clear line 33 R R2 cr clear line 34 R R3 cr clear line 35

21 R R4 cr clear line 36 S S1 cs clear line 37 S S2 cs clear line 38 S S3 cs clear line 39 *********************************** R1> // 输入 r1 命令, 如果出现 R1> 或者 Router> 等, 表明可以控制 R1 路由器了 如果出现以下情况 : Terminal-Server>r1 Trying R1( ). %Connection refused by remote host 请执行几次 cr1 命令后, 重新执行 r1 命令 (4) 步骤 4: 打开多个窗口 图 1-11 重复步骤 3, 可以打开多个路由器或者交换机的控制窗口, 这样我们就可以在一台计算机上同时配置多个路由器和交换机了, 图 1-11 所示 当然, 一台路由器只能被一台计算机所控制 提示 实际应用中如果需要配置多台设备, 不 Windows 自带的 Telnet 程序, 可以选用 SecureCRT 等专业终端软件, 这些软件的功能完善, 更方便我们的配置

22 1.5 终端访问服务器配置命令汇总 表 1-1 是本章出现的命令 表 1-1 本章命令汇总 命令 作用 enable 从用户模式进入特权模式 configure terminal 进入配置模式 interface g0/0 进入千兆位以太网接口模式 ip address 配置接口的 IP 地址 no shutdown 打开接口 line vty 0 4 进入虚拟终端 vty 0~vty 4 password CISCO 配置密码 login 用户要进入路由器, 需要先进行登录 exit 退回到上一级模式 enable password CISCO 配置进入特权模式的密码, 密码不加密 end 直接回到特权模式 show int g0/0 显示 g0/0 接口信息 hostname Terminal-Server 配置路由器的主机名 enable secret ccielab 配置进入特权模式的密码, 密码加密 no ip domain-lookup 路由器不使用 DNS 服务器解析主机的 IP 地址 logging synchonous 对路由器上的提示信息进行同步, 防止信息干扰我们输入命令 no ip routing 关闭路由器的路由功能 ip default-gateway 配置路由器访问其他网段时所需的网关 show line 显示各线路的状态 line 进入 33~38 线路模式 transport input all 允许所有协议进入线路 int loopback0 进入 Loopback0 接口 iop host R 为 主机起一个主机名 alias exec crl clear line 33 为命令起一个别名 privilege exec level 0 clear line 把命令 clear line 的等级改为 0, 在用户模式下也可以执行它 banner motd 设置用户登录路由器时的提示信息

23 第 2 章路由器基本配置 本章首先将简要介绍路由器的硬件组成, 重点介绍路由器中最重要的部分 IOS 对路由器的配置, 实际上就是对 IOS 软件进行配置 IOS 提供了大量的命令, 只有熟悉这些命令才能很好地发挥路由器的功能, 本章介绍了路由器的一些基本配置命令 2.1 路由器及 IOS 简介 路由器简介 路由器能起到隔离广播域的作用, 还能在不同网络间转发数据包 路由器实际上是一台特殊用途的计算机, 和常见的 PC 一样, 路由器有 CPU 内存和 BOOT ROM 路由器没有键盘 硬盘和显示器 ; 然而比起计算机, 路由器多了 NVRAM FLASH 及各种各样的接口 路由器各个部件的作用如下所述 1CPU: 中央处理单元, 和计算机一样, 它是路由器的控制和去处部件 2RAM/DRAM: 内存, 用于存储临时的运算结果, 例如, 路由表 ARP 表 快速交换缓存 缓冲数据包 数据队列, 以及当前配置 众所周知,RAM 中数据在路由器断电后是会丢失的 3FLASH: 可擦除 可编程的 ROM, 用于存放路由器的 IOS,FLASH 的可擦除特性允许我们更新 升级 IOS, 而不用更换路由器内部的芯片 路由器断电后,FLASH 的内容不会丢失 当 FLASH 容量较大时, 可以存放多个 IOS 版本 4NVRAM: 非易失性 RAM, 用于存放路由器的配置文件, 路由器断电后,NVRAM 中的内容仍然保持 5ROM: 只读存储器, 存储了路由器的开机诊断程序 引导程序和特殊版本的 IOS 软件 ( 用于诊断奶用途 ), 当 ROM 中软件升级时需要更换芯片 6 接口 (Interface): 用于网络连接, 路由器就是通过这些拉响不同的网络进行连接的 IOS 简介 路由器也有自己的操作系统, 通常称为 IOS(Internetwork Operating System) 和计算机上的 Windows 一样,IOS 是路由器的灵魂, 所有配置是通过 IOS 完成的 Cisco 的 IOS 是命令行界面 (Command Line Interface,CLI), CLI 有如下两种基本工作模式 1 用户模式 (User Mode): 通常用来查看路由器的状态 在此状态下, 无法对路由器

24 进行配置, 可以查看的路由器信息也是有限的 2 特权模式 (Privilege Mode): 可以更改路由器的配置, 当然也可以查看路由器的所有信息 虽然是命令行,CLI 提供简单 丰富的编辑功能, 如表 2-1 所示, 熟悉它们是熟练配置路由器的基础 在 CLI 下, 可以使用 show 命令查看存放在路由中不同部件中的信息, 如图 2-1 所示 在 CLI 下, 我们可以在路由器的各种模式间进行切换来对路由器进行配置 对路由器进行配置后, 可以把配置保存在 NVRAM 中, 路由器开机时会自动读取 为了安全, 可以通过 TFTP 服务器把配置文件备份在计算机 路由器的配置文件可以不同的部件间流动, 流动如图 2-2 所示 路由器的 IOS 是如此重要, 因此我们也需要通过 TFTP 服务器把 IOS 备份到计算机上 由于各种各样的原因, 我们可能会不小心破坏了 IOS, 造成路由器无法开机, 可以通过 TFTP 把之前备份出的 IOS 进行恢复 如果不慎忘记了路由器的密码, 也可以进行恢复 表 2-1 常用的编辑命令 编辑键 命令功能 Ctrl+A 移动光标到命令行开头 Ctrl+E 移动光标到命令行末尾 Ctrl+P ( 或 ) 重用前一条命令 Ctrl+N ( 或 ) 重用下一条命令 Esc+F 光标前移一个词 Esc+B 光标后移一个词 Ctrl+F 光标前移一个字母 Ctrl+B 光标前移一个字母 图 2-1

25 图 2-2 Cisco 路由器开机后, 首先执行一个开机自检过程 (Power On Self Test, POST), 诊断验证 CPU 内存及各个端口是否正常, 紧接着路由器将进入软件初始化过程 其步骤如图 2-3 所示 : 图 执行 ROM 中的引导程序加载 (Bootstrap Loader), 它和计算机中的 BIOS 很类似,Bootstrap 会把 IOS 装到 RAM 中 2IOS 可以存放在许多地方 (FLASH TFTP 服务器上或 ROM 中 ), 路由器寻找 IOS 映像的顺序决于配置寄存器的启动域以及其他的设置 配置寄存器 (Configuration Register) 是一个 16 位 ( 二进制 ) 的寄存器, 低 4 位就是启动域, 不同的值代表从不同的位置查找 IOS, 如表 2-2. 详细的 IOS 查找过程如图 2-4 所示 表 2-2 配置寄存器中启动域的值配置寄存器的值 ( 十六进制 ) 描述 0 使用 ROM 模式 1 自动从 ROM 中启动

26 2-F 从 FLASH 或 TFTP 服务器启动 图 加载 IOS 到 RAM 中, 如果 IOS 是压缩过的, 就先解压 4 在 NVRAM 中查找配置文件, 并把配置文件加载到 RAM 中运行 5 如果在 NVRAM 中没有找到配置文件, 就进入 setup 配置模式 ( 也称为配置对话模式 ) CDP 协议介绍 CDP(Ciso Discovery Protocol) 协议是 Cisco 专有协议, 是使 Cisco 网络设备能够发现相邻的 直连的其他 Cisco 设备的协议 CDP 是数据层的协议, 因此使用不同的网络层协议的 Cisco 设备也可以获得对方的信息 CDP 协议默认是启动的 2.2 实验 1:CLI 的使用与 IOS 基本命令 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 熟悉路由器 CLI 的各种模式 ; 2 熟悉路由器 CLI 的各种编辑命令 ; 3 掌握路由器的 IOS 基本命令 4 查看路由器的有关信息 2. 实验拓扑 实验拓扑图如图 2-5 所示

27

28 图 2-5 实验 1 拓扑图 3. 实验步骤 (1) 步骤 1: 用户模式和特权模式的切换 Router> Router>enable Router# Router#disable Router> // Router 是路由器的名字, 而 > 代表是在用户模式 enable 命令可以使路由器人用户模式进入到特权模式, disable 命令则相反, 在特权模式下的提示符为 # (2) 步骤 2:? 和 Tab 键的使用( 以配置路由器时钟为例 ) Router>enable Router#clok Traslating clok...domain server( ) ( ) %Unknown command or computer name,or unable to find computer address // 以上表明输入了错误的命令 Router#cl? clear clock // 路由器列出了当前模式下可以使用, 并以 cl 开头的所有命令 Router#clock // 路由器提示命令输入不完整 Router#clock? set Set the time and date // 要注意的是? 和 clock 之间要有空格, 否则将得到不同的结果, 如果不加空格路由器以为你是想列出以 clock 字母开头的命令, 而不是想列出 clock 命令的子命令或参数 Router#clock set? hh;mm;ss Current Time

29 Router#clock set 11;36;00 %Incomplete command. Router#clock set 11;36;00? <1-31> Day of the month MONTH Month of the year Router#clock set 11;36;00 12? MONTH Month of the year // 以上多次使用? 帮助命令, 获得了 clock 命令的格式 Router#clock set 11;36; ˆ % Invalid input detected at ˆ marker. // 路由器提示输入了无效的参数, 并用 ˆ 指示错误的所在 Router#clock set 11;36;00 12 august %Incomplete command. Router#clock set 11;36;00 12 august 2003 Router#show clock 11:36: UTC Tue Aug // 至此成功配置了路由器的时钟, 通常如果命令成功, 路由器不会有任何提示 在 CLI 下, 可以直接使用? 命令获得当前模式下的全部命令 如下 Router#? Exec commands; access-enable Create a temporary Access-List entry access-profile Apply user-profile to interface access-template Create a temporary Access-List entry // 为了节约篇幅, 此处省略了部分输出 erase Erase a filesystem exit Exit from the EXEC help Description of the interactive help system --More // 有多于一屏的内容时, 按 回车 键显示下一行, 按 空格 键显示下一页, 按其他键则退出 Router#disable Router>en Router# // 在 CLI 中, 命令是可以缩写的, 但前提是路由器要能够区分得出, 如下 Router#dis %Ambiguous command; dis Router#dis? disable disconnect // 使用 dis 不能退出特权模式的原因是路由器无法区分出 dis 是代表 disable 还是 disconnect 若再多多一个字母 a 就可以区分了

30 Router#disa Router>en Tab Router>enable Router#conf Tab t Tab Router#configure terminal Router(config)# // 可以使用 Tab 键自动完成命令 (3) 步骤 3:IOS 编辑命令与历史命令缓存大小 Router#sh ow history en conf t show histroy dis disable enable conf t show histroy // 以上是显示历史命令 Router#terminal editing // 以上是打开编辑功能, 实际上这是默认的 用上下左右光标键试试移动光标, 也可以试试使用表 2-1 的编辑键移动光标 Router#terminal history size 50 // 以上把缓存的历史命令数改为 50, 默认值为 10 Router#terminal no editing // 以上着装徭的编辑功能, 这时表 2-1 的编辑键失效 Router#terminal editing (4) 步骤 4: 基本 IOS 命令先连接到 R1 路由器上 : Router>enable Router#configure terminal Enter configuration commands,one per line. End with CNTL/Z Router(config)#hostname R1 // 以上改变路由器的名称为 R1, 设置立即生效 R1(config)enable password cisco // 以上改变了 enable 的密码为 cisco, 这个密码是从用户模式进入到特权模式的密码 R1(config)#interface g0/0 // 以上进入到接口模式, 这里是千兆位以太网口 ( 第 0 个插槽的第 0 个接口, 编号从 0 开始 ) R1(config-if)#ip address // 以上给以太接口配置一个 IP 地址 , 掩码为

31 R1(config-if)no shutdown // 以上开启以太网口, 因为默认时路由器的各个接口是关闭的 R1(config-if)#exit // 退回到上一级模式 R1(config)interface s0/0/0 // 以上进入到接口模式, 这里是串行接口 R1(config-if)#ip address // 以上给串行接口配置一个 IP 地址 R1(config-if)no shutdown // 以上开启接口 R1(config-if)#end( 或 Ctrl+Z ) // 以上结束配置直接回到特权模式下 R1#copy running-config starup-config Destination filename[startup-config]? Building configuration... [OK] // 以上把内存中的配置保存到 NVRAM 中, 路由器开机时会读取它连接到 R2 路由器上, 进入以下操作 : Router>enable Router#configure terminal Enter configuration commands,one per line. End with CNTL/Z Router(config)#hostname R2 R2(config)enable password cisco R2(config)#interface g0/0 R2(config-if)#ip address R2(config-if)no shutdown R2(config-if)#exit R2(config)#interface s0/0/0 R2(config-if)#ip address R2(config-if)#clock rate //R2 这一端是 DCE, 需要配置时钟 R2(config-if)no shutdown R2(config-if)#end R2#copy running-config starup-config Destination filename[startup-config]? Building configuration... [OK] R2#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds;!!!!! Success rate is 100 percent(5/5), round-tri0p min/avg/max =1/1/4ms // 从 R2 ping R1 的串行接口, 可以 ping 通 (5) 步骤 5: 各种 show 命令 R2#show version Cisco IOS Software, 28/00 Software (C28/00NM-ADVENTERPRISEK9-M, Version 12.4(11)T1, RELEASE SOFTWARE(fc5) Technical Support; http;// Copyright by Cisco Systems,Inc. Compiled Thu 25-Jan-07 12;50 by prod_rel_team // 以上是 IOS 的版本信息 ROM;System Bootstrap,Version 12.4(1r)[hqluong 1r], RELEASE SOFTWARE(fc1) // 以上是 ROM 的版本信息 R2 uptime is hours, 10 minutes // 路由器的开机时间 System returned to ROM by power-on // 路由器是如何启动的, 例如, 开电或者热启动 System image file is flash;c2800nm-adventerprisek9-mz t1.bin

32 // 以上是当前正在使用的 IOS 文件名 ( 此处省略 ) If you require further assistance please contact us by sending to export@cisco.com. Cisco 2821(revision 53.50)with K/12288K bytes of memory. // 以上是路由型号和 RAM 大小 (249856K+12288K) Processor board ID FHK1039F1FG // 主板系列号 2Gigabit Ethernet interfaces 4Low-speed serial(sync/async)interfaces 1Virtual Private Network(VPN)Module // 以上是各种接口的数量 DRAM configuration is 64 bits wide with parity enabled. 239K bytes of non-volatile configuration memory K bytes of ATA CompactFlash(Read/Write) // 以上是 NVRAM 和 FLASH 的大小情况 Configuration register is 0x2142 // 以上是配置寄存器的值 R2#show running-config Building configuration...

33 Current configuration;1238 bytes! version 12.4 service timestamps debug datetime msec service timestamps log datetime msec no service password-encryption! hostname R ( 此处省略 ) // 以上显示路由正在使用的配置文件 ( 存放在 RAM 中 ), 通常配置文件为几百到几千字节 R2#show startup-config Building configuration... Current configuration;1238 bytes! version 12.4 // 以上显示 NVRAM 中的配置文件 R2#show interface s0/0/0 Serial0/0/0 is up,line protocol is up // 该接口的状态 Hardware is GT96K Serial Internet address is /24 // 该接口的 IP 地址 MTU 1500 bytes, BW 128Kbit, DLY usec, reliability 255/255,txload 1/255,rxload 1/255 // 以上是该接口的 MTU 带宽 延时 可靠性和负载大小 Encapsulation HDLC,loopback not set // 串口的封装类型为 HDLC Keepalive set (10 sec) ( 此处省略 ) R2#show flash CompactFlash directory; File length Name/status c2800nm-adventerprisek9-mz t1.bin [ bytes used, available, total] 62720K bytes of ATA CompactFlash(Read/Write) // 显示了 FLASH 中存放的 IOS 情况,FLASH 的大小, 可用空间 R2#show controllers s0/0/0 Interface Serial0/0/0

34 Hardware is GT96K SerialDCE V.35,clock rate idb at 0x4728A8C0,driver data structure at 0x4728CBEC wic_info 0x4728A8C0 Physical Port 1,SCC Num 1 // 显示 s0/0/0 接口为 v.35 接口, 且为 DCE, 已经配置了时钟 R2#show ip arp Protocol Address Age(min) Hardware Addr Type Interface Internet ARPA GigabitEthernet0/0 Internet c.7650.df17 ARPA GigabitEthernet0/0 // 以上显示路由中缓存的 ARP 表 2.3 实验 2: 配置文件的备份和 IOS 的备份 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 熟悉 TFTP 服务器的使用 ; 2 熟悉备份路由器的配置文件 ; 3 掌握备份路由器的 IOS 2. 实验拓扑实验拓扑图如图 2-6 所示 图 实验步骤 (1) 步骤 :TFTP Server 软件的安装和准备 TFTP 服务器软件有各种各样, 本书以 SolarWinds TFTP Server 软件为例, 该软件可以从 http;//solarwinds.net 免费下载 下载并安装后, 运行该软件, 如图 2-7 所示 从 File Configure 菜单打开配置窗口, 如图 2-8 所示 在 TFTP Root Directory 选项卡中, 可以看到 TFTP 的主目录为 c;\tftp-root,tftp Server 接收到的文件将放在该目录, 也从该目录查找要发送的文件 如图 2-9 所示, 在 Security 选项卡中, 配置 TFTP 可以接收和发送的文件

35 图 2-7 图 2-8

36 图 2-9 ( 2) 步骤 2: 路由器和计算机间的 IP 可达首先确保交换机 S1 为出厂配置, 如果不是的话, 请执行以下命令 ; Switch>enable Switch#delete flash ;vlan.dat Switch#erase startup -config 其次, 在 PC 上配置 IP 地址 / 16 R2(config)#int g0/0 R2(config-if)#no shutdown R2(config-if)#ip address R2(config-if)#exit // 以上是在路由器的以太网接口上配置 IP 地址, 并启用接口 R2#ping Type eccape sequence to abort. Sending 5100-byte ICMP Echos to , timeout is 2 seconds ;!!!!! Success rate is 100 percent(5/5), round-trip in/avg/max=1/1/4ms // 测试从 R2 到 PC( TFTP 服务器 ) 的 IP 可达 ( 3) 步骤 3: 备份配置文件到 TFTP 服务器 R2#copy running-config tftp; // 把内存中的配置文件备份到 TFTP 服务器上 Address or name of remote host[]? // 回答 TFTP 服务器的 IP 地址 Destination filename[r2 -confg]? // 回答文件名, 默认时为 路由器名 -confg!! 1381 byte copied in secs(3055 bytes/sec) // 备份成功, 共 字节, 可以在 c;\tftp-root 目录下找到该文件, 是一个纯文本的文件 可以用写字板打开, 而用记事本打开则格式会出现问题 ( 4) 步骤 4: 采用 复制 粘贴 备份配置文件使用 TFTP 服务器备份配置文件很麻烦, 我们可以简单地在终端窗口, 执行 show running-config 命令, 显示当前的配置, 在终端窗口中复制全部配置, 粘贴到某文本文件中 提示 如果是在 Windows 自带的超级终端窗口中复制 粘贴配置, 会有 ----more---- 等字样, 要记得删除这些字符 ( 5) 步骤 5: 备份配置 IOS 到 TFTP 服务器 R2#show flash; CompactFlash directory ; File Length Name/status c2800nm -adventerprisek9 -mz t1.bin [ bytes used, available, total]

37 62720K bytes of ATA CompactFlash (Read/Write) // 先查看 FLASH 中的 IOS 大小和文件名等 R2#copy flash;c2800nm-adventerprisek9 -mz t1.bin tftp; // 把 IOS 备份到 TFTP 服务器上 Address or name of remote host []? // 回答 TFTP 服务器的 IP 地址 Destination filename[c2800nm -adventerprisek9-mz t1.bin]? // 回答文件名 默认时和源文件名是一样的, 不建议修改文件名, 因为 IOS 文件名包含了 IOS 的版本和特征等信息!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!( 此处省略 ) // 备份成功后可以在 c;\tftp-root 目录下找到该文件 2.4 实验 3: 密码恢复和 IOS 的恢复 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 熟悉路由器的密码恢复步骤 ; 2 熟悉路由器的 IOS 恢复步骤 2. 实验拓扑实验拓扑图如图 2-10 所示 图 实验步骤 ( 1) 步骤 1: 在路由器上配置密码 Router>enable Router#configure terminal Enter configuration commands, one per line. End with CNTL/Z Router(config)#hostname R2 R2(config)#enable password 309nasfdndf12 // 故意配置一个自己也记不住的密码, 以供恢复使用 ( 2) 步骤 2: 路由器密码恢复关闭路由器电源并重新开机, 当控制台出现启动过程时, 赶快按 Ctrl+Break 键中断

38 路由器的启动过程, 进入 rommon 模式, 如下所述 System bootstrap, Version 12.4(1r)[hqluong 1r], RELEASE SFOTWARE(fc1) Copyight 2005 by cisco Systems, inc. Initializing memory for ECC C2821 processor with Bbytes 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>i // 重启路由器 路由器重启后会直接进入到 setup 配置模式, 使用 Ctrl+C 键或者回答 n 退出 setup 模式 Router>enable Router#copy startup -config running-config Destination filename[running -config]? 661 bytes copied in secs // 把配置文件从 NVRAM 中复制到 RAM 中, 在此基础上修改密码 R2#configure teminal R2(config)enable password cisco // 以上把密码改自己的密码, 如果还配置别的密码请把它们一一修改了 R2(config)#config -register 0x2102 // 以上把寄存器的值恢复为正常值 0x2102 R2(config)#exit R2#copy running -config startup -config Destination filename[startup -config]? Building configuration... [ OK] R2#reload // 以上是保存配置, 重启路由器, 检查路由器是否正常 提示 在保存配置前, 还需要把路由器的各个接口一一打开 ( 3) 步骤 3: 故意删除 FLASH 中的 IOS, 我们要恢复 IOS R2#show flash; CompactFLASH diretory ; File length Name/status c2800nm -adventerprisek9-mz t1.bin [ bytes used, available, tota l]

39 62720K bytes of ATA CompactFlash(Read/Write) // 显示 flash 中的 IOS R2#delete flash ; c2800nm-adventerprisek9 -mz t1.bin Delete filename[ c2800nm-adventerprisek9 -mz t1.bin]? delete flash;c2800nm-adventerprisek9 -mz t1.bin?[confirm] // 以上是删除 FLASH 的 IOS, 模拟 FLASH 中的 IOS 丢失或者 IOS 升级失败 提示 请慎重进行该步骤 如果工作中不慎误删 IOS, 请不要将路由器关机, 可以直接使用 copy tftp flash 命令从 TFTP 服务器恢复 IOS, 这比起我们下面介绍的方法简单得多 除了从 TFTP 恢复 IOS, 还可以用 Xmodem 方式通过 Console 口恢复 IOS, 然而, 由于 Console 的速度很慢, 很少有人采用 ( 4) 步骤 4: 恢复 IOS 请确认 IOS 已经放在 c;\tftp-root 目录下 路由器丢失了 IOS 后, 开机将自动进入 rommon 模式 rommon 2>IP_ADDRESS= rommon 3>IP_SUBNET_MASK= rommon 4>DEFAULT_GATEWAY= rommon 5>TFTP_SERVER= rommon 6>TFTP_FILE=c2800nm-adventerprisek9 -mz t1.bin // 要恢复 IOS, 需要配置一些变量的值, 主要是路由器的 IP 地址 掩码等 由于这里的路由器和 TFTP 服务器在同一网段, 是不需要网关的, 但是不能不配置该值, 所以我们把 DEFAULT_GATEWAY 胡乱地指向了 TFTP 服务器 请注意变量名的大小写 rommon 8>tftpdnld // 开始从 TFTP 恢复 IOS IP_ADDRESS= IP_SUBNET_MASK= DEFAULT_GATEWAY= TFTP_SERVER= TFTP_FILE=c2800nm-adventerprisek9-mz 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.

40 WARNING;all existing data in all partitions on flash w ill be lost! Do you wish to continue?y/n [n] ; y // 回答 y 开始从 TFTP 服务器上恢复 IOS, 根据 IOS 的大小, 通常需要十几分钟 Receiving c2800nm-adventerprisek9 -mz t1.bin from !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! ( 此处省略 )!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! File reception completed. Validating checksum. Copying file c2800nm-adventerprisek9-mz t1.bin to flash. Eeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee // 从 TFTP 服务器接收了 IOS 后, 会进行校验 rommon 9>i // 重启路由器 2.5 实验 4:CDP 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 查找 CDP 邻居 ; 2 熟悉 CDP 的配置 2. 实验拓扑实验拓扑图如图 2-11 所示 3. 实验步骤 ( 1) 步骤 1: 打开接口 R1(config)#int g0/0 R1(config-if)#no shutdown R1(config-if)#int s0/0/0 图 2-11

41 R1(config-if)#no shutdown R2(config)#int g0/0 R2(config-if)#no shutdown R2(config-if)#int s0/0/0 R2(config-if)#no shutdown R2(config-if)clock rate // 以上是打开嵓间互连各个接口, 而默认时交换机 S1 的所有接口就是打开 ( 2) 步骤 2: 查看 CDP 配置 R1#show cdp Global CDP information ; Sending CDP packets every 60 seconds Sending a holdtime value of 180 seconds Sending CDPv2 advertisements is enabled // 默认时 CDP 是运行的, 每 60s 从接口发送 CDP 消息 ; 发送出的 CDP 消息, 邻居会为它保存 180s R1#show cdp interface GigabitEthernet0/0 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds GigabitEthernet0/1 is up, line protocol is up Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds Serial0/0/0 is down, line protocol is down Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds Serial0/0/0 is down, line protocol is down Encapsulation ARPA Sending CDP packets every 60 seconds Holdtime is 180 seconds // 以上显示在哪些接口运行 CDP 协议, 每 60s 从接口发送一次 CDP 包,Holdtime 为 180s, 即邻居应为该设备的 CDP 信息保存 180s ( 3) 步骤 3: 查看 CDP 邻居 R1#show cdp neighbors Device ID Local Intrfce Holdtme Capability Platform Port ID R2 Ser0/0/0 137 R S I 2821 Ser0/0/0 S1 Gig0/0 172 S I WS -C3560- F0/1

42 // 以上显示 R1 路由器有两个邻居 : R2 和 S1. Device ID 表示邻居的主机名 ; Local Intrfce 表明 R1 通过该接口和邻居连接, 注意是 R1 上的接口 ; Holdtme 指收到邻居发送的 CDP 消息的时间, 采用倒计时 ; Capability 表明邻居是什么设备, 第一 二行 Capability Codes 对各符号进行了说明 ; Platform 指明了邻居的硬件型号 ; Port ID 指明了 R1 是连接到对方的哪个接口上 R1#show cdp entry R Device ID; R2 Entry address(es) ; Platform; cisco C821, Capabilities; Router Switch IGMP Interface; Serial0/0/0, Port ID (outgoing port) ; Serial0/0/0 Holdtime; 158sec Version ; Cisco IOS Software, 2800 Software(C2800NM-ADVENTERPRISEK9-M), Version 12.4(11)T1, RELEASE SOFTWARE (fc5) Technical Support ; http;// Copyright (c) by cisco Systems, Inc Compiled Thu 25-Jan-07 12;50 by prod_re1_team advertisement version ; 2 Vtp Management Domain ; // 以上是显示邻居 R2 的详细信息, 甚至可以知道邻居的 IOS 版本 R1#clear cdp table // 清除 CDP 表 ( 4) 步骤 4: 关 启 CDP, 调整 CDP 参数 R1(config)#int g0/0 R1(config-if)#no cdp enable // 以上是在 g0/0 接口上关闭 cdp, 其他接口还运行 CDP R1(config-if)#exit R1(config)#no cdp run // 以上是在整个路由器上关闭 CDP R1(config)#cdp run // 在整个路由器上打开 CDP R1(config)#cdp timer 30 //CDP 消息发送时间为 30s R1(config)#cdp holdtime 120 // 调整 CDP 消息的 holdtime 为 120s, 对方收到该路由器发送的 CDP 消息后将保持 120s R1#show cdp Global CDP informati on; Sending CDP packets every 30 seconds Sending a holdtime value of 120 seconds Sending CDPv2 advertisements is enabled

43 2.6 路由器基本配置命令汇总 表 2-3 是本章出现的命令 表 2-3 本章命令汇总 命令 作用 clock set 设置路由器的时间 show clock 显示路由器的时间 show history 显示历史命令 terminal no editing 关闭 CLI 的编辑功能 terminal editing 打开 CLI 的编辑功能 terminal histroy size 50 修改历史命令缓冲区的大小 copy running-config startup-config 把内存中的配置文件保存到 NVRAM 中 clock rate 配置串口上的时钟 (DCE 端 ) show version 显示路由器的 IOS 版本等信息 show running-config 显示内存中的配置文件 show startup-config 显示 NVRAM 中的配置文件 show interface s0/0/0 显示接口的信息 show flash 显示 FLASH 的有关信息 show controllers s0/0/0 显示 s0/0/0 的控制器信息 show ip arp 显示路由器中的 arp 表 copy running-config tftp 把内存中的配置文件复制到 TFTP 服务器上 copoy tftp running-config 把 TFTP 服务器上的配置文件复制到内存中 copy flash; c2800nm-adventerprisek9-mz t1.bin tftp 把 FLASH 中的 IOS 到 TFTP 服务器上 confreg 0x2142 在 rommon 模式下修改配置寄存器值 i 在 rommon 模式下重启路由器 copy startup-config running-config 把 NVRAM 中的配置文件复制到内存中 config-register 0x2102 修改配置寄存器值为 0x2102 reload 重启路由器 delete flash; c2800nm-adventerprisek9-mz t1.bin 删除 FLASH 中的 IOS copy tftp flash 从 TFTP 服务器上复制 IOS 到 FLASH 中 tftpdnld rommon 模式下, 从 TFTP 服务器下载 IOS show cdp 显示 CDP 运行信息 show cdp interface 显示 CDP 在各接口的运行情况 show cdp neighbors 显示 CDP 邻居信息 show cdp entry R2 显示 CDP 邻居 R2 的详细信息 clear cdp table 清除 CDP 邻居表 no cdp enable 接口下关闭 CDP no cdp run/ cdp run 关闭 / 打开整个路由器的 CDP cdp timer 30 CDP 每 30 s 发送一次 cdp holdtime 120 让邻居为本设备发送的 CDP 消息保持 120 s

44 第 3 章静态路由 转发数据包是路由器的最主要功能 路由器转发数据包时需要查找路由表, 管理员可以通过手工的方法在路由器中直接配置路由表, 这就是静态路由 虽然静态路由不适合于在大的网络中使用, 但是由于静态路由简单 路由器负载小 可控性强等原因, 在许多场合中还经常被使用 本章将介绍静态路由的配置, 同时为以后配置动态路由奠定基础 3.1 静态路由与默认路由 静态路由介绍 路由器在转发数据时, 要先在路由表 (Routing Table) 中查找相应的路由 路由器有以下 3 种途径建立路由 1 直连网络 : 路由器自动添加和自己直接连接的网络的路由 ; 2 静态路由 : 管理员手支输入到路由器的路由 ; 3 动态路由 : 由路由协议 (Routing Protocol) 动态建立的路由 静态路由的缺点是不能动态反映网络拓扑, 当网络拓扑发生变化时, 管理就必须手工改变路由表 然而, 静态路由不会战胜路由器太多的 CPU 和 RAM 资源, 也不占用线路的带宽 如果出于安全的考虑想隐藏网络的某些部分或者管理员想控制数据转发路径, 也会使用静态路由 在一个小而简单的网络中, 也常使用静态路由, 因为配置静态路由会更为简捷 配置静态路由的命令为 ip route, 其命令的格式如下 : ip route 目的网络掩码 { 网关地址 接口 } 例子 : ip route s0/0 例子 : ip route 在写静态路由时, 如果链路是点到点的链路 ( 如 PPP 封装链路 ), 采用网关地址和接口都是可以的 ; 然而如果是多路访问的链路 ( 如以太网 ), 则只能采用网关地址, 即不能 :ip route f0/0 提示 有的 IOS 版本中, 当采用 ip route f0/0 时, 路由器也是正常工作的, 然而这是代理 ARP 的功劳, 建议不要采用该形式 在路由器上, 可以使用 show ip route 命令查看路由表 如下所述 :

45 R1#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set R /16[120/2]via ,00;00;21, Serial0/0 [120/2]via ,00;00;06, Serial0/ /16 is subnetted, 4 subnets R [120/1]via ,00;00;21,Serial0/0 C is directly connected, Serial0/1 C is directly connected, Serial0/0 R [120/1]via ,00;00;06, Serial0/1 C /24 is directly connected, FastEthernet0/0 在输出中, 首先显示路由条目各种类型的科室, 如 C 为直连网络, S 为静态路由 以上面带有下划线的路由为例, R 表示这条路由是 RIP 协议学习得到的 ; 是目的网络 ; [120/1] 是管理距离 (Administrative Distance,AD)/ 度量值 (Metric); via 是达目的网络的下一跳路由器的 IP 地址 ; 00;00;21 是指路由器最近一次得知路由到现在的时间 ; Serials0/0 是指到达下一跳应从哪个端口出去 技术要点 管理距离 (AD); 用来表示路由的可信度, 路由器可能从多种途径获得同一路由, 例如, 一个路由器要获得 /24 网络的路由, 可以来自 RIP, 可以是静态路由, 不同途径获得的路由可能采取不同的路径到达目的网络, 为了区分不同路由协议的可信度, 用管理距离加以表示 表 3-1 是通过各种路由协议获得的路由的默认管理距离 路由表中管理距离值越小, 说明路由的可靠程度越高 ; 静态路由的管理距离为 1, 说明手工输入的路由优先级高于其他的路由 表 3-1 路由协议的默认管理距离 路由协议 管理距离 直连接口 0 静态路由 1 外部 BGP 20 内部 EIGRP 90 IGRP 100 OSPF 110

46 RIP 120 外部 EIGRP 170 内部 BGP 200 技术要点 度量值 (Metric); 某一个路由协议判别到达目的网络的最佳路径的方法 当一路由器有多条路径到达某一目的网络时, 路由协议必须判断其中哪一条是最佳的并把它放到路由表中, 路由协议会给每一条路径计算机出一个数, 这个数就是度量值, 通常这个值是没有单位的 度量值越小, 这条路径越佳, 然而不同的路由协议定义度理值的方法是不一样的, 所以不同的路由协议选择出的最佳距离可能也是不一样的, 具体请参见路由协议的章节 默认路由介绍 所谓的默认路由, 是指路由器在路由表中如果找不到到达目的的具体路由时, 最后会采用的路由 默认路由通常会在存根网络 (Stub Network, 即只有一个出口的网络 ) 中使用 如图 3-1 所示, 图 3-1 中左边的网络到 Internet 上只有一个出口, 因此可以在 R2 上配置默认路由, 命令为 :ip route { 网关地址 接口 } 例子 :ip route s0/0 例子 :ip route 图 3-1 桩网络 (Stub Network) ip classless 在图 3-2 中, 如果在 R1 上配置了默认路由 :ip route s0/0/0, 那么路由器 R1 是否会把到达 /24 网络的数据从 s0/0/0 接口发送出去将取决于是否执行了 ip classless 命令, 如果执行了 ip classless 命令 ( 实际上这是默认值 ), 则路由器存在默认路由时, 所有在路由表中查不到具体路由的数据包将通过默认路由发送 图 3-2 ip classless 示例

47 如果执行了 no ip classless 命令, 当路由器存在一主类网络的某一子网路由时, 路由器将认为自己已经知道该主类网络的全部子网的路由, 这时即使存在默认路由, 到达该主类任一子网的数据包不会通过默认路由发送 在图 3-2 中, 执行了 no ip classless 后, 由于路由器 R1 上有 的子网 /24( 这是直连路由 ), 因此路由器 R1 收到到达 /24 子网的数据包不会使用默认路由进行发送 然而, 如果数据包是要达 /24 的, 默认路由会被采用, 因为 R1 没有任何 子网的路由 3.2 实验 1: 静态路由 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 路由表的概念 ; 2 ip route 命令的使用 ; 3 根据需求正确配置静态路由 2. 实验拓扑实验拓扑图如图 3-3 所示 图 3-3 实验 1 和实验 2 拓扑图 3 实验步骤我们要使 /24, /24 和 /24 网络能够互相通信, 按如下所述操作 (1) 步骤 1: 在各路由器上 IP 地址, 保证直连链路的连通性 R1(config)#int loopback0 R1(config-if)#ip address R1(config)#int s0/0/0 R1(config-if)#ip address R1(config-if)#no shutdown R2(config)#int loopback0 R2(config-if)#ip address R2(config)#int s0/0/0 R2(config-if)#clock rate R2(config-if)#ip address

48 R2(config-if)#no shutdown R2(config)#int s0/0/1 R2(config-if)#clock rate R2(config-if)#ip address R2(config-if)#no shutdown R3(config)#int loopback0 R3(config-if)#ip address R3(config)#int s0/0/1 R3(config-if)#clock rate R3(config-if)#ip address R3(config-if)#no shutdown (2) 步骤 2: 在 R1 上配置静态路由 R1(config)#ip route s0/0/0 // 下一跳为接口形式,s0/0/0 是点对点的链路, 注意 : 应该是 R1 上的 s0/0/0 R1(config)#ip route // 下一跳为 IP 地址形式, 是 R2 上的 IP 地址 (3) 步骤 3: 在 R2 上配置静态路由 R2(config)#ip route s0/0/0 R2(config)#ip route s0/0/1 (4) 步骤 4: 在 R3 上配置静态路由 R3(config)#ip route s0/0/1 R3(config)#ip route s0/0/1 4. 实验调试 (1) 在 R1,R2,R3 上查看路由表 R1#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o ODR P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback0

49 /24 is subnetted, 1 subnets S is directly connected, Loopback /24 is subnetted, 1 subnets S [1/0]via R2#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets S is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /24 is subnetted, 1 subnets S is directly connecte,serial0/0/1 C /24 is directly connected, Serial0/0/1 R3#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set /24 is subnetted, 1 subnets S is directly connected, Serial0/0/ /24 is subnetted, 1 subnets S is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connecte,loopback0 C /24 is directly connected, Serial0/0/1

50 (2) 从各路由器的环回口 ping 其他路由器的环回口 R1#ping // 不带任何参数的 ping 命令, 允许输入更多的参数 Protocol [ip]; Target IP address; // 目标 IP 地址 Repeat count [5]; // 发送的 ping 次数 Datagram size [100]; //ping 包的大小 Timeout in seconds [2]; // 超时时间 Extended commands [n]; y // 是否进一步扩展命令 Source address or interface; // 源 IP 地址 Type of service [0]; Set DF bit in IP header? [no]; Validate reply data? [no]; Data pattern [0xABCD]; Loose, Strict, Record, Timestamp, Verbose[none]; Sweep range of sizes [n]; Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds; Packet sent with a source address of !!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 12/14/16 ms // 以上说明从 R1 的 loopback 0 可以 ping 通 R2 上的 loopback0 也可以直接使用以下命令 R1#ping source loopback 0 Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds; Packet sent with a source address of !!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 12/14/16 ms R2#ping source loopback 0 R2#ping source loopback 0 // 从 R2 的 loopback 0 应该可以 ping 通 R1 和 R3 的 loopback 9 接口 R3#ping source loopback 0 R3#ping source loopback 0 //// 从 R3 的 loopback 0 也应该可以 ping 通 R1 和 R2 的 loopback 9 接口 提示 虽然从 R1 的 loopback0 可以 ping 通 R3 的 loopback 0, 数据需要以过 /24 网络, 但是在 R1 上, 我们并没有添加 /24 的路由 路由器转发数据包完全是根据路由表进行的, 并且数据是一跳一跳地被转发的, 就像接力赛似的 当从 R1 的 loopbak 0 口 ping R3 的 loopback

51 0 口时,IP 数据包的源 IP 为 , 目的 IP 为 R1 路由器首先查路由表, 数据包被发到了 R2;R2 路由器也查路由表 ( /24 路由 ), 数据包被发到了 R3;R3 知道这是直连路由 R3 响应 R1 的数据包进行类似的过程 (3) 从 R1 上 ping , 从 R1 上 ping R1#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds;!!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 12/14/16 ms // 可以 ping 通 R1#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds;... Success rate is 0 percent (0/5) // 以上无法 ping 通, 原因在于使用 ping 命令时, 如果不指明源接口, 则 R1 路由器使用 s0/0/0 接口的 IP 地址 ( ) 作为 IP 数据包的源 IP 地址 当 R3 上响应 R1 的数据包时, 数据包是发向 的 然而, 由于 R3 没有 /24 的路由, 数据包无法发送 即 : 数据包人 R1 到了 R3 后, 无法返回 R1 3.3 实验 2: 默认路由 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 默认路由的使用场合 ; 2 默认路由的配置 2. 实验拓扑实验拓扑图如图 3-3 所示 3. 实验步骤在实验 1 的基础上进行实验 2 (1) 步骤 1: 在 R1 和 R3 上删除原有静态路由 R1(config)#no ip route s0/0/0 // 要删除路由, 在原有命令前面加 no 即可 R1(config)#no ip route 图 3-3 实验 1 和实验 2 拓扑图

52 R3(config)#no ip route s0/0/1 R3(config)#no ip route s0/0/1 (2) 步骤 2: 在 R1 和 R3 上配置默认路由 R1(config)#ip route s0/0/0 R3(config)#ip route s0/0/1 4. 实验调试从各路由器的环回口 ping 其他路由器的环回口 请读者比较两个实验 ping 的结果, 仔细分析原因 3.3 实验 3:ip classless 1. 实验目的通过本实验, 读者可以掌握如下技能 ; 1 ip classless 命令的含义 ; 2 配置 ip classless 2. 实验拓扑实验拓扑图如图 3-4 所示 图 3-4 实验 3 拓扑图 3. 实验步骤 (1) 步骤 1: 执行 ip classless R1(config)#interface loopback0 R1(config-if)#ip address R1(config)#interface Serial0/0/0 R1(config-if)#ip address R1(config-if)#no shutdown R1(config)#ip classless R1(config)#ip route Serial0/0/0 // 以上我们配置了默认路由, 同时打开 ip classless, 默认就是打开的

53 R2(config)#interface loopback0 R2(config-if)#ip address R2(config)#interface Serial0/0/0 R2(config-if)#no shutdown R2(config-if)#ip address R2(config-if)#clock rate R2(config)#ip classless R2(config)#ip route Serial0/0/0 // 测试从 R1 ping R2 的 loopback 0 接口 R1#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds;!!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 12/14/16 ms // 可以 ping 通 (2) 步骤 2: 执行 no ip classless R1(config)#no ip cef // 关闭 ip cef, 防止影响我们测试 R1(config)#no ip classless R1#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds;... Success rate is 0 percent (0/5) 可以看到,R1 虽然存在默认路由, 也不能 ping 通 R2 的 loopback 0 接口 3.5 静态路由命令汇总 表 3-2 是本章出现的命令表 3-2 本章命令汇总 命令 ip route show ip route ip classless/ no ip classless ping source loopback 0 作用配置静态路由查看路由表打开 / 关闭有类路由功能指定源端口进行 ping 测试

54 第 4 章 RIP 动态路由协议包括距离向量路由协议和链路状态路由协议 RIP(Routing Information Protocol, 路由信息协议 ) 是使用最广泛的距离微向量路由协议 RIP 是为小型网络环境设计的, 国为这类协议是路由学习及路由更新将产生较大的流量, 占用过多的带宽 4.1 RIP 概述 RIP 是由 Xerox 在 20 世纪 70 年代开发的, 最初定义在 RFC1058 中 RIP 用两种数据包传输更新 : 更新和请求, 每个有 RIP 功能的路由器在默认情况下, 每隔 30 s 利用 UDP520 端口向与它直连的网络邻居广播 (RIPv1) 或组播 (RIPv2) 路由更新 因此, 路由器不知道网络的全局情况, 如果路由更新在网络上传播慢, 将会导致网络收敛慢, 造成路由环路 为了避免路由环路,RIP 采用水平分割 毒性逆转 定义最大跳数 闪式更新和抵制计时 5 个机制来避免路由环路 RIP 协议分为版本 1 和片版本 2 不论是版本 1 还是版本 2, 都具备下面的特征 : 1 是距离向量路由协议 ; 2 使用跳数 (Hop Count) 作为度量值 ; 3 默认路由更新周期为 130 s; 4 管理距离 (AD) 为 120; 5 支持触发更新 ; 6 最大跳数为 150 跳 ; 7 支持等价路径, 默认 4 条, 最大 6 条 ; 8 使用 UDP520 端口进行路由更新 而 RIPv1 和 RIPv2 的区别如表 4-1 所示 表 4-1 RIPv1 和 RIPv2 的区别 RIPv1 在路由更新的过程中不携带子网信息不提供认证不支持 VLSM 和 CIDR 采用广播更新有类别 (Classful) 路由协议 RIPv2 在路由更新的过程中携带子网信息提供明文和 MD5 认证支持 VLSM 和 CIDR 采用组播 ( ) 更新无类别 (Classless) 路由协议

55 4.2 RIPv 实验 1:RIPv1 基本配置 1. 实验目的通过本实验可以掌握 : 1 在路由器上启动 RIPv1 路由进程 ; 2 启用参与路由协议的接口, 并且通告网络 ; 3 理解路由表的含义 ; 4 查看和调试 RIPv1 路由协议相关信息 2. 拓扑结构实验拓扑图如图 4-1 所示 图 4-1 RIPv1 的基本配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router rip // 启动 RIP 进程 R1(config-router)#version 1 // 配置 RIP 版本 1 R1(config-router)#network // 通告网络 R1(config-router)#network (2) 步骤 2: 配置路由器 R2 R2(config)#router rip R2(config-router)#version 1 R2(config-router)#network R2(config-router)#network (3) 步骤 3: 配置路由器 R3 R3(config)#router rip R3(config-router)#version 1

56 R3(config-router)#network R3(config-router)#network (4) 步骤 4: 配置路由器 R4 R4(config)#router rip R4(config-router)#version 1 R4(config-router)#network R4(config-router)#network 实验调试 (1)show ip route 该命令用来查看路由表 R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback0 R /8 [120/3] via , 00;00;03, Serial0/0/0 R /24 [120/1] via , 00;00;03, Serial0/0/0 R /24 [120/2] via , 00;00;03, Serial0/0/0 以上输出表明路由器 R1 学到了 3 条 RIP 路由, 其中路由条目 R /8 [120/3] via ,00;00;03, Serial0/0/0 的含义如下 1R: 路由条目是通过 RIP 路由协议学习来的 ; /8: 目的网络 ; 3120:RIP 路由协议的默认管理距离 ; 43: 度量值, 从路由器 R1 到达网络 /8 的度量值为 3 跳 ; : 下一跳地址 ; 600;00;03: 距离下一次更新还有 27(30-3)s; 7Serial0/0/0: 接收该路由条目的本路由器的接口 同时通过该路由条目的掩码长度可以看到,RIPv1 确实不传递子网信息 (2)show ip protocols 该命令查看 IP 路由协议配置和统计信息

57 R1#show ip protocols 注意 // 后的信息表示注释, 不是输出内容 Routing Protocol is rip // 路由器上运行的路由协议是 RIP Outgoing update filter list for all interfaces is not set // 在出方向上没有设置过滤列表 Incoming update filter list for all interfaces is not set // 在入方向没有设置过滤列表 Sending updates every 30 seconds, next due in 23 seconds // 更新周期是 30 s, 距离下次更新还有 23 s 注意 为了防止更新同步,RIP 会以 15% 的误差发送更新, 即实际发送更新的周期的范围是 25.5~30 s Invalid after 180 seconds, hold down 180, flushed after 240 //invalid after; 路由条目如果在 180s 还没有收到更新, 则被标记为无效 技术要点 被标记为无效的路由条目类似如下所示 : R /8 is possibly down,routing via , Serial0/0/0 可以通过很多方式使路由条目进入无效周期 例如, 在接口上加拒绝接收 UDP520 端口的 ACL; 又如, 将接口设置为被动接口等 //hold down: 抵制计时器的时间为 180s //flushed after: 路由条目如果在 240s 还没有收到更新, 则从路由表中删除此路由条目 提示 可以通过下面的命令来调整以上 3 个时间参数 : R1(config-router)#timers basic update invalid holddown flushed Redistributing; rip // 只运行 RIP 协议, 没有其他的协议重分布进来 Default version control; send version 1, receive version 1 // 默认发送版本 1 的路由更新, 接收本版 1 的路由更新 Interface Send Recv Triggered RIP Key-chain Serial0/0 1 1 Loopback0 1 1

58 // 以上 3 行显示了运行 RIP 协议的接口, 以及可以接收和发送的 RIP 路由更新的版本 Automatic network summarization is in effect //RIP 路由协议默认开启自动汇总功能 Maximum path; 4 //RIP 路由协议可以支持 4 条等价路径, 最大为 6 条 提示 可以通过下面的命令来修改 RIP 路由协议支持等价路径的条数 : R1(config-router)#maximum-paths mumber-paths Routing for Networks; // 以上 3 行表明 RIP 通告的网络 Routing Information Sources; Gateway Distance Last Update ;00;03 // 以上 3 行表明路由信息源, 其中 //gateway: 学习路由信息的路由器的接口地址, 也就是下一跳地址 //distance: 管理距离 //last update: 更新发生在多长时间以前 Distance; (default is 120) // 默认管理距离是 120 (3)debug ip rip 该命令可以查看 RIP 路由协议的动态更新过程 R1#clear ip route * R1#debug ip rip Feb 9 12;43;13.311;RIP;sending request on Serial0/0/0 to Feb 9 12;43;13.315;RIP;sending request on Loopback0 to Feb 9 12;43;13.323;RIP;received v1 update from on Serial0/0/0 Feb 9 12;43;13.323; in 3 hops Feb 9 12;43;13.323; in 1 hops Feb 9 12;43;13.323; in 2 hops Feb 9 12;43;15.311;RIP;sending v1 flash update to via Loopback0( ) Feb 9 12;43;15.311;RIP;build flash updata entries Feb 9 12;43;15.311; network metric 4 Feb 9 12;43;15.311; network metric 1 Feb 9 12;43;15.311; network metric 2 Feb 9 12;43;15.311; network metric 3 Feb 9 12;43;15.311;RIP;sending v1 flash update to via Serial0/0/0( )

59 Feb 9 12;43;15.311;RIP;build flash updata entries Feb 9 12;43;15.311; network metric 1 通过以上输出, 可以看到 RIPv1 采用广播更新 ( ), 分别向 Loopback 0 和 s0/0/0 发送路由更新, 同时从 s0/0/0 接收 3 条路由更新, 分别是 , 度量值是 3 跳 ; , 度量值是 2 跳 ; , 度量值是 1 跳. 技术要点 Flash Update( 闪式更新 ) 指的是当网络上某个路径的度量值发生变化时, 路由器立即发出更新信息, 而不管是否到达常规路由信息更新的周期 实验 2: 被动接口与单播更新 1. 实验目的通过本实验可以掌握 : (1) 被动接口的含义 配置和应用场合 ; (2) 单播更新的应用场合和配置 2. 拓扑结构实验拓扑如图 4-2 所示 图 4-2 配置被动接口由于以太口 g0/0 和 g0/1 连接主机, 不需要向这些接口发送路由更新, 所以, 可以考虑将路由器的该接口设置为被动接口 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router rip R1(config-router)#version 1 R1(config-router)#network R1(config-router)#network R1(config-router)#network R1(config-router)#passive-interface GigabitEthernet0/0

60 R1(config-router)#passive-interface GigabitEthernet0/1 (2) 步骤 2: 配置路由器 R2 R1(config)#router rip R1(config-router)#version 1 R1(config-router)#network R1(config-router)#network 实验调试 R1#debug ip rip R1#clear ip route * Feb 9 13;24;41.275;RIP;sending request on Serial0/0/0 to Feb 9 13;24;41.283;RIP;received v1 update from on Serial0/0/0 Feb 9 13;24;41.283; in 1 hops Feb 9 13;24;43.275;RIP;sending v1 flash update to via Serial0/0/0( ) Feb 9 13;24;43.275;RIP;build flash updata entries Feb 9 13;24;43.275; network metric 1 Feb 9 13;24;43.275; network metric 1 从以上输出可以看出, 路由器 R1 确实不向被动接口 g0/0 和 g0/1 发送路由更新 技术要点 被动接口只能接收路由更新, 不能以广播或组播方式发送更新, 但是可以以单播的方式发送更新, 配置单播更新的命令如下 : R1(config-router)#neighbor A.B.C.D 实例 如图 4-3 所示, 路由器 R1 只想把路由更新送到路由器 R3 上, 由于 RIPv1 路由协议采用广播更新, 在默认情况下, 路由更新将发送给以太网上任何一台设备 为了防止这种情况发生, 把路由器 R1 的 g0/0 配置成被动接口 然而, 路由器 R1 还想把路由更新发送给 R3, 这时必须采用单播更新, 为指定的相信路由器 R3 发送路由更新 路由器 R1 具体的配置如下 : 图 4-3 配置单播更新

61 R1(config)#router rip R1(config-router)#passive-interface GigabitEthernet0/0 R1(config-router)#neighbor 实验 3: 使用子网地址 1. 实验目的通过本实验可以掌握 : 1RIPv1 使用子网地址的条件 ; 2RIPv1 接收子网路由的原则 2. 拓扑结构实验拓扑如图 4-4 所示 图 4-4 RIPv1 使用子网地址 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router rip R1(config-router)#version 1 R1(config-router)#network (2) 步骤 2: 配置路由器 R2 R1(config)#router rip R1(config-router)#version 1 R1(config-router)#network 实验调试分别查看 R1 和 R2 的路由表 R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

62 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C C R /24 is subnetted, 3 subnets is directly connected, Loopback is directly connected, Serial0/0/ [120/1] via , 00;00;03, Serial0/0/0 R2#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set /24 is subnetted, 3 subnets R [120/1] via , 00;00;21, Serial0/0/0 C is directly connected, Loopback0 C is directly connected, Serial0/0/0 从路由器 R1 和 R2 的路由表输出可以看出, 它们互相学习到了 24 位的路由条目, 从而可以说明, 在某些情况下,RIPv1 更新确实可以携带子网信息 技术要点 RIPv1 路由更新可以携带子网信息必须同时满足以下两个条件 : 1 整个网络所有地址在同一个主类网络 ; 2 子网掩码长度必须相同 思考 假设在图 4-4 中, 路由器 R2 的 s0/0/0 接口的 IP 地址的掩码长度为 25 位, 那么 R2 的路由表是怎样的呢? 结果如下 : R2#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

63 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set /16 is variably subnetted, 3 subnets,2masks R /25 [120/1] via , 00;00;17, Serial0/0/0 C is directly connected, Loopback0 C is directly connected, Serial0/0/0 由此得出 RIPv1 接收子网路由的原则 : 如果路由器收到的是子网路由条目, 就以接收该路由条目的接口的掩码长度作为该子网路由条目的掩码长度 4.3 RIPv 实验 4:RIPv2 基本配置 1. 实验目的通过本实验可以掌握 : 1 在路由器上 RIPv2 路由进程 ; 2 启用参与路由协议的接口, 并且通告网络 ; 3auto-summary 的开启和关闭 ; 4 查看和调试 RIPv2 路由协议相关信息 2. 拓扑结构实验拓扑图如图 4-1 所示 3. 实验步骤 : (1) 步骤 1: 配置路由器 R1 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#network

64 (2) 步骤 2: 配置路由器 R2 R2(config)#router rip R2(config-router)#version 2 R3(config-router)#no auto-summary R2(config-router)#network R2(config-router)#network (3) 步骤 3: 配置路由器 R3 R3(config)#router rip R3(config-router)#version 2 R3(config-router)#no auto-summary R3(config-router)#network R3(config-router)#network (4) 步骤 4: 配置路由器 R4 R4(config)#router rip R4(config-router)#version 2 R4(config-router)#no auto-summary R4(config-router)#network R4(config-router)#network 实验调试 (1)show ip route R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C C R R /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets is directly connected, Loopback /8 is variably subnetted,2 subnets, 2 mask /24 [120/3] via , 00;00;22, Serial0/0/ /24 [120/1] via , 00;00;22, Serial0/0/0

65 R /24 [120/2] via , 00;00;22, Serial0/0/0 从上面输出的路由条目 /24 可以看到,RIPv2 路由更新是携带子网信息的 (2)show ip protocols R1#show ip protocols Routing Protocol is rip Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Sending updates every 30 seconds, next due in 19 seconds Invalid after 180 seconds, hold down 180, flushed after 240 Redistributing; rip Default version control; send version 2, receive version 2 Interface Send Recv Triggered RIP Key-chain Serial0/0 2 2 Loopback0 2 2 //RIPv2 在默认情况下只接收和发送版本 2 的路由更新 提示 可以通过命令 ip rip send version 和 ip rip receive version 来控制在路由器接口上接收和发送的版本 例如, 在 s0/0/0 接口上接收版本 1 和版本 2 的路由更新, 但是只发送版本 2 的路由更新, 配置如下 R1(config-if)#ip rip send version 2 R1(config-if)#ip rip receive version 1 2 注意 接口特性是优于进程特性的, 对于本实验, 虽然在 RIP 进程中配置了 version 2, 但是, 如果在接口上配置了 ip rip receive version 1 2, 则该接口可以接收版本 1 和版本 2 的路由更新 Automatic network summarization is in effect Maximum path; 4 Routing for Networks; Routing Information Sources; Gateway Distance Last Update ;00;26 Distance; (default is 120)

66 4.3.2 实验 5:RIPv2 手工汇总 1. 实验目的通过本实验可以掌握 : 1RIPv2 路由的手工汇总 ; 2RIPv2 不支持 CIDR 汇总 ; 3RIPv2 可以传递 CIDR 汇总 2. 拓扑结构实验拓扑如图 4-5 所示 图 4-5 RIPv2 路由手工汇总 2. 实验步骤路由器 R1 R2 和 R3 的配置和 节实验 4 相同 R4 的配置如下 : R4(config)#router rip R4(config-router)#version 2 R4(config-router)#no auto-summary R4(config-router)#network R4(config-router)#network R4(config)#interface s0/0/0 R4(config-if)#ip summary-address rip //RIP 手工路由汇总 4. 实验调试 1 在没有执行汇总之间路由器 R1 的路由表如下 : R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route

67 o - ODR, P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /24 is subnetted, 4 subnets R [120/3] via , 00;00;21, Serial0/0/0 R [120/3] via , 00;00;21, Serial0/0/0 R [120/3] via , 00;00;12, Serial0/0/0 R [120/3] via , 00;00;05, Serial0/0/0 R /24 [120/1] via , 00;00;21, Serial0/0/0 R /24 [120/2] via , 00;00;22, Serial0/0/0 从上面的输出看到, 路由器 R1 的路由表中有 R4 的 4 条环回接口的明细路由 2 在执行汇总以后路由器 R1 的路由表如下 : R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /22 is subnetted, 1 subnets R [120/3] via , 00;00;21, Serial0/0/0 R /24 [120/1] via , 00;00;21, Serial0/0/0 R /24 [120/2] via , 00;00;22, Serial0/0/0 上面的输出表明, 在路由器 R1 的路由接收到了汇总路由, 当然 R2 和 R3 上也能收到汇总路由 思考 现在将路由器 R4 上 4 个环回接口 Lo0~LO3 的地址分别修改为 /24, /24, /24 和 /24, 在 s0/0/0 接口下还能够实现路由汇总吗? 在 R4 上做如下的配置 :

68 R4(config)#router rip R4(config-router)#network R4(config-router)#network R4(config-router)#network R4(config-router)#network R4(config-if)#ip summary-address rip 路由器会提示如下信息 : Summary mask must be greater or equal to major net 显示的提示信息表明汇总后的掩码升序必须要大于或等主类网络的掩码长度, 因为 22<24, 所以不能汇总 所以,RIPv2 不支持 CIDR 汇总, 但是可以传递 CIDR 汇总 解决方案如下 : (1) 用静态路由发布被汇总的路由 R4(config)#ip route null0 (2) 将静态路由重分布到 RIP 网络中 R4(config)#router rip R4(config-router)#redistibute static // 将静态路由重分布到 RIP 网络中 R4(config-router)#no network R4(config-router)#no network R4(config-router)#no network R4(config-router)#no network (3) 在路由器 R1 上查看路由表 R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C C R /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets is directly connected, Loopback /24 [120/1] via , 00;00;18, Serial0/0/0

69 R /24 [120/2] via , 00;00;18, Serial0/0/0 R /22 [120/2] via , 00;00;18, Serial0/0/0 通过输出不难看出,RIPv2 是可以传递 CIDR 汇总信息的 实验 6:RIPv2 认证和触发更新 1. 实验目的通过本实验可以掌握 : 1RIPv2 明文认证的配置和匹配原则 ; 2RIPv2 MD5 认证的配置和匹配原则 ; 3RIPv2 触发更新 2. 拓扑结构 图 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#key chain test // 配置钥匙链 R1(config-keychain)#key 1 // 配置 KEY ID R1(config-keychain-key)#key-string cisco // 配置 KEY ID 的密匙 R1(config)#interface s0/0/0 R1(config-if)#ip rip authentication mode text // 启用认证, 认证模式为明文, 默认认证模式就是明文, 所以也可以不用指定 R1(config-if)#ip rip authentication key-chain test // 在接口上调用钥匙链 R1(config-if)#ip rip triggered // 在接口上启用触发更新 (2) 步骤 2: 配置路由器 R2 R2(config)#key chain test R2(config-keychain)#key 1 R2(config-keychain-key)#key-string cisco R2(config)#interface s0/0/0 R2(config-if)#ip rip triggered R2(config-if)#ip rip authentication key-chain test R2(config)#interface s0/0/1 R2(config-if)#ip rip authentication key-chain test R2(config-if)#ip rip triggered

70 (3) 步骤 3: 配置路由器 R3 R3(config)#key chain test R3(config-keychain)#key 1 R3(config-keychain-key)#key-string cisco R3(config)#interface s0/0/0 R3(config-if)#ip rip authentication key-chain test R3(config-if)#ip rip triggered R3(config)#interface s0/0/1 R3(config-if)#ip rip authentication key-chain test R3(config-if)#ip rip triggered (4) 步骤 4: 配置路由器 R4 R4(config)#key chain test R4(config-keychain)#key 1 R4(config-keychain-key)#key-string cisco R4(config)#interface s0/0/0 R4(config-if)#ip rip authentication key-chain test R4(config-if)#ip rip triggered 4. 实验调试 (1)show ip protocols R2#show ip protocols Routing Protocol is rip Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Sending updates every 30 seconds, next due in 4 seconds Invalid after 180 seconds, hold down 0, flushed after 240 // 由于触发更新,hold down 0,flushed after 240 Redistributing; rip Default version control; send version 2, receive version 2 Interface Send Recv Triggered RIP Key-chain Serial0/0/0 2 2 Yes teset Serial0/0/1 2 2 Yes teset // 以上两行表明 s0/0/0 和 s0/0/1 接口启用了认证和触发更新 Automatic network summarization is in effect Maximum path; 4 Routing for Networks;

71 Routing Information Sources; Gateway Distance Last Update ;26; ;26;01 Distance; (default is 120) (2)debug ip rip R2#debug ip rip RIP protocol debugging is on R2#clear ip route * *Feb 11 13;51;31.827;RIP;sending triggered request on Serial0/0/0 to *Feb 11 13;51;31.831;RIP;sending triggered request on Serial0/0/1 to *Feb 11 13;51;31.843;RIP;sending triggered request on Serial0/0/0 to *Feb 11 13;51;31.847;RIP;sending triggered request on Serial0/0/1 to *Feb 11 13;51;31.847;RIP;send v2 triggered flush update to on Serial0/0/0 with no route *Feb 11 13;51;31.851;RIP;start retransmit timer of *Feb 11 13;51;31.855;RIP;send v2 triggered flush update to on Serial0/0/1 with no route *Feb 11 13;51;31.855;RIP;start retransmit timer of *Feb 11 13;51;32.019;RIP;received packet with text authentication cisco *Feb 11 13;51;32.019;RIP;received v2 triggered update from on Serial0/0/0 *Feb 11 13;51;32.023;RIP;sending v2 ack to via Serial0/0/0( ) flush,seq#1 *Feb 11 13;51;32.027; /24 via in 1 hops *Feb 11 13;51;32.031;RIP;received packet with text authentication cisco *Feb 11 13;51;32.035;RIP;received v2 triggered update from on Serial0/0/1 *Feb 11 13;51;32.035;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#2 *Feb 11 13;51;32.039; /24 via in 1 hops *Feb 11 13;51;32.043; /24 via in 2 hops *Feb 11 13;51;32.071;RIP;received packet with text authentication cisco *Feb 11 13;51;32.071;RIP;received v2 triggered update from on Serial0/0/1 *Feb 11 13;51;32.071;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#3 *Feb 11 13;51;32.075; /24 via in 1 hops *Feb 11 13;51;32.079; /24 via in 2 hops *Feb 11 13;51;32.083;RIP;received packet with text authentication cisco *Feb 11 13;51;32.083;RIP;sending v2 triggered ack from on Serial0/0/1 flush,seq#2 *Feb 11 13;51;32.087;RIP;send v2 triggered update to on Serial0/0/1 *Feb 11 13;51;32.087;RIP;build update entriec *Feb 11 13;51;32.091; route 172; /24 metric 1,tag 0

72 *Feb 11 13;51;32.091; route 181; /24 metric 2,tag 0 *Feb 11 13;51;32.095;RIP;Update contains 2 routes,start 176,end 188 *Feb 11 13;51;32.095;RIP;start retransmit timer of *Feb 11 13;51;32.099;RIP;received packet with text authentication cisco *Feb 11 13;51;32.099;RIP;received v2 triggered update from on Serial0/0/0 *Feb 11 13;51;32.103;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#2 *Feb 11 13;51;32.107; /24 via in 1 hops *Feb 11 13;51;32.107;RIP;received packet with text authentication cisco *Feb 11 13;51;32.111;RIP;received v2 triggered ack from on Serial0/0/0 flush,seq#3 *Feb 11 13;51;32.111;RIP;send v2 triggered update to on Serial0/0/0 *Feb 11 13;51;32.115;RIP;build update entriec *Feb 11 13;51;32.115; route 178; /24 metric 1,tag 0 *Feb 11 13;51;32.119; route 184; /24 metric 2,tag 0 *Feb 11 13;51;32.123; route 187; /24 metric 3,tag 0 *Feb 11 13;51;32.123;RIP;Update contains 3 routes,start 178,end 188 *Feb 11 13;51;32.123;RIP;start retransmit timer of *Feb 11 13;51;32.263;RIP;received packet with text authentication cisco *Feb 11 13;51;32.263;RIP;received v2 triggered ack from on Serial0/0/1 flush,seq#3 *Feb 11 13;51;32.267;RIP;received packet with text authentication cisco *Feb 11 13;51;32.271;RIP;received v2 triggered ack from on Serial0/0/0 seq#4 从上面的输出可以看出, 在路由器 R2 上, 虽然我们打开了 debug ip rip, 但是由于采用触发更新, 所以并没有看到每 30 s 更新一次的信息, 而是清除了路由表这件事件解发了路由更新, 而且所有的更新中都有 triggered 的字样, 同时在接收的更新中带有 text authentication 字样, 证明接口 s0/0/0 和 s0/0/1 启用了触发更新和明文认证 (3)show ip rip database R2#show ip rip database /8 auto-summary /24 [1]via ,00;12;22(permanent),Serial0/0/0 *Triggered Routes: -[1]via , Serial0/0/ /8 auto-summary /24 [2]via ,00;12;22(permanent),Serial0/0/1 *Triggered Routes:

73 -[2]via , Serial0/0/ /24 auto-summary /24 directly connected,serial0/0/ /24 auto-summary /24 directly connected,serial0/0/ /24 auto-summary /24 [1]via ,00;12;22(permanent),Serial0/0/1 *Triggered Routes: -[1]via , Serial0/0/1 以上输出进一步说明了在 s0/0/0 和 s0/0/1 启用了触发更新 (4)show run R2#show run begin router rip router rip version 2 timers basic // 由于触发更新, 在配置中自动加入上面一行, 且 hold down 计时器被设置为 0 network network no auto-summary 关于 MD5 认证, 只需在接口下声明认证模式为 MD5 即可 例如, 在 R1 上的配置如下 : R1(config)#key chain test // 定义钥匙链 R1(config-keychain)#key 1 R1(config-keychain-key)#key-string cisco R1(config)#interface s0/0/0 R1(config-if)#ip rip authentication mode md5 R1(config-if)#ip rip authentication key-chain test 其他的配置和明文认证相同, 这里不再赘述 当在 R2 上执行 debug ip rip 时, 显示如下类似信息 : *Feb 11 14;04;36.851;RIP;sending triggered request on Serial0/0/0 to *Feb 11 14;04;36.855;RIP;sending triggered request on Serial0/0/1 to *Feb 11 14;04;36.867;RIP;sending triggered request on Serial0/0/0 to *Feb 11 14;04;36.871;RIP;sending triggered request on Serial0/0/1 to *Feb 11 14;04;36.871;RIP;send v2 triggered flush update to on Serial0/0/0 with no route *Feb 11 14;04;36.875;RIP;start retransmit timer of *Feb 11 14;04;36.875;RIP;send v2 triggered flush update to on Serial0/0/1 with no route *Feb 11 14;04;36.879;RIP;start retransmit timer of *Feb 11 14;04;36.927;RIP;received packet with MD5 authentication

74 *Feb 11 14;04;36.931;RIP;received v2 triggered update from on Serial0/0/1 *Feb 11 14;04;36.931;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#4 *Feb 11 14;04;36.935; /24 via in 1 hops *Feb 11 14;04;36.943; /24 via in 2 hops *Feb 11 14;04;36.947;RIP;received packet with MD5 authentication *Feb 11 14;04;36.947;RIP;received v2 triggered update from on Serial0/0/0 *Feb 11 14;04;36.951;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#3 *Feb 11 14;04;36.955; /24 via in 1 hops *Feb 11 14;04;36.959;RIP;received packet with MD5 authentication *Feb 11 14;04;36.959;RIP;received v2 triggered update from on Serial0/0/0 *Feb 11 14;04;36.963;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#4 *Feb 11 14;04;36.967; /24 via in 1 hops *Feb 11 14;04;36.967;RIP;received packet with MD5 authentication *Feb 11 14;04;36.971;RIP;received v2 triggered ack from on Serial0/0/0 flush,seq#5 *Feb 11 14;04;36.971;RIP;send v2 triggered update to on Serial0/0/0 *Feb 11 14;04;36.975;RIP;build update entriec *Feb 11 14;04;36.975; route 191; /24 metric 1,tag 0 *Feb 11 14;04;36.979; route 181; /24 metric 2,tag 0 *Feb 11 14;04;36.979; route 181; /24 metric 3,tag 0 *Feb 11 14;04;36.983;RIP;Update contains 3 routes,start 191,end 201 *Feb 11 14;04;36.983;RIP;start retransmit timer of *Feb 11 14;04;36.991;RIP;received packet MD5 text authentication *Feb 11 14;04;36.991;RIP;received v2 triggered update from on Serial0/0/1 *Feb 11 14;04;36.991;RIP;sending v2 ack to via Serial0/0/1( ) flush,seq#5 *Feb 11 14;04;36.999; /24 via in 1 hops *Feb 11 14;04;36.999; /24 via in 2 hops *Feb 11 14;04;37.003;RIP;received packet with MD5 authentication *Feb 11 14;04;37.003;RIP;received v2 triggered ack from on Serial0/0/1 flush,seq#4 *Feb 11 14;04;37.007;RIP;send v2 triggered update to on Serial0/0/1 *Feb 11 14;04;37.007;RIP;build update entriec *Feb 11 14;04;37.011; route 189; /24 metric 1,tag 0 *Feb 11 14;04;37.015; route 200; /24 metric 2,tag 0 *Feb 11 14;04;37.015;RIP;Update contains 2 routes,start 189,end 201 *Feb 11 14;04;37.019;RIP;start retransmit timer of *Feb 11 14;04;37.059;RIP;received packet with MD5 authentication

75 *Feb 11 14;04;37.059;RIP;received v2 triggered ack from on Serial0/0/0 seq#6 *Feb 11 14;04;37.067;RIP;received packet with MD5 authentication *Feb 11 14;04;37.071;RIP;received v2 triggered ack from on Serial0/0/1 seq#5 以上输出信息表明采用了 MD5 认证和触发更新 技术要点 1 在以太网接口下, 不支持触发更新 ; 2 触发更新需要协商, 链路的两端都需要配置 ; 3 在认证的过程中, 如果定义多个 Key ID, 明文认证和 MD5 认证的匹配原则是不一样的 A. 明文认证的匹配原则 发送方发送最小 Key ID 的密钥 ; 不携带 Key ID 号码 ; 接收方会和所有 Key Chain 中的密钥匹配, 如果匹配成功, 则通过认证 A. 明文认证的匹配发送方发生最小 KeyID 的密钥 : 不携带 KeyID 号码 : 接收方会和所有 Key Chain 中的密钥匹配, 如果匹配成功, 则通过认证 实例 1 路由器 R1 有 1 个 Key ID,key1=cisco 路由器 R2 有 2 个 Key ID,key1=ccie,key2=cisco 根据上面的原则,R1 认证失败,R2 认证成功 所以, 在 RIP 中出现单边路由并不稀奇 B.MD5 认证的匹配原则 发送方发送最小 Key ID 的密钥 ; 携带 Key ID 号码 ; 接收方首先会查找是否有相同的 Key ID, 如果有, 只匹配一次, 决定认证是否成功 如果没有该 Key ID, 只向下查找下一跳 : 若匹配, 则认证成功 ; 若不匹配, 则认证失败 实例 2 路由器 R1 有 3 个 Key ID,key1=cisco,key3=ccie,key5=cisco 路由器 R2 有 1 个 Key ID,,key2=cisco 根据上面的原则,R1 认证失败,R2 认证成功 实验 7: 浮动静态路由 1. 实验目的通过本实验可以掌握浮动静态路由的原理 配置以及备份应用 2. 拓扑结构实验拓扑如图 4-6 所示

76 图 4-6 浮动静态路由 3. 实验步骤本实验通过修改静态路由的管理距离为 130, 使得路由器在选中时优先选择 RIP, 而静态路由作为备份 (1) 步骤 1: 配置路由器 R1 R1(config)#ip route // 将静态路由的管理距离设置为 130 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#network (2) 步骤 2: 配置路由器 R2 R2(config)#ip route R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)#network R2(config-router)#network 实验调试 (1) 在 R1 上查看路由表 R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route

77 Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /24 is subnetted, 1 subnets R [120/1] via , 00;00;25, GigabitEthernet0/0 C /24 is directly connected, GigabitEthernet0/0 从以上输出可以看出, 路由器将 RIP 的路由放入路由表中, 因为 RIP 的管理距离为 120, 小于在静态路由中设定的 130, 而静态路由处于备份的地位 (2) 在 R1 上将 g0/0 接口关闭 (shutdown), 然后查看路由表 R1(config)#interface gigabitethernet0/0 R1(config-if)#shutdown R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /24 is subnetted, 1 subnets S [130/0] via 以上输出说明, 当主路由中断后, 备份的静态路由被放入到路由表中, 也很好地解释了浮动静态路由作为备份的工作原理 (3) 在 R1 上将 g0/0 接口启动, 然后查看路由表 R1(config)#interface gigabitethernet0/0 R1(config-if)#no shutdown R1#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2

78 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /24 is subnetted, 1 subnets R [120/1] via , 00;00;25, GigabitEthernet0/0 C /24 is directly connected, GigabitEthernet0/0 以上输出表明, 当主路由恢复后, 浮动静态路由又恢复到备份的地位 实验 8:ip default-network 1. 实验目的通过本实验可以掌握如何通过 ip default-network 向网络中注入一条默认路由 2. 拓扑结构实验拓扑图如图 4-7 所示 图 4-7 ip default-network 向 RIP 网络中注入默认路由 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network R1(config)#ip default-network

79 (2) 步骤 2: 配置路由器 R2 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network R1(config)#ip default-network 实验调试 (1) 在 R2 上查看路由表 R2#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is to network // 表明默认路由的网关为 C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback0 R* [120/1] via , 00;00;22, Serial0/0/0 从以上输出可以看出 R1 上的 ip default-network 命令确实向 RIP 网络中注入一条 R* 的默认路由 (2) 在 R2 上 ping R2#ping Type escape sequence to abort. Sending 5,100-byte ICMP Echos to ,timeout is 2 seconds;!!!!! Success rate is 100 percent(5/5),round-trip min/avg/max = 12/14/16 ms 以上输出表明, 在路由器 R2 上可以 ping 通地址 , 虽然在 R1 的 RIP 进程中没有通告该网络, 也恰恰说明是默认路由起了作用 因为在 R2 的路由表中没有 的路由条目, 所以是不可能 ping 通该 的

80 技术要点 1ip default-network 后面的网络一定要是主类网络 ; 2ip default-network 后面的网络可以是直连的或者通过其他协议学到的网络 4.4 RIP 命令汇总 表 4-2 列出了本章所涉及的主要命令 表 4-2 RIP 命令汇总命令 show ip route show ip protocols show ip rip database debug ip rip clear ip route * route rip network version no auto-summary ip rip send version ip rip receive version passive-interface neighbor ip summary-address rip key chain key key-id key-string ip rip triggered ip rip authentication mode ip rip authention key-chain timers basic maximum-paths ip default-network 作用查看路由表查看 IP 路由协议配置和统计信息查看 RIP 数据库动态查看 RIP 的更新过程清除路由表启动 RIP 进程通告网络定义 RIP 的版本关闭自动汇总配置 RIP 发送的版本配置 RIP 接收的版本配置被动接口配置单播更新的目标配置 RIP 手工汇总定义钥匙链配置 Key ID 配置 Key ID 的密匙配置触发更新配置认证模式配置认证使用的钥匙链配置更新的计时器配置等价路径的最大值向网络中注入默认路由

81 第 5 章 EIGRP EIGRP(Enhanced Interior Gateway Routing Protocol, 增强型内部网关路由协议 ) 是 Cisco 公司开发的一个平衡混合型路由协议, 它融合了距离向量和链路状态两种路由协议的优点, 支持 IP,IPX 和 ApplleTalk 等多种网络层协议 由于 TCP/IP 是当今网络中最常用的协议, 因此本书只讨论 IP 网络环境中的 EIGRP 5.1 EIGRP 概述 EIGRP 是一个高效的路由协议, 它的特点如下 : 1 通过发送和接收 Hello 包建立和维持邻居关系, 并交换路由信息 ; 2 采用组播 ( ) 或单播进行路由更新 ; 3 EIGRP 的管理距离为 90 或 170; 4 采用触发更新, 减少带宽战胜 ; 5 支持可变长子网掩码 (VLSM), 默认开启自动汇总功能 ; 6 支持 IP,IPX 和 ApplleTalk 等多种网络层协议 ; 7 对每一种网络协议,EIGRP 都维持独立的邻居表 拓扑表和路由表 ; 8 EIGRP 使用 Diffusing Update 算法 (DUAL) 来实现快速收敛并确保没有路由环路 ; 9 存储整个网络拓扑结构的信息, 以便快速适应网络变化 ; 10 支持等价和非等价的负载均衡 ; 11 使用可靠传输协议 (RTP) 保证路由信息传输的可靠性 ; 12 无缝连接数据链路层协议和拓扑结构,EIGRP 不要求对 OSI 参考模型的 2 层协议进行特别的配置 5.2 实验 1:EIGRP 基本配置 1. 实验目的通过本实验可以掌握 1 在路由器上启动 EIGRP 路由进程 ; 2 启用参与路由协议的接口, 并且通告网络 ; 3 EIGRP 度量值的计算方法 ; 4 可行距离 (FD) 通告距离 (RD) 以及可行性条件 (FC); 5 邻居表 拓扑以及路由表的含义 ; 6 查看和调试 EIGRP 路由协议相关信息

82 2. 实验拓扑本实验拓扑结构如图 5-1 所示 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router eigrp 1 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#network (2) 步骤 2: 配置路由器 R2 R2(config)#router eigrp 1 R2(config-router)#no auto-summary R2(config-router)#network R2(config-router)#network (3) 步骤 3: 配置路由器 R3 R3(config)#router eigrp 1 R3(config-router)#no auto-summary R3(config-router)#network R3(config-router)#network (4) 步骤 4: 配置路由器 R4 R4(config)#router eigrp 1 R4(config-router)#no auto-summary R4(config-router)#network R4(config-router)#network 图 5-1 EIGRP 基本配置 说明 EIGRP 协议在通告网段时, 如果是主类网络 ( 即标准 A B C 类的网络, 或者说没有划分子网的网络 ), 只需输入此网络地址 ; 如果是子网, 则最好在网络号后面写子网掩码, 或者反掩码, 这样可以避免将所有的子网都加入 EIGRP 进程中

83 反掩码是用广播地址 ( ) 减去子网掩码所得到的 如掩码地址是 , 则反掩码地址是 在高级的 IOS 中也支持网络掩码的写法 运行 EIGRP 的整个网络 AS 号码必须一致, 其范围为 1~ 实验调试 (1)show ip route R2#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /24 is subnetted, 1 subnets D /24[90/ ]via ,00;04;19, Serial0/0/ /16 is subnetted, 1 subnets D /24[90/ ]via ,00;00;06, Serial0/0/1 C /24 is directly connected, Serial0/0/1 D /24[90/ ]via ,00;05;34, Serial0/0/1 // 以上输出表路由器 R2 通过 EIGRP 尝到了 3 条路由条目, 管理距离是 90, 注意 EIGRP 协议代码用字母 D 表示, 如果通过重分布方式进入 EIGRP 网络的路由条目, 默认管理距离为 170, 路由代码用 D EX 表示, 这也说明 EIGRP 路由协议能够区分内部路由和外部路由 对于 EIGRP 度量值的计算, 不妨以 D /24[90/ ]via ,00;04;19, Serial0/0/0 路由条目为例来说明 EIGRP 度量值的计算公式 =[K1*Bandwidth+(K2+Bandwidth)/(256-Load)+K3+Delaly]*[K5/(Reliability+K4)]*256 在默认情况下,K1=K3=1,K2=K4=K5=0 Bandwidth=10 7 / 所经由链路中入口带宽 ( 单位为 kbps) 的最小值 Delay= 所经由链路中入口的延迟为 ( 单位为 us)/10 接下来看一下在路由器 R2 中的 路由条目的度量是如何计算的 首先, 带宽应该是从 R1 的 Loopback 0 到 R2 最小的带宽, 应该是 R2 的 s0/0/0 接口的带宽, 为 128kbps; 而延迟是路由器 R1 的 Loopback 0 和路由器 R2 的 s0/0/0 接口的延迟之和,

84 所以, 最后的度量值应该是 [10 7 /128+( )/10]*256 = , 和路由器计算的结果是一致的 提示 接口的带宽和延迟可以通过 show interface 查看 (2)show ip protocols R2#show ip protocols Routeing Protocol is eigrp 1 //AS 号码为 1 Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Default networks flagged in outgoing updates Default networks accepted from incoming updates EIGRP metric weight K1=1,K2=0,K3=1,K4=0,K5=0 // 显示计算度量值所用的 K 值 EIGRP maximum hopcount 100 //EIGRP 支持的最大路数 EIGRP maximum metric variance 1 //variance 值默认为 1, 即默认时只支持等价路径的负载均衡 Redistributing;eigrp 1 EIGRP NSF-aware route hold timer is 240s // 不间断转发的持续时间 Automatic network summarization is not int effect // 显示自动灡地, 默认自动总是开启的 Maximum path;4 Routing for Networks; Routing Information Sources; Gateway Distance Last Update ;10; ;10;15 Distance;internal 90 external 170 (3)show ip eigrp neighbors R2# show ip eigrp neighbors IP-EIGRP neighbors for process 1 H Address Interface Hold Uptime SRTT RTO Q Seq (Sec) (ms) Cnt Num Se0/0/ ;11; Se0/0/ ;11;

85 以上输出各字段的含义如下所述 1 H; 表示与邻居建立会的顺序 ; 2 Address; 邻居路由器的接口地址 ; 3 Interface; 本地到邻居路由器的接口 ; 4 Hold; 认为邻居关系不存在所能等待的最长时间 ; 5 Uptime; 从邻居关系建立到目前的时间 6 SRTT; 是向邻居路由器发送一个数据包到本路由器收到确认包的时间 ; 7 RTO; 路由器在重新传输包之前等待 ACK 的时间 ; 8 Q Cnt; 等待发送的队列 ; 9 Seq Num; 从邻居收到的发送数据包的序列号 技术要点 运行 EIGRP 路由协议的路由器不能建立邻居关系的可能原因 : 1 EIGRP 进程的 AS 号码不同 ; 2 计算度量值的 K 值不同 (4)show ip eigrp topology R2# show ip eigrp topology IP-EIGRP Topology Table for AS(1)/ID( ) Codes;P-Passive, A-Active, U-Update, Q-QUERY, R- Reply, r-reply Status, s-sia Status P /24, 1 successors, FD is via ( /128256),Serial0/0/0 P /24, 1 successors, FD is via ( / ),Serial0/0/1 P /24, 1 successors, FD is via ( / ),Serial0/0/1 P /24, 1 successors, FD is via Connected,Serial0/0/0 P /24, 1 successors, FD is via Connected,Serial0/0/1(5)show ip eigrp interface 从以上输出可以清楚地看到每条路由条目的 FD 和 RD 的值, 而拓扑结构数据库中状态代码最常见的是 P, A 和 s, 其含义如下所述 1 P; 代表 passive, 表示网络处于收敛的稳定状态 ; 2 A; 代表 active, 当前网络不可用, 正处于发送查询状态 ; 3 s: 在 3min 内, 如果被查询的路由没有收到回应, 查询的路由就被置为 stuck in active 状态

86 4 术语 1 可行距离 (FD); 到达一个目的网络的最小度量值 ; 2 通告距离 (RD); 邻居路由器所通告的它自己到达目的网络的最小度量值 ; 3 可行性条件 (FC); 是 EIGRP 路由器更新路由表和拓扑表的依据, 可行性条件可以有效地阻止路由环路, 实现路由的快速收敛, 可行性条件的公式为 :RD<FD (5)show ip eigrp interfaces R2# show ip eigrp interfaces IP-EIGRP interfaces for process 1 Xmit Queue Mean Pacing Time Multicast Pending Interface Peers Un/reliable SRTT Un/Reliable Flow Timer Routes Se0/0/0 1 0/0 7 5/ Se0/0/1 1 0/0 7 5/ 以上输出各字段的含义如下所述 1 Interface; 运行 EIGRP 协议的接口 ; 2 Peers; 该接口邻居的个数 ; 3 Xmit Queue Un/Reliable; 在不可靠 / 可靠队列中存留的数据包的数量 ; 4 Mean SRTT; 平均的往返时间, 单位是 s; 5 Pacing Time Un/Reliable; 用业确定不可靠 / 可靠队列中数据包被送出接口的时间间隔 ; 6 Multicast Flow Timer; 组播数据包被发送前最长的等待时间 ; 7 Pending Routes; 在传送队列中等待被发送的数据包拾的路由条目 (6)show ip eigrp traffic R2# show ip eigrp traffic IP-EIGRP Traffic Statistics for AS 1 Hellos sent/received;364/361 Updates sent/received;10/8 Queries sent/received;0/0 Replies sent/received;0/0 Acks sent/received;4/5 Input queue high water mark 1, 0 drops SIA-Queries sent/received;0/0 SIA-Replies sent/received;0/0 Hello Process ID;187 PDM Process ID;167 以上输出显示了 EIGRP 发送和接收到的数据包的统计情况 (7)debug eigrp neighbors 该命令可以动态查看 EIGRP 邻居关系的情况 在路由器 R1 上先将 s0/0/0 接口 shutdown

87 ( 关闭 ) 掉, 然后再 no shutdown )( 启用 ) 可以看到 EIGRP 邻居建立的过程 R2# debug eigrp neighbors EIGRP Neighbors debugging is on *Feb 10 02;59;31.199;%LINK-3-UPDOWN;Interface Serial0/0/0,changed state to down *Feb 10 02;59;31.199;%DUAL-5-NBRCHANGE;IP-EIGRP(0)1;Neighbor (Serial0/0/0) is down; interface down *Feb 10 02;59;31.199;Going down;peer total=1 stub 0 template=1,iidb-stub=0 iid-all=0 *Feb 10 02;59;31.199;EIGRP;Neighbor went down on Serial0/0/0 *Feb 10 02;59;32.199;%LINEPROTO-5-UPDOWN;Line protocol on Interface Serial0/0/0,changed state to down *Feb 10 02;59;48.199;%LINK-3-UPDOWN;Interface Serial0/0/0,changed state to up *Feb 10 02;59;49.199;%LINEPROTO-5-UPDOWN;Line protocol on Interface Serial0/0/0,changed state to up *Feb 10 02;59;49.199;EIGRP;New peer total=2 stub 0 template=1,iidb-stub=0 iid-all=1 *Feb 10 02;59;31.199;%DUAL-5-NBRCHANGE;IP-EIGRP(0)1;Neighbor (Serial0/0/0) is up; new adjacency (8)debug eigrp packets 该命令可以显示 EIGRP 发送和接收的数据包 R2#dubug eigrp packets EIGRP Packets debugging is on (UPDATE,REQUEST,QUERY,REPLY,HELLO,IPXSAP,PROBE,ACK,STUB,SIAQUERY, SIARELPLY) *Feb 10 03;01;08.107;EIGRP;Received HELLO on Serial 0/0/0 nbr *Feb 10 03;01;08.107; AS 1,Flags 0x0,Seq 0/0 idbq 0/0 iidbq un/rely 0/0 peerq un/rely 0/0 *Feb 10 03;01;08.843;EIGRP;Received HELLO on Serial 0/0/1 nbr *Feb 10 03;01;08.843; AS 1,Flags 0x0,Seq 0/0 idbq 0/0 iidbq un/rely 0/0 peerq un/rely 0/0 *Feb 10 03;01;08.927;EIGRP;sending HELLO on Serial 0/0/0 *Feb 10 03;01;08.927; AS 1,Flags 0x0,Seq 0/0 idbq 0/0 iidbq un/rely 0/0 *Feb 10 03;01;08.471;EIGRP;sending HELLO on Serial 0/0/1 *Feb 10 03;01;08.471; AS 1,Flags 0x0,Seq 0/0 idbq 0/0 iidbq un/rely 0/0 以上输出显示 R2 发送和接收的 EIGRP 数据包, 由于当前网络是收敛的, 所以只有 HELLO 断气包发送和接收的报告 术语 在 EIGRP 中, 有如下 5 种类型的数据包 1 Hello; 以组播的方式定期发送, 用于建立和维持邻居关系 ; 2 更新 (Update); 当路由器收到某个邻居路由器的第一个 Hello 包时, 以单播传送方式回送一个包含它所知道的路由信息的更新包, 当路由信息发生变化时, 以组播的方式发送只包含变化信息的更新包 ;

88 3 查询 (Query); 当一条链路失效, 路由器重新进行路由计算, 但在拓扑表中没有可行的后继路由时, 路由器就以组播的方式向它的邻居发送一个查询包, 以询问它们是否有一条到达目的地的后继路由 ; 4 答复 (Reply); 以单播的方式回送给查询方, 对查询数据包进行应答 ; 5 确认 (Ack); 以单播的方式传送, 用来确认更新 查询和答复数据包 (9) 注入默认路由在路由器 R1 上通过 ip default-network 向 EIGRP 网络注入一条默认路由, 具体配置如下 : R1(config-if)#ip address R1(config)#router eigrp 1 R1(config-router)#no network R1(config-router)#network R1(config)#ip default-network 在 R2 上查看路由表 : R2#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /8 is subnetted, 1 subnets D* [90/ ]via ,00;00;08,Serial0/0/ /24 is subnetted, 1 subnets D C D [90/ ]via ,00;05;35,Serial0/0/ /24 is directly connected, Serial0/0/ [90/ ]via ,00;05;35,Serial0/0/1 以上输出表明路由器 R2 收到一条默认路由, 同时在 R3,R4 上也会收到一条默认路由

89 5.3 EIGRP 负载均衡 汇总和认证 实验 2:EIGRP 负载均衡 1. 实验目的通过本实验可以掌握 1 EIGRP 等价负载均衡的实现方法 ; 2 EIGRP 非等价负载均衡的实现方法 ; 3 修改 EIGRP 度量值的方法 ; 4 可行距离 (FD) 通告距离 (RD) 以及可行性条件 (FC) 的深层含义 2. 实验拓扑本实验拓扑结构图如图 5-2 所示 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router eigrp 1 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#network (2) 步骤 2: 配置路由器 R2 R2(config)#router eigrp 1 R2(config-router)#no auto-summary R2(config-router)#network 图 5-2 EIGRP 负载均衡

90 R2(config-router)#network R2(config-router)#network (3) 步骤 3: 配置路由器 R3 R3(config)#router eigrp 1 R3(config-router)#no auto-summary R3(config-router)#network R3(config-router)#network (4) 步骤 4: 配置路由器 R4 R4(config)#router eigrp 1 R4(config-router)#no auto-summary R4(config-router)#network R4(config-router)#network R4(config-router)#network 实验调试 1 按照上面的配置, 在 R4 上查看路由表 : R4#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;00;19, GigabitEthernet0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;00;15, GigabitEthernet0/0 C /24 is directly connected, GigabitEthernet0/ /24 is subnetted, 1 subnets C /24 is directly connected,loopback0 D /24[90/ ]via ,00;00;15, Serial0/0/0 C /24 is directly connected, Serial0/0/1 本实验只关注路由器 R2 的 Loopback 0, 虽然路由器 R4 到达路由器 R2 的 Loopback 0 有

91 两条路径, 但是路由器会将 FD 最小的放入路由表, 选择走 g0/0 接口 那么另外一条路径是不是可行后继路由呢? 在路由器上查看拓扑表, 详述如下 : R4#show ip eigrp topology IP-EIGRP Topology Table for AS(1)/ID( ) Codes;P-Passive, A-Active, U-Update, Q-QUERY, R- Reply, r-reply Status, s-sia Status P /24, 1 successors, FD is via ( / ),GigabitEthernet0/0 via ( / ),Serial0/0/0 P /24, 1 successors, FD is via Connected,Loopback0 P /24, 1 successors, FD is via Connected,Serial0/0/0 P /24, 1 successors, FD is via ( / ),GigabitEthernet0/0 P /24, 1 successors, FD is via Connected, GigabitEthernet0/0 P /24, 1 successors, FD is via ( / ),Serial0/0/0 从下面的输出中可以看到, 第二条路径 ( 走 s0/0/0 接口 ) 的 AD 为 , 而最优路由 ( 走 g0/0) 的 FD 为 ,AD<FD, 满足可行性条件, 所以第二路径 ( 走 s0/0/0 接口 ) 是最优路由 ( 走 g0/0 接口 ) 的可行后继路由 术语 1 后继路由器 : 是一个直接连接的邻居路由器, 通过它到达目的网络的路由最优 ; 2 可行后继路由器 : 是一个邻居路由器, 但是通过它到达目的地的度量值比其他路由器高, 但它的通告距离小于通过后继路由器到达目的网络的可行距离, 因而被保存在拓扑表中, 用做备份路由 2 通过适当的配置, 使得在路由器 R4 上看 R2 的 Loopback 0 的路由条目为等价路由, 从而实现等价负载均衡 根据前面讲的 EIGRP 度量值的计算公式, 这两条路径的最小带宽是相同的, 只要它们的延迟之和相同, 就是等价路由 为此, 在路由器 R4 上做如下的配置 : R4(config)#interface gigabitethernet 0/0 R4(config)#delay 2000 提示 在接口下用 delay 命令修改的延迟, 在计算度量值时, 不需要再除以 10

92 在 R4 上看路由表 : R4#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;00;15, GigabitEthernet0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;00;15, Serial0/0/0 [90/ ]via ,00;00;15,GigabitEthernet0/0 D /24[90/ ]via ,00;00;15, Serial0/0/0 以上输出表明路由条目 确实有两条等价路径, 表明 EIGRP 是支持等价负载均衡的 3 将 R4 的以太口 g0/0 的 delay 恢复到原来的值, 通过 variance 命令来研究 EIGRP 的非等价负载均衡 在 1 的结果中发现, 对于 路由条目, 在路由器 R4 的拓扑结构数据库中存在如下的记录 : P /24, 1 successors, FD is via ( / ),GigabitEthernet0/0 via ( / ),Serial0/0/0 现在只需在 R4 的路由器上调整 variance 的值, 即可使这两条路径在路由表中都可见和可用,R4 上的配置如下 : R4(config)#router eigrpr 1 R4(config-router)#variance 2 在 R4 上查看路由表 : R4#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2,

93 ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;00;02, GigabitEthernet0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;00;15, Serial0/0/0 [90/ ]via ,00;00;15,GigabitEthernet0/0 D /24[90/ ]via ,00;00;15, Serial0/0/0 以上输出表明, 路由条目 有两条路径可达, 但是它们的度量值不同, 这就是所说的非等价路由, 从而证明 EIGRP 是支持非等价负载均衡的 技术要点 EIGRP 非等价负载均衡是通过 variance 命令实现的, variance 默认值是 1( 即代表等价路径的负载均衡 ), variance 值的范围是 1~128, 这个参数代表了可以接受的不等价路径的度量值的倍数, 在这个范围内的链路都将被接受, 并且被放入路由表中 实验 3: EIGRP 路由汇总 1. 实验目的通过本实验可以掌握 : 1 路由汇总的目的 ; 2 EIGRP 自动汇总 ; 3 EIGRP 手工汇总 ; 4 指向 null0 路由的含义 2. 实验拓扑本实验拓扑结构图如图 5-3 所示 图 5-3 EIGRP 路由汇总

94 3. 实验步骤 本实验只给出路由器 R4 的配置, 路由器 R1 R2 和 R3 的配置同 5.2 节实验 1 完全相同 默认时 EIGRP 的自动汇总是开启的, 自动汇总只对本地产生的 EIGRP 路由汇总, 可以通过 no auto-summary 命令关闭自动汇总, 然后进行手工汇总,R4 的配置如下 : R4(config)#router eigrp 1 R4(config-router)#no auto-summary R4(config-router)#network R4(config-router)#network R4(config)#interface s0/0/0 R4#(config-if)#ip summary-address eigrp // 配置 EIGRP 手工路由汇总 4. 实验调试 1 在 R4 s0/0/0 执行汇总之前, 在 R3 上查看路由表 : R4#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;23;31, Serial0/0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;00;18, Serial0/0/ /24 is subnetted, 4 subnets D [90/ ]via ,00;01;02, Serial0/0/0 D [90/ ]via ,00;01;02, Serial0/0/0 D [90/ ]via ,00;01;02, Serial0/0/0 D [90/ ]via ,00;01;02, Serial0/0/0 以上输出表明路由器 R3 的路由表中有 4 条明细路由 2 在路由器 R4 s0/0/0 接口执行汇总, 在 R3 和 R4 上查看路由表 : R4#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area

95 N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;23;31, Serial0/0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;00;18, Serial0/0/ /24 is subnetted, 4 subnets D /22 is a summary,00;01;33, Null0 D /24 [90/ ]via ,00;26;55, Serial0/0/0 R3#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;27;30, Serial0/0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;04;17, Serial0/0/ /22 is subnetted, 1 subnets D [90/ ]via ,00;02;09, Serial0/0/0 以上输出说明, 在路由器 R4 的 s0/0/0 执行手工汇总后, 会在自己的路由表中产生一条指向 null0 的 EIGRP 路由, 主要是为了防止路由环路 ; 在路由器 R3 上收到被汇总的路由条目 /22 提示 当被汇总的明细路由全部 down 掉以后, 汇总路由才自动从路由表里被删除, 从而可以有效避免路由抖动 思考 如果把上面实验的 R4 的环回接口 lo0~lo4 的地址改为 /24, /24, /24 和 /24, 那么, 在路由器 R4 的 s0/0/0 接口还能够实现汇总吗?

96 在路由器 R4 上实施的配置如下 : R4(config)#router eigrp 1 R4(config-router)#network R4(config)#interface s0/0/0 R4#(config-if)#ip summary-address eigrp 分别在 R4 和 R3 上查看路由表 : R4#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;04;36, Serial0/0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;03;41, Serial0/0/0 D /22 is a summary,00;01;40, Null0 D /24 [90/ ]via ,00;26;55, Serial0/0/0 R3#show ip route Codes; C - connected, S - static, I - IGRP, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2, E - EGP i - IS-IS, L1 - IS-IS level-1, L2 - IS-IS level-2, ia - IS-IS inter area * - candidate default, U - per-user static route, o - ODR P - periodic downloaded static route Gateway of last resort is not set D /24 [90/ ]via ,00;27;30, Serial0/0/ /24 is subnetted, 1 subnets D [90/ ]via ,00;04;17, Serial0/0/1 D /22 [90/ ]via ,00;02;09, Serial0/0/0 从 R3 和 R4 的路由表的输出可以看出 EIGRP 支持 CIDR 汇总, 这一点和 RIPv2 是不同的

97 5.3.3 实验 4:EIGRP 认证 1. 实验目的通过本实验可以掌握 EIGRP 路由协议认证的配置和调试 2. 实验拓扑本实验拓扑结构图如图 5-1 所示 图 5-1 EIGRP 基本配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#key chain ccnp R1(config-keychain)#key 1 R1(config-keychain-key)#key-string cisco R1(config)#interface s0/0/0 R1(config-if)#ip authentication mode eigrp 1 md5 // 认证模式为 MD5 R1(config-if)ip authentication key-chain eigrp 1 ccnp // 在接口上调用钥匙链 (2) 步骤 2: 配置路由器 R2 R2(config)#key chain ccnp R2(config-keychain)#key 1 R2(config-keychain-key)#key-string cisco R2(config)#interface s0/0/0 R2(config-if)#ip authentication mode eigrp 1 md5 R2(config-if)ip authentication key-chain eigrp 1 ccnp R2(config)#interface s0/0/1 R2(config-if)#ip authentication mode eigrp 1 md5 R2(config-if)ip authentication key-chain eigrp 1 ccnp (3) 步骤 3: 配置路由器 R3 R3(config)#key chain ccnp R3(config-keychain)#key 1 R3(config-keychain-key)#key-string cisco R3(config)#interface s0/0/0 R3(config-if)#ip authentication mode eigrp 1 md5 R3(config-if)ip authentication key-chain eigrp 1 ccnp R3(config)#interface s0/0/1 R3(config-if)#ip authentication mode eigrp 1 md5 R3(config-if)ip authentication key-chain eigrp 1 ccnp

98 (4) 步骤 4: 配置路由器 R4 R2(config)#key chain ccnp R2(config-keychain)#key 1 R2(config-keychain-key)#key-string cisco R2(config)#interface s0/0/0 R2(config-if)#ip authentication mode eigrp 1 md5 R2(config-if)ip authentication key-chain eigrp 1 ccnp 4. 实验调试 1 如果链路的一端启用了认证, 另外一端没有启用认证, 则出现下面的提示信息 : *Feb 10 05;46;11.119%DUAL-5-NBRCHANGE;IP-EIGRP(0)1;Neighbor (Serial0/0/0)is down;authentication mode changed 2 如果钥匙链的密匙不正确, 则出现下面的提示信息 : *Feb 10 05;47;08.122%DUAL-5-NBRCHANGE;IP-EIGRP(0)1;Neighbor (Serial0/0/0)is down;auth failure 5.4EIGRP 命令汇总 表 5-1 列出了本章涉及的主要命令表 5-1 本章命令汇总命令 show ip eigrp neighbors show ip eigrp topology show ip eigrp interface show ip eigrp traffic debug eigrp neighbors debug eigrp packets ip hello-interval eigrp ip hold-time eigrp router eigrp no auto-summary ip authentication mode eigrp ip authentication key-chain eigrp variance delay bandwidth ip summary-address eigrp 作用查看 EIGRP 邻居表查看 EIGRP 拓扑结构数据库查看运行 EIGRP 路由协议的接口的状况查看 EIGRP 发送和接收到的数据包的统计情况查看 EIGRP 动态建立邻居关系的情况显示发和接收的 EIGRP 数据包配置 EIGRP 的 HELLO 发送周期配置 EIGRP 的 HELLO hold 时间启动 EIGRP 路由进程关闭自动汇总配置 EIGRP 的认证模式在接口上调用钥匙链配置非等价负载均衡配置接口下的延迟配置接口下的带宽手工路由汇总

99 第 6 章单区域 OSPF OSPF(Open Shortest Path First, 开放最短链路优先 ) 路由协议是典型的链路状态路由协议 OSPF 由 IETF 在 20 世纪 80 年代末期开发,OSPF 是 SPF 类路由协议中的开放式版本 最初的 OSPF 规范体现在 RFC1131 中, 被称为 OSPF 版本 1, 但是版本 1 很快被进行了重大改进的版本所代替, 这个新版本体现在 RFC1247 文档中 RFC1247 被称为 OSPF 版本 2, 是为了明确指出其在稳定性和功能性方面的实质性改进 这个 OSPF 版本有许多更新文档, 第一个更新都是对开放标准的精心改进 接下来的一些规范出现在 RFC1583 和 2328 中 OSPF 版本 2 的最新版体现在 RFC2328 中 而 OSPF 版本 3 是关于 Ipv6 的 OSPF 的内容多而复杂, 所以本书分为多个章节来介绍 本章只讨论单区域的 OSPF 6.1 OSPF 概述 OSPF 作为一种内部网关协议 (Interior Gateway Protocol,IGP), 用于在同一个自治系统 (AS) 中的路由器之间交换路由信息 OSPF 的特性如下 : 1 可适应大规模网络 ; 2 收敛速度快 ; 3 无路由环路 ; 4 支持 VLSM 和 CIDR; 5 支持等价路由 ; 6 支持区域划分, 构成结构化的网络 ; 7 提供路由分级管理 ; 8 支持简单口令和 MD5 认证 ; 9 以组播方式传送协议报文 ; 10 OSPF 路由协议的管理距离是 110; 11 OSPF 路由协议采用 cost 作为度量标准 ; 12 OSPF 维护邻居表 拓扑表和路由表 另外,OSPF 将网络划分为 4 种类型 : 广播多路访问型 (BMA) 非广播多路访问型 (NBMA) 点到点型 (Point-to-Point) 和点到多点型 (Point-to-MultiPoint) 不同的二层链路的类型需要 OSPF 不同的网络类型来适应 下面的几个术语是学习 OSPF 要掌握的 1 链路 : 链路就是路由器用来连接网络的接口 ; 2 链路状态 : 用来描述路由器接口及其与邻居路由器的关系, 所有链路状态信息构成链路状态数据库 ; 3 区域 : 有相同区域标志的一组路由器和网络的集合, 在同一个区域内的路由器有相

100 同的链路状态数据库 ; 4 自治系统 : 采用同一种路由协议交换路由信息的路由器及其网络构成一个自治系统 ; 5 链路状态通告 (LSA):LSA 用来描述路由器的本地状态,LSA 包括信息有路由器接口的状态和所形成的邻接状态 ; 6 最短路径优先 (SPF) 算法 ; 是 OSPF 路由协议的基础,SPF 算法有时也被称为 Dijkstra 算法, 这是因为最短路径优先算法 (SPF) 是 Dijkstra 发明的,OSPF 路由器利用 SPF, 独立地计算出到达任意目的地的最佳路由 6.2 实验 1: 点到点链路上的 OSPF 1. 实验目的通过本实验可以掌握 1 在路由器上 OSPF 路由进程 ; 2 启用参与路由协议的接口, 并且通告网络及所在的区域 ; 3 度量值 Cost 的计算 ; 4 Hello 相关参数的配置 ; 5 点到点链路上的 OSPF 特征 ; 6 查看和调试 OSPF 路由协议相关信息 2. 实验拓扑本实验的拓扑结构图如图 6-1 所示 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id 图 6-1 点到点链路上的 OSPF

101 R1(config-router)#network area 0 R1(config-router)#network area 0 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config-router)#network area 0 (3) 步骤 3: 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 0 R3(config-router)#network area 0 (4) 步骤 4: 配置路由器 R4 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0 技术要点 1 OSPF 路由进程 ID 的范围必须是在 1~65535 之间, 而且只有本地含义, 不同路由器的路由进程 ID 可以不同, 如果要想启动 OFPS 路由进程, 至少确保有一个接口是 up 的 ; 2 区域 ID 是在 0~ 内的十进制数, 也可以是 IP 地址格式 A.B.C.D, 当网络区域 ID 为 0 或 时称为主干区域 ; 3 在高版本的 IOS 中通告 OFPF 网络的时候, 网络号的后面可以跟网络掩码, 也可以跟跟反掩码 ; 4 确定 Router ID 遵循如下顺序 : 最优先的是在 OSPF 进程中用命令 router-id 指定了路由器 ID; 如果没有在 OSPF 进程中指定路由器 ID, 那么把选择 IP 地址最大的环回接口的 IP 地址为 Router ID; 如果没有环回接口, 就选择最大活动的物理接口的 IP 地址为 Router ID, 建议用命令 router-id 来指定路由器 ID, 这样可控性比较好 4. 实验调试 (1)show ip route

102 R2#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS ia - IS-IS inter area, * - candidate default, U - per-user sta o - ODR, P - periodic downloaded static route Gateway of last resort is not set C /24 is directly connected, Serial0/0/ /32 is subnetted, 1 subnets O [110/65] via , 00;07;27, Serial0/0/ /24 is subnetted, 1 subnets C is directly connected, Loopback /32 is subnetted, 1 subnets O [110/65] via , 00;07;27, Serial0/0/ /32 is subnetted, 1 subnets O [110/129] via , 00;07;27, Serial0/0/1 C /24 is directly connected, Serial0/0/1 O /24 [110/128] via , 00;07;27, Serial0/0/1 输出结果表明同一个区域内通过 OSPF 路由协议学习的路由条目用代码 O 表示 说明 1 环回接口 OSPF 路由条目的掩码长度都是 32 位, 这是环回接口的特性, 尽管通告了 24 位 解决的办法是在环回接口下修改网络类型为 Point-to-Point, 操作如下 : R2(config)#interface loopback 0 R2(config-if)#ip ospf network point-to-point 这样收到的路由条目的掩码长度和通告的就一致了 2 路由条目 的度量值为 1 563, 计算过程如下 : cost 的计算公式为 10 8 / 带宽 (bps), 然后取整, 而且是所有链路入口的 cost 之和, 环回接口的 cost 为 1, 路由条目 到路由器 R2 经过的入接口包括路由器 R4 的 loopback 0, 路由器 R3 的 s0/0/0, 路由器 R2 的 s0/0/1, 所以计算如下 : / / =1 563, 也可以直接通过命令 ip ospf cost 设置接口的 cost 值, 并且它是优先计算的 cost 值 (2)show ip protocols R2#show ip protocols Routing Protocol is ospf 1 // 当前路由器运行的 OSPF 进程 ID Outgoing update filter list for all interfaces is not set

103 Incoming update filter list for all interfaces is not set Router ID // 本路由器 ID Number of areas in this router is 1. 1 normal 0 stub 0 nssa // 本路由器参与的区域数量和类型 Maximum path; 4 // 支持等价路径最大数目 Routing for Networks; area area area 0 // 以上 4 行表明 OSPF 通告的网络以及这些网络所在的区域 Reference bandwidth unit is 100 mbps // 参考带宽为 10 8 Routing Information Sources; Gateway Distance Last Update ;17; ;17; ;17; ;17;02 // 以上 5 行表明路由信息源 Distance; (default is 110) //OSPF 路由协议默认的管理距离 (3)show ip ospf R2#show ip ospf Routing Process ospf 1 with ID Start time;00;50;57.156,time elapsed;00;42; Supports only single TOS(TOS0) routes Supports opaque LSA Supports Link-local Signaling (LLS) Supports area transit capability Router is not originating router-lsas with maxium metric Initial SPF schedule delay 5000 msecs Minimum hold time between two consecutive SPFs msecs Maximum wait time between two consecutive SPFs msecs Incremental-SPF disabled Minimum LSA interval 5 secs Minimum LSA arrival 1000 msecs LSA group pacing timer 240 secs Interface flood pacing timer 33 msecs

104 Retransmission pacing timer 66 msecs Number of external LSA 0. Checksum Sum 0x Number of opaque AS LSA 0. Checksum Sum 0x Number of DCbitless external and opaque AS LSA 0 Number of DoNotAge external and opaque AS LSA 0 Number of areas in this router is 1. 1 normal 0 stub 0 nssa Number of areas transit capable is 0 External flood list length 0 Cisco NSF helper support enabled IETF NSF helper support enabled Area BACKBONE(0) Number of interfaces in this area is 3 Area has no authentication SPF algorithm last executed 00;15; ago SPF algorithm executed 9 times Area ranges are Number of LSA 4. Checksum Sum 0x02611A Number of opaque link LSA 0. Checksum Sum 0x Number of DCbitless LSA 0 Number of indication LSA 0 Number of DoNotAge LSA 0 Flood list length 0 (4)show ip ospf interface R2#show ip ospf interface Serial0/0/0 is up, line protocol is up Internet Address /24, Area 0 // 该接口的地址和运行的 OSPF 区域 Process ID 1, Router ID , Network Type POINT_TO_POINT, Cost; 781 // 进程 ID, 路由器 ID, 网络类型, 接口 Cost 值 Transmit Delay is 1 sec, State POINT_TO_POINT, // 接口的延迟和状态 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 // 显示几个计时器的值 Hello due in 00;00;05 // 距离下次发送 Hello 包的时间 Supports Link-local Signaling (LLS) // 支持 LLS IETF NSF helper support enabled

105 IETE NSF helper support enabled // 以上 2 行表明启用了 IETF 和 Cisco 的 NSF 功能 Index 1/1, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 0 msec Neighbor Count is 1, Adjacent neighbor count is 1 // 邻居的个数以及已建立邻接关系的邻居的个数 Adjacent with neighbor // 已经建立邻接关系的邻居路由器 ID Suppress hello for 0 neighbor(s) // 没有进行 Hello 抑制 (5)show ip ospf neighbor R2#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface FULL/ - 00;00; Serial0/0/ FULL/ - 00;00; Serial0/0/0 以上输出表明路由器 R2 有两个邻居, 它们的路由器 ID 分别为 和 , 其他参数解释如下所述 1 Pri; 邻居路由器接口的优先级 ; 2 State; 当前邻居路由器接口的状态 ; 3 Dear Time; 清除邻居关系前等待的最长时间 ; 4 Address; 邻居接口的地址 ; 5 Interface; 自己和邻居路由器相连的接口 ; 6 - : 表示点到点的链路上 OSPF 不进行 DR 选举 技术要点 OSPF 邻居关系不能建立的常见原因 : 1 Hello 间隔和 Dead 间隔不同同一链路上的 Hello 包间隔和 Dead 间隔必须相同才能建立邻接关系 在默认情况下,Hello 包发送间隔如表 6-1 所示 默认时,Dead 间隔是 Hello 间隔的 4 倍, 可以在接口下通过 ip ospf hello-interval 和 ip ospf Dead-interval: 命令调整 2 区域号码不一致 3 特殊区域 ( 如 stub 和 nssa 等 ) 区域类型不匹配 4 认证类型或密码不一致 5 路由器 ID 相同 6 Hello 包被 ACL deny

106 7 链路上的 MTU 不匹配 8 接口下 OSPF 网络类型不匹配 表 6-1OSPF Hello 间隔和 Dead 间隔 网络类型 Hello 间隔 /s Dead 间隔 /s 广播多路访问 非广播多路访问 点到点 点到多点 (6)show ip ospf datebase R2#show ip ospf database OSPF Router with ID ( ) (Process ID 1) Router Link States (Area 0) Link ID ADV Router Age Seq# Checksum Link count x x00BA x x00D7C x x00282D x x009AFE 3 以上输出是 R2 的区域 0 的拓扑结构数据库的信息, 标题行的解释如下所述 1 Link ID; 是指 Link State ID, 代表整个路由器, 而不是某个链路 ; 2 ADV Router; 是指链路状态信息的路由器 ID; 3 Age; 老化时间 ; 4 Seq#; 序列号 ; 5 Checksum; 校验和 ; 6 Link count; 通告路由器在本区域内的链路数目 6.3 实验 2: 广播多路访问链路上的 OSPF 1. 实验目的通过本实验可以掌握 : 1 在路由器上启动 OSPF 进程 ; 2 启用参与路由协议的接口, 并且通告网络及所在的区域 ; 3 修改参考带宽 ; 4 DR 选举的控制 ;

107 5 广播多多路访问链路上的 OSPF 特征 2. 实验拓扑本实验的拓扑结构图如图 6-2 所示 图 6-2 广播多路访问链路上的 OSPF 3. 实验步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config-router)#auto-cost reference-bandwidth 1000 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#auto-cost reference-bandwidth 1000 (3) 步骤 3: 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0

108 R3(config-router)#auto-cost reference-bandwidth 1000 (4) 步骤 4: 配置路由器 R4 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0 R4(config-router)#auto-cost reference-bandwidth 1000 说明 auto-cost reference-bandwidth 1000 命令是用来修改参考带宽的, 因为本实验中的以太口的带宽为千兆位, 如果采用默认的百兆位参考带宽, 计算出来的 Cost 是 0.1, 这显示是不合理的, 修改参考带宽要在所有的 OSPF 路由器上配置, 目的是确保参考标准是相同的 另外, 当执行 auto-cost reference-bandwidth 1000 命令的时候, 系统也会如下信息 %OSPF;Reference bandwith is changed. Please ensure reference bandwidth is consistent across allrouters. 4. 实验调试 (1)show ip ospf neighbor R1#show ip ospf neighbor Neighbor ID Pri State Dead Time Address Interface FULL/BDR 00;00; GigabitEthernet0/ FULL/DROTHER 00;00; GigabitEthernet0/ FULL/DROTHER 00;00; GigabitEthernet0/0 以上输出表明在该广播多路访问网络中,R1 是 DR,R2 是 BDR,R3 和 R4 为 DROTHER 技术要点 1 为了避免路由器之间建立完全邻接关系而引起的大量开销,OSPF 要求在多路访问的网络中选举一个 DR, 每个路由器都与之建立邻接关系 选举 DR 的同时也选举出一个 BDR, 在 DR 失效的时候,BDR 担负起 DR 的职责, 所有其他路由器只与 DR 和 BDR 建立邻接关系 2 DR 和 BDR 有它们自己的组播地址 Dr 和 BDR 的选举是以各个网络为基础的, 也就是说,DR 和 BDR 选举是一个路由器的接口特性, 而不是整个路由器的特性 4 DR 选举的原则 : 首要因素是时间, 最先启动的路由器被选举成 DR; 如果同时启动, 或者重新选举, 则看接口优先级 ( 范围为 0~255), 优先级最高的被选举成 DR, 在默认情况下, 多路访问网络的接口优先级为 1, 点到点网络接口优

109 先级为 0, 修改接口优先级的命令是 ip ospf priority, 如果接口的优先级被设置为 0, 那么该接口将不参与 DR 选举 ; 如果前两者相同, 最后看路由器 ID, 路由器 ID 最高的被选举成 DR 5Dr 选举是非抢占的, 除非人为地重新选举 重新选举 DR 的方法有两种, 一是路由器重新启动 ; 二是执行 clear ip ospf process 命令 (2)show ip ospf interface 分别在路由器 R1 和 R4 上执行该命令 : R1#show ip ospf interface GigabitEthernet0/0 is up, line protocol is up Internet Address /24, Area 0 Process ID 1, Router ID , Network Type BROADCAST, Cost; 10 Transmit Delay is 1 sec, State DR,Priority 1 // 自己的 state 是 DR Designated Router(ID) ,Interface address //DR 的路由器 ID 以及接口地址 Backup Designated Router(ID) ,Interface address //BDR 的路由器 ID 以及接口地址 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 Hello due in 00;00;09 Supports Link-local Signaling (LLS) Cisco NSF helper support enabled IETF NSF helper support enabled Index 2/2, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 4 msec Neighbor Count is 3, Adjacent neighbor count is 3 //R1 是 DR, 有 3 个邻居, 并且全部形成邻接关系 Adjacent with neighbor (Backup Designated Router) //R2 是 BDR Adjacent with neighbor Adjacent with neighbor R4#show ip ospf interface GigabitEthernet0/0 is up, line protocol is up Internet Address /24, Area 0 Process ID 1, Router ID , Network Type BROADCAST, Cost; 10 // 网络类型为 BROADCAST

110 Transmit Delay is 1 sec, State DROTHER,Priority 1 // 自己的 state 是 DROTHER Designated Router(ID) ,Interface address //DR 的路由器 ID 以及接口地址 Backup Designated Router(ID) ,Interface address //BDR 的路由器 ID 以及接口地址 Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 Hello due in 00;00;06 Supports Link-local Signaling (LLS) Cisco NSF helper support enabled IETF NSF helper support enabled Index 2/2, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 0 msec Neighbor Count is 3, Adjacent neighbor count is 2 // 有 3 个邻居, 只与 R1 和 R2 形成邻接关系, 与 R3 只是邻居关系 Adjacent with neighbor (Designated Router) Adjacent with neighbor (Backup Designated Router) // 上面两行表土 DR 和 BDR 形成邻接关系 suppress hello for 0 neighbor(s) 从上面的路由器 R1 和 R4 的输出得知, 邻居关系和邻接关系是不能混为一谈的, 邻居关系是指达到 2WAY 状态的两台路由器, 而邻接关系是指达到 FULL 状态的两台路由器 (3)debug ip ospf adj 该命令显示 OSPF 邻接关系创建或中断的过程 R2#debug ip ospf adj OSPF adjacency events debugging is on R2#clear ip ospf process Reset ALL OSPF processes?[no];y *Feb 10 10;37;33.447;OSPF;Interface GigabitEthernet0/0 going Down *Feb 10 10;37;33.447;OSPF; address on GigabitEthernet0/0 is dead,state DOWN *Feb 10 10;37;33.447;OSPF;Neighbor change Event on interface GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;DR/BDR election on GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;Elect BDR *Feb 10 10;37;33.447;OSPF;Elect DR *Feb 10 10;37;33.447;OSPF;Elect BDR *Feb 10 10;37;33.447;OSPF;Elect DR *Feb 10 10;37;33.447; DR (Id) BDR (Id)

111 *Feb 10 10;37;33.447;OSPF;Reset adjacency with on GigabitEthernet0/0,state 2WAY *Feb 10 10;37;33.447;OSPF; address on GigabitEthernet0/0 is dead,state DOWN *Feb 10 10;37;33.447;OSPF;%OSPF-5-ADJCHG;Process 1,Nbr on GigabitEthernet0/0 from FULL to DOWN, Neighbor Down;Interface down or detached *Feb 10 10;37;33.447;OSPF;Neighbor change Event on interface GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;DR/BDR election on GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;Elect BDR *Feb 10 10;37;33.447;OSPF;Elect DR *Feb 10 10;37;33.447; DR (Id) BDR (Id) *Feb 10 10;37;33.447;OSPF;Remimber old DR (Id) *Feb 10 10;37;33.447;OSPF; address on GigabitEthernet0/0 is dead,state DOWN *Feb 10 10;37;33.447;OSPF;%OSPF-5-ADJCHG;Process 1,Nbr on GigabitEthernet0/0 from 2WAY to DOWN, Neighbor Down;Interface down or detached *Feb 10 10;37;33.447;OSPF;Neighbor change Event on interface GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;DR/BDR election on GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;Elect BDR *Feb 10 10;37;33.447;OSPF;Elect DR *Feb 10 10;37;33.447; DR (Id) BDR (Id) *Feb 10 10;37;33.447;OSPF; address on GigabitEthernet0/0 is dead,state DOWN *Feb 10 10;37;33.447;OSPF;%OSPF-5-ADJCHG;Process 1,Nbr on GigabitEthernet0/0 from FULL to DOWN, Neighbor Down;Interface down or detached *Feb 10 10;37;33.447;OSPF;Neighbor change Event on interface GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;DR/BDR election on GigabitEthernet0/0 *Feb 10 10;37;33.447;OSPF;Elect BDR *Feb 10 10;37;33.447;OSPF;Elect DR *Feb 10 10;37;33.447; DR ;none BDR ;none *Feb 10 10;37;33.447;OSPF;Remimber old DR (Id) *Feb 10 10;37;33.447;OSPF;Interface Loopback0 going Down *Feb 10 10;37;33.447;OSPF; address on Loopback0 is dead,state DOWN *Feb 10 10;37;33.459;OSPF;Interface GigabitEthernet0/0 going Up *Feb 10 10;37;33.459;OSPF;Interface Loopback0 going Up *Feb 10 10;37;33.459;OSPF;2 Way Communication to on GigabitEthernet0/0,state 2WAY *Feb 10 10;37;33.459;OSPF;2 Way Communication to on GigabitEthernet0/0,state 2WAY *Feb 10 10;37;33.459;OSPF;2 Way Communication to on GigabitEthernet0/0,state 2WAY *Feb 10 10;37;33.459;OSPF;Backup seen Event before WAIT timer on GigabitEthernet0/0 *Feb 10 10;37;33.459;OSPF;DR/BDR election on GigabitEthernet0/0 *Feb 10 10;37;33.459;OSPF;Elect BDR *Feb 10 10;37;33.459;OSPF;Elect DR *Feb 10 10;37;33.459; DR (Id) BDR (Id) *Feb 10 10;37;33.459;OSPF;Send DBD to on GigabitEthernet0/0 seq 0xC87 opt 0x52 flag 0x7 len 32

112 *Feb 10 10;37;33.459;OSPF;Send DBD to on GigabitEthernet0/0 seq 0x1B1C opt 0x52 flag 0x7 len 32 *Feb 10 10;37;33.463;OSPF;Rcv DBD from on GigabitEthernet0/0 seq 0x1A0 opt 0x52 flag 0x7 len 32 mtu 1500 state EXSTART *Feb 10 10;37;33.463;OSPF;First DBD and we are not SLAVE *Feb 10 10;37;33.463;OSPF;Rcv DBD from on GigabitEthernet0/0 seq 0xC87 opt 0x52 flag 0x2 len 112 mtu 1500 state EXSTART *Feb 10 10;37;33.463;OSPF;NBR Negotiation Done.We are the MASTER *Feb 10 10;37;33.463;OSPF; ;Send DBD to on GigabitEthernet0/0 seq 0xC88 opt 0x52 flag 0x1 len 32 *Feb 10 10;37;33.463;OSPF;Rcv DBD from on GigabitEthernet0/0 seq 0x13C0 opt 0x52 flag 0x2 len 112 mtu 1500 state EXSTART *Feb 10 10;37;33.463;OSPF;NBR Negotiation Done.We are the SLAVE *Feb 10 10;37;33.463;OSPF;Send DBD to on GigabitEthernet0/0 seq 0x13C0 opt 0x52 flag 0x0 len 32 *Feb 10 10;37;33.463;OSPF;Rcv DBD from on GigabitEthernet0/0 seq 0xc88 opt 0x52 flag 0x0 len 112 mtu 1500 state EXCHANGE *Feb 10 10;37;33.463;OSPF;Exchange Done with on GigabitEthernet0/0 *Feb 10 10;37;33.463;OSPF;Send LS REQ to length 48 LSA count 4 *Feb 10 10;37;33.463;OSPF; Rcv DBD from on GigabitEthernet0/0 seq 0x13C1 opt 0x52 flag 0x3 len 112 mtu 1500 state EXCHANGE *Feb 10 10;37;33.463;OSPF;Send DBD to on GigabitEthernet0/0 seq 0x13C1 opt 0x52 flag 0x0 len 32 *Feb 10 10;37;33.463;OSPF;Rcv LS UPD from on GigabitEthernet0/0 length 212 LSA count 4 *Feb 10 10;37;33.467;OSPF;Synchronized with on GigabitEthernet0/0 state FULL *Feb 10 10;37;33.467;OSPF;%OSPF-5-ADJCHG;Process 1, Nbr on GigabitEthernet0/0 from LOADING to FULL, Loading Done *Feb 10 10;37;33.467;OSPF;Rcv DBD from on GigabitEthernet0/0 seq 0x13C2 opt0x52 flag 0x1 len 32 mtu 1500 state EXCHANGE *Feb 10 10;37;33.467;OSPF;Exchange Done with on GigabitEthernet0/0 *Feb 10 10;37;33.467;OSPF;Synchronized with on GigabitEthernet0/0,state FULL *Feb 10 10;37;33.467;OSPF; %OSPF-5-ADJCHG;Process 1, Nbr on GigabitEthernet0/0 from LOADING to FULL, Loading Done *Feb 10 10;37;33.467;OSPF;Send DBD to on GigabitEthernet0/0 seq 0x13C2 opt 0x52 flag 0x0 len 32 *Feb 10 10;37;33.947;OSPF;Build router LSA for area 0,router ID ,seq 0x ,process 1 *Feb 10 10;37;33.155;OSPF;Rcv LS UPD from on GigabitEthernet 0/0 length 76 LSA count 1 *Feb 10 10;37;33.443;OSPF;Rcv LS UPD from on GigabitEthernet 0/0 length 76 LSA count 1 *Feb 10 10;37;33.595;OSPF;Rcv LS UPD from on GigabitEthernet 0/0 length 76 LSA count 1 *Feb 10 10;37;33.635;OSPF;Rcv LS UPD from on GigabitEthernet 0/0 length 76 LSA count 1 *Feb 10 10;37;33.155;OSPF;Build router LSA for area 0,router ID ,seq 0x ,process 1 *Feb 10 10;37;33.155;OSPF;Rcv LS UPD from on GigabitEthernet 0/0 length 76 LSA count 1

113 以上的输出表明 : 1 DR 重新选举的过程和结果, 新的 DR 是 R1,BDR 是 R4; 2 在 OSPF 邻接关系建立的过程中, 接口状态的变化包括 DOWN,2 Way,EXSTART,EXCHANGE,Loading 和 FULL 6.4 OSPF 认证 实验 3: 基于区域的 OSPF 简单口令认证 1. 实验目的通过本实验可以掌握 : 1 OSPF 认证的类型和意义 ; 2 基于区域的 OSPF 简单口令认证的配置和调试 2. 实验拓扑本实验的拓扑结构图如图 6-3 所示 图 6-3 基于区域的 OSPF 简单口令认证 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config-router)#area 0 authentication // 区域 0 启用简单口令认证 R1(config)#interface s0/0/0 R1(config-if)#ip ospf authentication-key cisco // 配置认证密码

114 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config-router)#area 0 authentication R2(config)#interface s0/0/0 R2(config-if)#ip ospf authentication-key cisco 4. 实验调试 (1)show ip ospf interface R1#show ip ospf interface Serial0/0/0 is up, line protocol is up Internet Address /24, Area 0 Process ID 1, Router ID , Network Type POINT_TO_POINT, Cost; 781 Transmit Delay is 1 sec, State POINT_TO_POINT, Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 Hello due in 00;00;02 Supports Link-local Signaling (LLS) Cisco NSF helper support enabled IETF NSF helper support enabled Index 1/1, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 0 msec Neighbor Count is 0, Adjacent neighbor count is 0 Adjacent with neighbor Suppress hello for 0 neighbor(s) Simple password authentication enabled 以上输出最后一行信息表明该接口启用了简单口令认证 (2)show ip ospf R1#show ip ospf Routing Process ospf 1 with ID Supports only single TOS(TOS0) routes... Area BACKBONE(0) Number of interfaces in this area is 2 (1 loopback) Area has simple password authentication

115 SPF algorithm last executed 00;04; ago SPF algorithm executed 5 times Area ranges are Number of LSA 2. Checksum Sum 0x Number of opaque link LSA 0. Checksum Sum 0x Number of DCbitless LSA 0 Number of indication LSA 0 Number of DoNotAge LSA 0 Flood list length 0 以上输出表明区域 0 采用简单口令认证 1 如果 R1 区域 0 没有启动认证, 而 R2 区域 0 启动简单口令认证, 则 R2 上出现下面的信息 : *Feb 10 11;03;03.071;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Type.Input packet specified type 0,we use type 1 2 如果 R1 和 R2 的区域 0 都启动简单口令认证, 但是 R2 的接口下没有配置密码或密码错误, 则 R2 上出现下面的信息 : *Feb 10 10;55;53.071;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Key-Clear Text 实验 4: 基于区域的 OSPF MD5 认证 1. 实验目的通过本实验可以掌握 : 1 OSPF 认证的类型和意义 ; 2 基于区域的 OSPF MD5 认证的配置和调试 2. 实验拓扑本实验的拓扑结构图如图 6-3 所示 图 6-3 基于区域的 OSPF 简单口令认证 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0

116 R1(config-router)#network area 0 R1(config-router)#area 0 authentication message-digest // 区域 0 启用 MD5 认证 R1(config)#interface s0/0/0 R1(config-if)#ip ospf message-digest-key 1 md5 cisco // 配置认证 key ID 及密匙 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config-router)# area 0 authentication message-digest R2(config)#interface s0/0/0 R2(config-if)# ip ospf message-digest-key 1 md5 cisco 4. 实验调试 (1)show ip ospf interface R1#show ip ospf interface Serial0/0/0 is up, line protocol is up Internet Address /24, Area 0 Process ID 1, Router ID , Network Type POINT_TO_POINT, Cost; 781 Transmit Delay is 1 sec, State POINT_TO_POINT, Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 Hello due in 00;00;09 Supports Link-local Signaling (LLS) Cisco NSF helper support enabled IETF NSF helper support enabled Index 1/1, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 0, maximum is 1 Last flood scan time is 0 msec, maximum is 0 msec Neighbor Count is 0, Adjacent neighbor count is 0 Adjacent with neighbor Suppress hello for 0 neighbor(s) Message digest authentication enabled Youngest key id is 1 输出最后两行信息表明该接口启用了 MD5 认证, 而且密钥 ID 为 1. (2)show ip ospf R1#show ip ospf Routing Process ospf 1 with ID Supports only single TOS(TOS0) routes...

117 Area BACKBONE(0) Number of interfaces in this area is 2 (1 loopback) Area has simple password authentication SPF algorithm last executed 00;01; ago SPF algorithm executed 5 times Area ranges are Number of LSA 2. Checksum Sum 0x Number of opaque link LSA 0. Checksum Sum 0x Number of DCbitless LSA 0 Number of indication LSA 0 Number of DoNotAge LSA 0 Flood list length 0 以上输出表明区域 0 采用 MD5 认证 1 如果 R1 区域 0 启动 MD5 认证, 而 R2 区域 0 启动简单口令认证, 则 R2 上出现下面的信息 : *Feb 10 11;08;13.075;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Type.Input packet specified type 2,we use type 1 2 如果 R1 和 R2 的区域 0 都启动 MD5 认证, 但是 R2 的接口下没有配置 key ID 和密码或密码错误, 则 R2 上出现下面的信息 : *Feb 10 11;08;13.075;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Key-No message digest key 1 on interface 实验 5: 基于链路的 OSPF 简单口令认证 1. 实验目的通过本实验可以掌握 : 1 OSPF 认证的类型和意义 ; 2 基于链路的 OSPF 简单口令认证的配置和调试 2. 实验拓扑本实验的拓扑结构图如图 6-3 所示 图 6-3 基于区域的 OSPF 简单口令认证 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id

118 R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config)#interface s0/0/0 R1(config-if)#ip ospf authentication // 链路启用简单口令认证 R1(config-if)#ip ospf authentication-key cisco // 配置认证密码 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config)#interface s0/0/0 R2(config-if)# ip ospf authentication R2(config-if)# ip ospf authentication-key cisco 4. 实验调试 (1)show ip ospf interface R1#show ip ospf interface Serial0/0/0 is up, line protocol is up Internet Address /24, Area 0 Process ID 1, Router ID , Network Type POINT_TO_POINT, Cost; 781 Transmit Delay is 1 sec, State POINT_TO_POINT, Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 Hello due in 00;00;09 Supports Link-local Signaling (LLS) Cisco NSF helper support enabled IETF NSF helper support enabled Index 1/1, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 0 msec Neighbor Count is 1, Adjacent neighbor count is 1 Adjacent with neighbor Suppress hello for 0 neighbor(s) Simple password authentication enabled 以上输出最后两行信息表明该接口启用简单口令认证 1 如果 R1 的 s0/0/0 接口启动伴音口令认证, 而 R2 的 s0/0/0 接口没有启动认证, 则 R2 上出现下面的信息 :

119 *Feb 10 11;19;33.074;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Type.Input packet specified type 1,we use type 0 2 如果 R1 和 R2 的 s0/0/0 接口都启动简单口令认证, 但是 R2 的接口下没有配置认证密码或密码错误, 则 R2 上出现下面的信息 : *Feb 10 11;22;33.074;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Key-Clear Text 实验 6: 基于链路的 OSPF MD5 认证 1. 实验目的通过本实验可以掌握 : (1) OSPF 认证的类型和意义 ; (2) 基于链路的 OSPF MD5 认证的配置和调试 2. 实验拓扑本实验的拓扑结构图如图 6-3 所示 图 6-3 基于区域的 OSPF 简单口令认证 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config)#interface s0/0/0 R1(config-if)#ip ospf authentication message-digest // 接口 s0/0/0 启用 MD5 认证 R1(config-if)#ip ospf message-digest-key 1 md5 cisco // 配置认证 key ID 及密匙 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config)#interface s0/0/0 R2(config-if)# ip ospf authentication message-digest R2(config-if)# ip ospf message-digest-key 1 md5 cisco

120 4. 实验调试 (1)show ip ospf interface R1#show ip ospf interface Serial0/0/0 is up, line protocol is up Internet Address /24, Area 0 Process ID 1, Router ID , Network Type POINT_TO_POINT, Cost; 781 Transmit Delay is 1 sec, State POINT_TO_POINT, Timer intervals configured, Hello 10, Dead 40, Wait 40, Retransmit 5 oob-resync timeout 40 Hello due in 00;00;00 Supports Link-local Signaling (LLS) Cisco NSF helper support enabled IETF NSF helper support enabled Index 1/1, flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec, maximum is 0 msec Neighbor Count is 1, Adjacent neighbor count is 1 Adjacent with neighbor Suppress hello for 0 neighbor(s) Message digest authentication enabled Youngest key id is 1 输出最后两行信息表明该接口启用了 MD5 认证, 而且密钥 ID 为 1 1 如果 R1 的 s0/0/0 启动 MD5 认证, 而 R2s0/0/0 启动简单口令认证, 则 R2 上出现下面的信息 : *Feb 10 11;08;13.075;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Type.Input packet specified type 2,we use type 1 2 如果 R1 和 R2 的 s0/0/0 都启动 MD5 认证, 但是 R2 的接口下没有配置 key ID 和密码, 则 R2 上出现下面的信息 : *Feb 10 11;08;13.075;OSPF;Rcv pkt from Serial0/0/0 ;Mismatch Authentication Key-No message digest key 1 on interface 技术要点 1 OSPF 链路认证优于区域认证 ; 2 OSPF 定义了 3 种认证类型 :0 表示不进行认证, 是默认的类型 ;1 表示采用简单口令认证 ;2 表示采用 MD5 认证

121 6.5 实验 7:default-informtion originate 1. 实验目的通过本实验可以掌握如何通过 default-informtion originate 命令向 OSPF 网络注入一条默认路由 2. 实验拓扑本实验的拓扑结构图如图 6-4 所示 图 6-4 通过 default-informtion originate 命令向 OSPF 网络注入一条默认路由 3. 实验步骤本实验用 R1 的环回接口 1 来模拟 Internet (1) 步骤 1: 配置路由器 1 R1(config)#interface loopback 1 R1(config-if)#ip address R1(config)#ip route loopback 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config-router)#default-information originate 技术要点 default-informtion originate 命令后面可以加可选的 always 参数, 如果不使用该参数, 路由器上必须存在一条默认路由, 否则该命令不产生任何效果 如果使用该参数, 无论路由器上是否存在默认路由, 路由器都会向 OSPF 区域内注入一条默认路由 (2) 步骤 2: 路由器 R2 R3 和 R4 的配置同 6.2 实验 1 的配置完全相同

122 4. 实验调试 (1)show ip route R4#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is to network O /24[110/2343]via , 00;01;26, Serial0/0/ /32 is subnetted, 1 subnets O [110/2344]via , 00;01;26, Serial0/0/ /32 is subnetted, 1 subnets O [110/1563]via , 00;01;26, Serial0/0/ /32 is subnetted, 1 subnets O [110/782] via , 00;01;26, Serial0/0/0 O /24 [110/1562] via , 00;01;27, Serial0/0/0 O*E /0[110/1] via ,00;01;27,Serial0/0/0 R3#show ip route Codes; C - connected, S - static, R - RIP, M - mobile, B - BGP D - EIGRP, EX - EIGRP external, O - OSPF, IA - OSPF inter area N1 - OSPF NSSA external type 1, N2 - OSPF NSSA external type 2 E1 - OSPF external type 1, E2 - OSPF external type 2 i - IS-IS, su - IS-IS summary, L1 - IS-IS level-1, L2 - IS-IS level-2 ia - IS-IS inter area, * - candidate default, U - per-user static route o - ODR, P - periodic downloaded static route Gateway of last resort is to network O /24[110/1562]via , 00;05;28, Serial0/0/ /32 is subnetted, 1 subnets O [110/1563]via , 00;05;28, Serial0/0/ /32 is subnetted, 1 subnets O [110/782]via , 00;05;28, Serial0/0/ /32 is subnetted, 1 subnets O [110/782] via , 00; 05;28, Serial0/0/0

123 O*E /0[110/1] via ,00; 05;30,Serial0/0/0 从上面 R3 和 R4 的路由表的输出可以看到, 通过 deafult-information originate 命令确实可以向 OSPF 区域注入一条默认路由 (2)show ip ospf database R4#show ip ospf database OSPF Router with ID ( ) (Process ID 1) Router Link States (Area 0) Link ID ADV Router Age Seq# Checksum Link count x x000BD x x00CFB x x00282D x x Type-5 AS External Link States Link ID ADV Router Age Seq# Checksum Tag x x001D91 1 通过查看 R4 的拓扑结构数据库可以看到, 确实从外面注入了一条类型 5 的 LSA, 相关的内容在 18 章介绍 6.6 OSPF 命令汇总 表 6-2 列出了本涉及到的主要命令 表 6-2 本章命令汇总命令 show ip route show ip ospf neighbor show ip ospf database show ip ospf interface show ip ospf debug ip ospf adj debug ip ospf events debug ip ospf packet router ospf router-id 作用查看路由表查看 OSPF 邻居的基本信息查看 OSPF 拓扑结构数据库查看 OSPF 路由器接口的信息查看 OSPF 进程及其细节查看 OSPF 邻接关系创建或中断的过程显示 OSPF 发生的事件显示路由器收到的所有的 OSPF 数据包启动 OSPF 路由进程配置路由器 ID

124 network ip ospf network ip ospf cost ip ospf hello-interval ip ospf dead-interval ip ospf priority auto-cost reference-bandwidth clear ip ospf process area area-id authentication ip ospf authentication-key area area-id authentication message-digest ip ospf message-digest-key key-id md5 key ip ospf authentication ip ospf authentication message-digest default-information originate 通告网络及网络所在的区域配置接口网络类型配置接口 Cost 值配置 Hello 间隔配置 OSPF 邻居的死亡时间配置接口优先级配置参考带宽清除 OSPF 进程启动区域简单口令认证配置认证密码启动区域 MD5 认证配置 key ID 及密匙启用链路简单口令认证启用链路 MD5 认证向 OSPF 区域注入默认路由

125 第 7 章 HDLC 和 PPP 路由器经常用于构建广域网, 广域网链路的封装和以太网上的封装有着非常大的差别 常见的广域网封装有 HDLC, PPP 和 Frame-relay 等, 本章介绍 HDLC 和 PPP 相对而言,PPP 比 HDLC 有较多的功能 7.1 HDLC 和 PPP 简介 HDLC 介绍 HDCL 是点到点串行线路上 ( 同点电路 ) 的帧封装格式, 其帧格式和以太网帧格式有很大的差别,HDLC 帧没有源 MAC 地址和目的 MAC 地址 Cisco 公司对 HDLC 进行了专有化,Cisco 的 HDLC 封装和标准的 HDLC 不兼容 如果链路的两端都是 Cisco 设备, 如果 HDLC 封装没有问题, 但如果 Cisco 设备与非 Cisco 设备进行连接, 应使用 PPP 协议 HDLC 不能提供验证, 缺少了对链路的安全保护 默认时,Cisco 路由器的串口是采用 Cisco HDLC 封装的 如果串口的封装不是 HDLC, 要把封装改为 HDLC, 使用 encapsulation hdlc 命令 PPP 介绍 1. 概述和 HDLC 一样,PPP 也是串行线路上 ( 同步电路或异步电路 ) 的一种帧封装格式, 但是 PPP 可以提供对多种网络层协议的支持 PPP 支持认证 多链路捆绑 回拨和压缩等功能 PPP 经过 4 个过程在一个点到点的链路上建立通信连接 : 链路的建立和配置协调 通信的发起方发送 LCP 帧来配置和检测数据链路 ; 链路质量检测 在链路已经建立 协调之后进行, 这一阶段是可选的 ; 网络层协议配置协调 通信的发起方发送 NCP 帧以选择并配置网络层协议 ; 关闭链路 通信链路将一直保持到 LCP 或 NCP 帧关闭链路或发生一些外部事件 2.PPP 认证 :PAP 和 CHAP (1)PAP(Password Authentication Protocol) 利用 2 次握手的简单方法进行认证 在 PPP 链路建立完毕后, 源节点不停地在链路上发送用户名和密码, 直到验证通过 在 PAP 的验证中, 密码在链路上是以明文传输的, 而且由于是源节点控制验证重试频率和次数,PAP 不能防范

126 再生攻击和重复的尝试攻击 (2)CHAP 询问握手验证协议 CHAP(Challenge Handshake Authentication Protocol) 利用 3 次握手周期地验证源端节点的身份 CHAP 验证过程在链路建立之后进行, 而且在以后的任何时候都可以再次进行 这使得链路更为安全 ;CHAP 不允许连接发起方在没有收到询问消息的情况下进行验证尝试 CHAP 每次使用不同的询问消息, 每个消息都是不可预测的唯一的值,CHAP 不直接传送密码, 只传送一个不可预测的询问消息, 以及该询问消息与密码经过 MD5 加密运算后的加密值 所以 CHAP 可以防止再生攻击,CHAP 的安全性比 PAP 要高 7.2 实验 1:HDLC 和 PPP 封装 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 串行链路上的封装概念 ; 2 HDLC 封装 ; 3 PPP 封装 2. 实验拓扑实验拓扑图如图 7-1 所示 图 7-1 实验 1~ 实验 3 拓扑图 3. 实验步骤 (1) 步骤 1: 在路由器 R1 和 R2 上配置 IP 地址, 保证直接链路的连通性 R1(config)#int s0/0/0 R1(config-if)#ip address R1(config-if)#no shutdown R2(config)#int s0/0/0 R2(config-if)#clock rate R2(config-if)#ip address R2(config-if)#no shutdown R1#show interfaces s0/0/0

127 Serial0/0/0 is up, line protocol is up Hardware is GT96K Serial Internet address is /24 MTU 1500 bytes, BW 1544 Kbit, DLY usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation HDLC, crc 16, loopback not set ( 此处省略 ) // 该接口的默认封装为 HDLC 封装 (2) 步骤 2: 改变串行链路两端的接口封装为 PPP 封装 R1(config)#int s0/0/0 R1(config-if)#encapsulation ppp R2(config)#int s0/0/0 R2(config-if)#encapsulation ppp R1#show int s0/0/0 Serial0/0/0 is up, line protocol is up Hardware is GT96K Serial Internet address is /24 MTU 1500 bytes, BW 1544 Kbit, DLY usec, reliability 255/255, txload 1/255, rxload 1/255 Encapsulation PPP, LCP Open // 该接口的封装为 PPP 封装 Open; CDPCP, IPCP, crc 16, loopback not set // 网络层支持 IP 和 CDP 协议 ( 此处省略 ) 4. 实验调试 (1) 测试 R1 和 R2 之间串行链路的连通性 R1#ping Type escape sequence to abort. Sending 5, 100-byte ICMP Echos to , timeout is 2 seconds;!!!!! Success rate is 100 percent (5/5), round-trip min/avg/max = 12/13/16 ms 如果链路的两端封装相同, 则 ping 测试应该正常 (2) 链路两端封装不同协议 R1(config)#int s0/0/0 R1(config-if)#encapsulation ppp R2(config)#int s0/0/0 R2(config-if)#encapsulation hdlc

128 R1#show int s0/0/0 Serial0/0/0 is up, line protocol is down ( 此处省略 ) // 两端封装不匹配, 导致链路故障 提示 当显示串行接口时, 常见以下几种状态 Serial0/0/0 is up, line protocol is up // 链路正常 Serial0/0/0 is administratively down, line protocol is down // 没有打开该, 执行 no shutdown 可以打开接口 Serial0/0/0 is up, line protocol is down // 物理层正常, 数据链路层有问题, 通常是没有配置时钟 两端封装不匹配或 PPP 认证错误 Serial0/0/0 is down, line protocol is down // 物理层故障, 通常是连线问题 7.3 实验 2:PAP 认证 1. 实验目的通过本实验, 读者可以掌握 PAP 认证的配置方法这项技能 2. 实验拓扑如图 7-1 所示 图 7-1 实验 1~ 实验 3 拓扑图 3. 实验步骤在实验 1 基础上继续本实验 首先配置路由器 R1( 远程路由器, 被认证方 ) 在路由器 R2( 中心路由器, 认证方 ) 取得验证 : 1 两端路由器上的串口采用 PPP 封装, 用 encapsulation 命令 : R1(config)#int s0/0/0 R1(config-if)#encapsulation ppp 2 在过程路由器 R1 上, 配置在中心路由器上登录的用户名和密码, 使用 ppp pap sent-username 用户名 password 密码 命令 : R1(config-if)#ppp pap sent-username R1 password 在中心路由器上的路口采用 PPP 封装, 用 encapsulation 命令 :

129 R2(config)#int s0/0/0 R2(config-if)#encapsulation ppp 4 在中心路由器上, 配置 PAP 验证, 使用 ppp authentication pap 命令 : R2(config-if)#ppp authentication pap 5 中心路由器上为远程路由器设置用户名和密码, 使用 username 用户名 password 密码 命令 : R2(config)#username R1 password 以上的步骤只是配置了 R1( 远程路由器 ) 在 R2( 中心路由器 ) 取得验证, 即单向验证 然而, 在实际应用中, 通常采用双向验证, 即 R2 要验证 R1, 而 R1 也要验证 R2. 我们要采用类似的步骤配置 R1, 对 R2 进行验证, 这时 R1 为中心路由器,R2 为远程路由器 6 在中心路由器 R1 上, 配置 PAP 验证, 使用 ppp authentication pap 命令 : R1(config-if)#ppp authentication pap 7 在中心路由器 R1 上为远程路由器 R2 设置用户名和密码, 使用 username 用户名 password 密码 命令 : R1(config-if)#username R2 password 在远程路由器 R2 上, 配置以什么用户名和密码在远程路由器上登录, 使用 ppp pap sent-username 用户名 password 密码 命令 : R2(config-if)#ppp pap sent-username R2 password 提示 在 ISDN 拨号上网时, 却通常只是电信运营商对用户进行验证 ( 要根据用户名来收费 ), 用户不能对电信进行验证, 即验证是单向的 4. 实验调试使用 debug ppp authentication 命令可以查看 PPP 认证过程 R1#debug ppp authentication PPP authentication debugging is on // 以上打开 PPP 认证调试 R1(config)#int s0/0/0 R1(config-if)#shutdown R1(config-if)#no shutdown // 由于 PAP 认证是在链路建立后进行一次, 把接口关闭重新打开以便观察认证过程 *Feb 22 12;18;20.355; %LINK-3-UPDOWN; Interface Serial0/0/0, changed state to up

130 *Feb 22 12;18;20.355; Se0/0/0 PPP; Using default call direction *Feb 22 12;18;20.355; Se0/0/0 PPP; Treating connection as a dedicated line *Feb 22 12;18;20.355; Se0/0/0 PPP; Session handel[c ] Session id [15] *Feb 22 12;18;20.355; Se0/0/0 PPP; Authorization required *Feb 22 12;18;20.359; Se0/0/0 PAP; Using hostname from interface PAP *Feb 22 12;18;20.359; Se0/0/0 PAP; Using password from interface PAP *Feb 22 12;18;20.359; Se0/0/0 PAP; O AUTH-REQ id 13 len 14 from R1 *Feb 22 12;18;20.363; Se0/0/0 PAP; I AUTH-REQ id 2 len 14 from R2 *Feb 22 12;18;20.363; Se0/0/0 PAP; Authenticating peer R2 *Feb 22 12;18;20.363; Se0/0/0 PPP; Sent PAP LOGIN Request *Feb 22 12;18;20.363; Se0/0/0 PPP; Received LOGIN Response PASS *Feb 22 12;18;20.363; Se0/0/0 PPP; Sent LCP AUTHOR Request *Feb 22 12;18;20.363; Se0/0/0 PPP; Sent IPCP AUTHOR Request *Feb 22 12;18;20.363; Se0/0/0 LCP; Received AAA AUTHOR Response PASS *Feb 22 12;18;20.363; Se0/0/0 IPCP; Received AAA AUTHOR Response PASS *Feb 22 12;18;20.363; Se0/0/0 PAP; O AUTH-ACK id 2 len 5 *Feb 22 12;18;20.363; Se0/0/0 PAP; I AUTH-ACK id 13 len 5 *Feb 22 12;18;20.363; Se0/0/0 PPP; Sent CDPCP AUTHOR Request *Feb 22 12;18;20.363; Se0/0/0 CDPCP; Received AAA AUTHOR Response PASS *Feb 22 12;18;20.363; Se0/0/0 PPP; Sent IPCP AUTHOR Request *Feb 22 12;18;20.363; %LINEPROTO-5-UPDOWN; Line protocol on Interface Serial0/0, changed state to up // 以上是认证成功的例子 *Feb 22 12;22;07.391; Se0/0/0 PPP; Authorization required *Feb 22 12;22;09.411; Se0/0/0 PAP; Using hostname from interface PAP *Feb 22 12;22;09.411; Se0/0/0 PAP; Using password from interface PAP *Feb 22 12;22;09.411; Se0/0/0 PAP; O AUTH-REQ id 15 len 14 from R1 *Feb 22 12;22;09.411; Se0/0/0 PAP; I AUTH-REQ id 4 len 14 from R2 *Feb 22 12;22;09.411; Se0/0/0 PAP; Authenticating peer R2 *Feb 22 12;22;09.411; Se0/0/0 PPP; Sent PAP LOGIN Request *Feb 22 12;22;09.415; Se0/0/0 PPP; Received LOGIN Response FAIL *Feb 22 12;22;09.415; O AUTH-NAK id 4 len 26 msg is Authentication failed // 以上是认证失败的例子, 如密码错误等 7.4 实验 3: CHAP 认证 1. 实验目的通过本实验, 读者可以掌握 CHAP 认证的配置方法这项技能

131 2. 实验拓扑如图 7-1 所示 图 7-1 实验 1~ 实验 3 拓扑图 3. 实验步骤在实验 1 基础上继续本实验 1 使用 username 用户名 password 密码 命令为对方配置用户名和密码, 需要注意的是双方的密码要相同 : R1(config)#username R2 password hello R2(config)#username R1 password hello 2 路由器的两端串口采用 PPP 封装, 并采用配置 CHAP 验证 : R1(config)#int s0/0/0 R1(config-if)#encapsulation ppp R1(config-if)#ppp authentication chap R2(config)#int s0/0/0 R2(config-if)#encapsulation ppp R2(config-if)#ppp authentication chap 上面是 CHAP 验证的最简单配置, 也是实际应用中最常用的配置方式 在配置时, 要求用户为对方路由器, 而双方密码必须一致 原因是 : 由于 CHAP 默认使用本地路由器的名字作为建立 PPP 连接时的标识符, 路由器在收到对方发送过来的询问消息后, 将本地路由器的名字作为身份标识发送给对方 ; 而在收到对方发过来的身份标识之后, 默认使用本地验证方法, 即在配置文件中寻找, 看看有没有用户身份标识和密码 ; 如果, 计算加密值, 结果正确则验证通过 ; 否则验证失败, 连接无法建立 提示 在配置验证时也可以选择同时使用 PAP 和 CHAP 如 : R2(config-if)#ppp authentication chap pap 或 R2(config-if)#ppp authentication pap chap 如果同时使用两种验证方式, 那么在链路协商阶段将先用第一种验证方式进行验证 ; 如果对方建议使用第二种验证方式或者只是简单拒绝使用第一种方式, 那将采用第二种方式 7.5 HDLC PPP 命令汇总 表 7-1 是本意出现的命令

132 表 7-1 本章命令汇总 命令 作用 encapsulation hdlc 把接口的封装改为 HDLC encapsulation PPP 把接口的封装改为 PPP ppp pap sent-username R1 password PAP 认证时, 向对方发送用户名 R1 和密码 PPP authentication pap PPP 的认证方式为 PAP user R1 password 为对方创建用户 R1, 密码为 debug ppp authentication 打开 PPP 的认证调试过程 ppp authentication chap PPP 的认证方式为 CHAP

133 第 8 章帧中继 帧中继线路是中小企业常用的广域网线路, 其通信费用较低 由于帧中继技术的一些特殊性使得帧中继的配置较为复杂, 特别是在帧中继上运行路由协议时更是如此 作为入门, 对帧中继的理解应着重放在 DLCI PVC 帧中继映射和子接口等概念上 本章通过几个实验详细介绍帧中继的关键概念 8.1 帧中继简介 什么是帧中继 帧中继 (Frame Relay,FR) 是面向连接的第 2 层传输协议, 帧中继是典型的包交换技术 相比而言, 同样带宽的帧中继通信费用比 DDN 专线要低, 而且允许用户在帧中继交换网络比较空闲的时候以高于 ISP 所承诺的速率进行传输 帧中继的合理性 用户经常需要租用线路把分散在各地的网络连接起来, 如图 8-1(a) 所示, 如果采用点到点的专用线路 ( 如 DDN),ISP 需要给每个地方的路由器拉 4 地物理线路, 同时每个路由器需要有 4 个串口 帧中继网络拓扑图 8-1(b) 所示, 每个路由器只通过一条线路连接到帧中继云上, 线路的代价大大降低, 每个路由器也只需要一个串行接口 图 8-1 FR 与 DDN 比较

134 8.1.3 DLCI DLCI(Data Link Circiut Identification, 数据链路连接标识符 ) 实际上就帧中继网络中的第 2 层地址 如图 8-2 所示, 当路由器 R1 要把数据发向路由器 R2(IP 地址为 ) 时, 路由器 R1 可以用 DLCI=102 来对 IP 数据包进行第 2 层的封装 数据帧到达帧中继交换机后, 帧中继交换机根据帧中继交换表进行交换 : 从 S1 接口收到一个 DLCI 为 102 的帧时, 交换机将把帧从 S2 接口发送出去, 并且发送出去的帧的 DLCI 改为 201 这样路由器 R2 就会接收到 R1 发来的数据包 而当路由器 R2 要发送数据给 R1(IP 地址为 ) 时, 路由器 R2 可以用 DLCI=201 来对 IP 数据包进行第 2 层的封装, 数据帧到达帧中继交换机后, 帧中继交换机同样根据帧中继交换表进行交换 : 当从 S2 接口收到一个 DLCI 为 201 的帧时, 交换机将把帧从 S1 接口发送出去, 并且发送出去的帧的 DLCI 改为 102, 这样路由器 R1 就会接收到 R2 发来的数据包 图 8-2 帧中继网络通过以上分析可以知道,DLCI 实际上就是 IP 数据包在帧中继链路上进行封装时所需的第 2 层地址 图 8-2 中各路由器的第 3 层地址和第 2 层地址映射如下 : R1; R2; R3; 帧中继的一个非常姝特性是 NBMA( 非广播多路访问 ) 在图 8-2 中, 如果路由器在 DLCI 为 102 的 PVC 上发送一个广播, 路由器 R2 可以收到, 然而 R3 是无法收到的 如果 R1 发送的广播想 R2 和 R3 都收到, 必须分别在 DLCI 为 102 和 103 的 PVC 上各发送一次, 这就是非广播的含义 多路访问的意思是帧中继网络是多个设备接在同一网络介质上, 以太网也是多路访问网络

135 8.1.4 帧中继术语 1 永久虚电路 (PVC): 虚电路是永久建立的链路, 由 ISP 在其帧中继交换机静态配置交换表实现 不管电路两端的设备是否连接上,ISP 总是为它保留相应的带宽 2 数据链路连接标识符 (DLCI): 一个在路由器和帧中继交换机之间标识 PVC 或者 SVC 的数值 3 本地管理接口 (LMI): 是路由器和帧中继交换机之间的一种信令标准, 负责管理设备之间的连接及维护其连接状态 4 承诺信息速率 (Committed Information Rate,CIR): 也叫保证速率, 是 ISP 承诺将要提供的有保证的速率, 一般为一段时间内 ( 承诺速率测量间隔 T) 的平均值, 其单位为 bps 5 超量突发 (Excess Brust,EB): 在承诺信息速率之外, 帧中继交换机试图发送而未被准许的最大额外数据量, 单位为 bit 超量突发依赖于服务提供商提供的服务状况, 但它通常受到本地接入环路端口速率的限制 LMI LMI(Local Management Interface) 提供了一个帧中继交换机和路由器之间的简单信令 在帧中继交换机和路由器之间必须采用相同的 LMI 类型,Cisco 路由器在较高版本 (11.2 以后 ) 的 IOS 中具有自动检测 LMI 类型的功能 配置接口 LMI 类型的命令为 encapsulation frme-relay[cisco ietf] 路由器人帧中继交换机收到 LMI 信息后, 可以得知 PVC 状态 这 3 种 PVC 状态是 : 激活状态 (Active): 本地路由器与帧中继交换机的连接是启动且激活的, 可以与帧中继交换交换数据 ; 非激活状态 (Inactive): 本地路由器与帧中继交换机的连接是启动且激活的, 但 PVC 另一端的路由器未能与它的帧中继交换机通信 ; 删除状态 (Deleted): 本地路由器没有从帧中继交换机上收到任何 LMI, 可能线路或网络有问题, 或者配置了不存在的 PVC 帧中继映射 DLCI 是帧中继网络中的第 2 层地址 路由器要通过帧中继网络把 IP 数据包发到下一跳路由器时, 它必须知道 IP 和 DLCI 的映射才能进行帧的封装 有两种方法可以获得该映射 : 一种是静态映射, 由管理员手工输入 ; 另一种是动态映射 默认情况下, 路由器帧中继接口是开启动态映射 1. 静态映射管理员手工输入的映射就为静态映射, 其命令为 : frame-relay map ip protocol address dlci [broadcast]

136 其中, protocol: 协议类型 address: 网络地址 dlci: 为所需交换逆向 ARP 信息的本地接口的 DLCI 号 broadcast: 参数表示允许在帧中继线路上传送广播或组播信息例子 :R1(config-if)#frame map ip broadcast 2. 动态映射 IARP(Inverse Arp, 逆向 ARP) 允许路由器自动建立帧中继映射, 其工作原理如图 8-3 所示 : 1 路由器 R1 从 DLCI=102 的 PVC 上发送 IARP 包,IARP 包中有 R1 的 IP 地址 ; 2 帧中继云对数据包进行交换, 最终把 IARP 包通过 DLCI=201 的 PVC 发送给 R2; 3 由于 R2 是从 201 的 PVC 上接收到该 IARP 包的, 因此 R2 会建立一个映射 ; ; 4 同样,R2 也发送 IARP 数据包,R1 收到该 IARP 包, 也会自动建立一个映射 ; ; 图 8-3 动态映射 (IARP) 工作示意图 子接口 子接口实际上是一个逻辑的接口, 并不存在真正物理上的子接口 子接口有两种类型 : 占到点和点到多点 当采用点到点子接口时, 每一个子接口用来连接一条 PVC, 每条 PVC 的另一端连接到另一路由器的一个子接口或物理接口, 这种子接口的连接与通过物理接口连接的点对点连接交换果是一样的 每一对点对点的连接都是在不同的子网上 一个点到多点子接口被用来建立多条 PVC, 这些 PVC 连接到远端路由器的多点子接口或物理接口 这时, 所有加入连接的接口 ( 不管是物理接口还是子接口 ) 都应该在同一个子网上 点到多点子接口和一个没有配置子接口的物理主接口相同, 路由更新要受到水平分割的限制 默认情况下, 多点子接口水平分割是开启的

137 8.2 实验 1: 把一台 Cisco 路由器配置为帧中继交换机 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解帧中继交换机的工作原理 ; 2 理解 PVC 的概念 ; 3 用路由器充当帧中继交换机的配置 2. 实验拓扑实验拓扑图如图 8-4 所示 图 8-4 实验 1~ 实验 4 拓扑图 3. 实验步骤这里我们只关心 R2 的配置 (1) 步骤 1: 开启帧中继交换功能 R2(config)frame-relay switching // 把该路由器当成帧中继交换机 (2) 步骤 2: 配置接口封装 R2(config)#int s0/0/0 R2(config-if)#no shutdown R2(config-if)#clock rate 该接口为 DCE, 要配置时钟 R2(config-if)#encapsulation frame-relay

138 // encapsulation frame-relay [ietf] 命令用来配置接口封装成帧中继, 如果不加 ietf 参数, 帧类型为 cisco; 如果加 ietf 参数, 则帧类型为 ietf R2(config)#int s0/0/1 R2(config-if)#no shutdown R2(config-if)#clock rate R2(config-if)#encapsulation frame-relay R2(config)#int s0/1/0 R2(config-if)#no shutdown R2(config-if)#clock rate R2(config-if)#encapsulation frame-relay (3) 步骤 3: 配置 LMI 类型 R2(config)int s0/0/0 R2(config-if)frame-relay lmi-type cisco // frame-relay lmi-type{ansi cisco q933a} 命令用来配置 LMI 的类型, 默认时是 cisco R2(config-if)frame-relay lmi-type dce frame-relay lmi-type{dec dte} 命令用来配置接口是帧中继的 DCE 还是 DTE, 要注意的是这里的帧中继 DEC 和 s0/0/0 接口是 DCE 还是 DTE 无关, 也就是说即使 s0/0/0 是 DTE, 也可以把它配置成帧中继的 DCE R2(config)int s0/0/1 R2(config-if)frame-relay lmi-type cisco R2(config-if)frame-relay lmi-type dce R2(config)int s0/1/0 R2(config-if)frame-relay lmi-type cisco R2(config-if)frame-relay lmi-type dce (4) 步骤 4: 配置帧中继交换表 R2(config)#int s0/0/0 R2(config-if)#frame-relay route 103 interface s0/0/1 301 R2(config-if)#frame-relay route 104 interface s0/0/1 401 // frame-relay route 103 interface s0/0/1 301 命令是配置帧中继交换表的, 告诉路由器如果从该接口收到 DLCI=103 的帧, 从 s0/0/1 交换出去, 并且将 DLCI 改为 301 R2(config)#int s0/0/1 R2(config-if)#frame-relay route 301 interface s0/0/1 103 R2(config)#int s0/1/0 R2(config-if)#frame-relay route 401 interface s0/0/ 实验调试可以使用 show frmae-relay route, show frame pvc 和 show frame lmi 等命令检

139 查帧中继交换机是否正常 (1) show frame-relay route R2#show frame-relay route Input Intf Input Dlci Output Intf Output Dlci Status Serial0/0/0 103 Serial0/0/1 301 inactive Serial0/0/0 104 Serial0/1/0 401 inactive Serial0/0/1 301 Serial0/0/0 103 inactive Serial0/0/1 401 Serial0/0/0 104 inactive (2) show frame pvc PVC Statistics for interface Serial0/0/0(Frame Relay DCE) Active Inactive Deleted Static Local Switched Unused DLCI = 103,DLCI USAGE = SWITCHED,PVC STATUS = INACTIVE,INTERFACE = Serial0/0/0 // 由于 PVC 还未被使用, 所以状态为 inactive input pkts 0 output pkts 0 in bytes 0 out bytes 0 dropped pkts 0 in pkts dropped 0 out pkts dropped 0 out bytes dropped 0 in FECN pkts 0 in BECN pkts 0 out FECN pkts 0 out BECN pkts 0 in DE pkts 0 out DE pkts 0 out bcast pkts 0 out bcast bytes 0 30 second input rate 0 bits/sec, 0 packets/sec 30 second output rate 0 bits/sec, 0 packets/sec switched pkts 0 Detailed packet drop counters; no out intf 0 out intf down 0 no out PVC0 in PVC down 0 out PVCdown 0 pkt too big 0 shaping Q full 0 pkt above DE 0 policing drop 0 pvc create time 00;07;31,last time pvc status changed 00;06;01 ( 此处省略 ) 8.3 实验 2: 帧中继基本配置和帧中继映射 1. 实验目的通过本实验, 读者可以掌握如下技能 :

140 1 帧中继的基本配置 ; 2 帧中继的动态映射 ; 3 帧中继的静态映射 2. 实验拓扑实验拓扑图如图 8-4 所示 图 8-4 实验 1~ 实验 4 拓扑图 3. 实验步骤在实验 1 的基础上进行实验 2. 在图 8-4 中, 我们已经模拟出了帧中继交换机, 现配置 R1,R3 和 R4, 使它们能够互相通信, 配置步骤如下 : (1) 帧中继接口基本配置 R1(config)#int s0/0/0 R1(config-if)#ip address R1(config-if)#no shutdown R1(config-if)encapsulation frame-relay // 使用 encapsulation frame-relay[ietf] 命令配置帧中继封装类型 帧中继有两种封装类型 :cisco 和 (Internet Engineering Task Force) 对于 cisco 路由器,cisco 是它的默认值 ; 对于非 cisco 路由器, 须选用 ietf 类型 但国内帧中继线路一般为 ietf 类型的封装, 我们这里由于上面的帧中继交换机中封装类型是 cisco, 所以选择 cisco R1(config-if)#frame-relay lmi-type cisco // 如果采用的 IOS 是 11.2 或以后版本的, 路由器可以自动适应 LMI 类型, 则本步骤可不做 国内帧中继线路一般采用 ansi 的 LMI 信令类型, 这里采用的是 cisco R3(config)#int s0/0/0 R3 (config-if)#ip address R3(config-if)#no shutdown R3(config-if)encapsulation frame-relay R4(config)#int s0/0/0 R4(config-if)#ip address R4(config-if)#no shutdown R4(config-if)encapsulation frame-relay (2) 测试连通性从各个路由器 ping 其他路由器 R1#ping Type escape sequence to abort. Sending 5,100-byte ICMP Echos to ,timeout is 2 seconds;

141 !!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 28/28/28 ms R1#ping Type escape sequence to abort. Sending 5,100-byte ICMP Echos to ,timeout is 2 seconds;!!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 28/28/28 ms R1#show frame-relay map Serial0/0/0(up); ip dlci 103(0x67,0x1870),dynamic, broadcast,status defined,active Serial0/0/0(up); ip dlci 103(0x68,0x1880),dynamic, broadcast,status defined,active // 时, 帧中继接口开启了动态映射, 会自动建立帧中继, dynamic 表明这是动态映射 R1#show frame-relay pvc PVC Statistics for interface Serial0/0/0 (Frame Relay DTE) Active Inactive Deleted Static Local Switched Unused DLCI = 103,DLCI USAGE = LOCAL,PVC STATUS = ACTIVE,INTERFACE = Serial0/0/0 // 可以看到 DLCI=103 的 PVC 状态为 inactive input pkts 11 output pkts 11 in bytes 1074 out bytes 1074 dropped pkts 0 in pkts dropped 0 out pkts dropped 0 out bytes dropped 0 in FECN pkts 0 in BECN pkts 0 out FECN pkts 0 out BECN pkts 0 in DE pkts 0 out DE pkts 0 out bcast pkts 1 out bcast bytes 34 5 minute input rate 0 bits/sec, 0 packets/sec 5 minute output rate 0 bits/sec, 0 packets/sec switched pkts 0 Detailed packet drop counters; No out intf 0 out intf down 0 no out PVC0 In PVC down 0 out PVCdown 0 pkt too big 0 Shaping Q full 0 pkt above DE 0 policing drop 0 pvc create time 00;07;31,last time pvc status changed 00;06;01 ( 此处省略 ) (3) 手工配置帧中继映射 默认情况, 路由器支持 IARP 若 IARP 未打开, 可以用下列命令设置 : R1(config-if)#frame-relay inverse-arp 也可以关闭 IARP, 使用静态映射, 命令如下 : frame-relay map ip address dlci[broadcast] 这里的 broadcast 参数是允许该帧中继链路通过多播或广播包, 如果帧中继链路上要运行

142 路由协议, 该参数则非常重要 R1(config)#int s0/0/0 R1(config-if)#no frame-relay inverse-arp // 关闭自动映射 R1(config-if)frame-relay map ip broadcast R1(config-if)frame-relay map ip broadcast R1(config)#int s0/0/0 R1(config-if)#no frame-relay inverse-arp R1(config-if)frame-relay map ip broadcast R1(config)#int s0/0/0 R1(config-if)#no frame-relay inverse-arp R1(config-if)frame-relay map ip broadcast 4. 实验调试可以使用 show frame-relay map, show frame pvc 和 show frame lmi 等命令检查帧中继交换机是否正常 R1#show frame-relay map Serial0/0/0(up);ip dlci 103(0x67,0x1870),dynamic, broadcast,status defined,active 从命令输出中可以得到的信息如下所述 : 映射到 103; Dynamic: 表明是动态映射 ; Broadcast: 该 PVC 允许广播包的通过 ; Active: 该 PVC 是激活的 以上命令很重要, 如果在映射表中不存在映射, 路由器将无法通信 可以使用 clear frame-relay inarp 命令清除无效的帧中继映射表 R1#show frame-relay pvc DLCI = 103,DLCI USAGE = LOCAL,PVC STATUS = ACTIVE,INTERFACE = Serial0/0/0 input pkts output pkts in bytes out bytes dropped pkts 0 in FECN pkts 287 in BECN pkts 290 out FECN pkts 0 out BECN pkts 0 in DE pkts out DE pkts 0 pvc create time 1w1d,last time pvc status changed 1w1d 从命令输出中可以得到的信息如下所述

143 DLCI = 103: 表明该 PVC 的 DLCI 为 103. PVC STATUS = ACTIVE: 表明 PVC 的状态是激活的 ; 若 PVCSTATUS = INACTIVE 表明远端路由器没有正确配置 ; 若 PVC STATUS = DELETED 表明输入了错误的 DLCI, 该 PVC 不存在 R1#show frame-relay lmi LMI Statistics for interface Serial0/0(Frame Relay DTE)LMI TYPE = CISCO Invalid Unnumbered info 0 Invalid Port Disc 0 Invalid dummy Call Ref 0 Invalid Msg Type 0 Invalid Status Message 0 Invalid Lock Shift 0 Invalid Information ID 0 Invalid Report IE Len 0 Invalid Report Request 0 Invalid Keep Ie Len 0 Num Status Enq.Sent Num Status msgs Rcvd Num Update Status Rcvd 0 Num Status Timeouts 2 从命令输出中可以得到的信息如下所述 LMI TYPE = CISCO: 表明帧中继 LMI 类型为 cisco; Frame Relay DTE: 这是帧中继 DTE; Num Status Enq.Sent 74859: 表明路由器向帧中继交换机发送的 LMI 状态查询消息的数量 ; Num Status msgs Rcvd 74857: 表明路由器从帧中继交换机收到的 LMI 状态信息的数量 8.4 实验 3: 帧中继上的 RIP 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 帧中继上路由协议运行的特殊性 ; 2 水平分割 2. 实验拓扑实验拓扑图如图 8-4 所示 3. 实验步骤在实验 2 的基础上继续本实验 (1) 配置 RIP R1(confgi)#interface Loopback0 R1(config-if)#ip address 图 8-4 实验 1~ 实验 4 拓扑图

144 R1(config)#router rip

145 R1(config-router)#network R1(config-router)#network R3(confgi)#interface Loopback0 R3(config-if)#ip address R3(config)#router rip R3(config-router)#network R3(config-router)#network R4(confgi)#interface Loopback0 R4(config-if)#ip address R4(config)#router rip R4(config-router)#network R4(config-router)#network (2) 检查路由表并测试在各个路由器上检查路由表, 并测试各路由环回口之间能否互相 ping 通 R3#show ip route ( 此处省略 ) C /24 is directly connected,serial0/0/1 R /8[120/1]via ,00;00;26,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 R /8[120/2]via ,00;00;26,Serial0/0/1 // 看到正常的路由表, 注意 RIP 路由表中的下一跳 R3#ping source loopback 0 Type escape sequence to abort. Sending 5,100-byte ICMP Echos to ,timeout is 2 seconds; Packet sent with a source address of !!!!! Success rate is 100 percent (5/5),round-trip min/avg/max = 52/54/46 ms // 以上表明从 R3 的 loopback 0 接口能 ping 通 R4 的 loopback 0 接口 R3#ping Type escape sequence to abort. Sending 5,100-byte ICMP Echos to ,timeout is 2 seconds;... // 在这里,ping 命令没指明源地址, 则 ICMP 数据包的源 IP 为 , 目标为 路由器 R3 查询路由得知该数据包应该发送给 , 而 的帧中继映射 DLCI 为 301; 数据包到达 R1, 路由器 R1 查询路由表得知该数据包应该发送给 , 而

146 的帧中继映射 DLCI 为 104 R4 收到数据包, 进行响应,ICMP 数据包的源 IP 为 , 目标为 ;R4 有 /24 的直连路由, 却没有 的帧中继映射, 因此无法进行封装 为了解决该问题, 可以在 R4 中增加映射 : R4(config)#int s0/0/1 R4(config-if)frame-relay map ip 这样从 R3 就可以直接 ping 通 R4 的 loopback0 接口了 (3) 水平分割问题 R1#show ip int s0/0/0 Serial0/0/0 is up,line protocol is up Internet addfress is /24 ( 此处省略 ) Security level is defautl Spilt horizon is disabled // 接口封装了帧中继后, 水平分割被自动关闭 ICMP redirects are always sent ( 此处省略 ) 在 R1 上重新打开水平分割, 在各路由器上检查路由表 R1(config)#int Serial0/0/0 R1(config-if)#ip split-horizon R1#clear ip route * // 清除路由表 R1#show ip route C /24 is directly connected,serial0/0/ /24 is subnetted, 1 subnets C is directly connected,looopback0 R /8[120/1]via ,00;00;01,Serial0/0/0 R /8[120/1]via ,00;00;01,Serial0/0/0 //R1 可以获得 R3 和 R4 的环回口路由 R3#clear ip route * R3#show ip route C /24 is directly connected,serial0/0/1 R /8[120/1]via ,00;00;00,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 //R3 只能获得 R1 的环回口路由, 这是由于 R1 上的水平分割开启后,R1 从 R4 接收到 R4 公告的路由后, 不从帧中继口发送出来, 导致 R3 没有接收到 R4 上公告的路由 R4#clear ip route * R4#show ip route C /24 is directly connected,serial0/0/1

147 R /8[120/1]via ,00;00;01,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 //R4 也只能获得 R1 的环回口路由 8.5 实验 4: 帧中继点到多点子接口 1. 实验目的通过本实验, 读者可以掌握点到多点子接口的配置这项技能 2. 实验拓扑实验拓扑图如图 8-4 所示,R3 和 R4 使用帧中继主接口, 在 R1 上创建点到多点子接口 图 8-4 实验 1~ 实验 4 拓扑图 3. 实验步骤在实验 1 的基础上继续本实验 (1) 对主接口进行配置 R1(config)#interface serial0/0/0 R1(config-if)no ip address // 主接口下不需要 IP 地址 R1(config-if)#encap frame-relay // 封装帧中继 R1(config-if)#no frame-relay inverse-arp // 通常需要关闭主接口下的 IARP R1(config-if)#no shutdown (2) 创建点到多点子接口 R1(config)int s0/0/0.1 multipoint // 创建点到多点子接口 // 这里 interface serial solt-number interface-number.subinterface-number{multipoint point-to-point} 命令用来创建子接口, 其中, slot-number/interface-number: 本物理接口的号码 ; subinterface-number: 是子接口号, 用户可以根据自己来确定 ; multipoint 和 point-to-point: 属于必须选择的项, 是子接口的类型, 那么是点到多点多, 要么是点到点 R1(config-subif)#ip address R1(config-subif)#frame-relay map ip broadcast R1(config-subif)#frame-relay map ip broadcast // 以上是配置帧中继映射 (3) 在 R1 上配置路由协议

148 R1(config)#router rip

149 R1(config-router)#network R1(config-router)#network (4)R3 和 R4 的完整配置 R3(config)interface serial 0/0/1 R3(config-subif)#ip address R3(config-if)#encap frame-relay R3(config-if)#no frame-relay inverse-arp R3(config-subif)#frame-relay map ip broadcast R3(config-if)#no shutdown R3(config)#router rip R3(config-router)#network R3(config-router)#network R4(config)interface serial 0/0/1 R4(config-subif)#ip address R4(config-if)#encap frame-relay R4(config-if)#no frame-relay inverse-arp R4(config-subif)#frame-relay map ip broadcast R4(config-if)#no shutdown R4(config)#router rip R4(config-router)#network R4(config-router)#network 提示 可以使用 no interface s0/0/0.1 命令来删除子接口, 然而需要重新启动路由器, 该接口才真正被删除 4. 实验调试在各个路由器上检查路由表, 注意路由的下一跳 R1#show ip route ( 此处省略 ) C /24 is directly connected,serial0/0/ /24 is subnetted, 1 subnets C is directly connected,looopback0 R /8[120/1]via ,00;00;01,Serial0/0/0 R /8[120/1]via ,00;00;01,Serial0/0/0 //R1 可以获得 R3 和 R4 的环回口路由 R3#show ip route

150 ( 此处省略 ) C /24 is directly connected,serial0/0/1 R /8[120/1]via ,00;00;01,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 //R3 只能获得 R1 的环回口路由, 这是由于默认时,R1 的点到多点子接口水平分割是开启的, 可以使用 ip split-horizon 命令在子接口下关闭水平分割 R4#show ip route ( 此处省略 ) C /24 is directly connected,serial0/0/1 R /8[120/1]via ,00;00;01,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 //R4 同样也只能获得 R1 的环回口路由 8.6 实验 5: 帧中继点到点子接口 1. 实验目的通过本实验, 读者可以掌握点到点子接口的配置这项技能 2. 实验拓扑实验拓扑图如图 8-5 所示 图 8-5 实验 5 拓扑图

151 3. 实验步骤在实验 1 的基础上继续本实验 (1) 对主接口进行配置 R1(config)#interface serial0/0/0 R1(config-if)no ip address R1(config-if)#encap frame-relay R1(config-if)#no frame-relay inverse-arp R1(config-if)#no shutdown (2) 创建点到点子接口 R1(config)int s0/0/0.3 point-to-point // 创建点到点子接口 R1(config-subif)#ip address R1(config-subif)#frame-relay interface-dlci 103 // 在点到点子接口下不能使用 frame-relay map ip 命令来配置帧中继的映射, 而改用 frame-relay interface-dlci 103 命令 R1(config)int s0/0/0.4 point-to-point R1(config-subif)#ip address R1(config-subif)#frame-relay interface-dlci 104 // 注意 : 不同子接口应属于不同的子网 (3) 在 R1 上配置路由协议 R1(config)#router rip R1(config-router)#network R1(config-router)#network R1(config-router)#network (4)R3 和 R4 的完整配置 R3(config)interface serial 0/0/1 R3(config-if)no ip address R3(config-if)#encap frame-relay R3(config-if)#no frame-relay inverse-arp R3(config-if)#no shutdown R3(config-if)#exit R3(config)interface serial 0/0/1.1 point-to-point R3(config-subif)#ip address R3(config-subif)#frame-relay interface-dlci 301 R3(config- subif)#exit R3(config)#router rip R3(config-router)#network

152 R3(config-router)#network R4(config)interface serial 0/0/1 R4(config-if)no ip address R4(config-if)#encap frame-relay R4(config-if)#no frame-relay inverse-arp R4(config-if)#no shutdown R4(config-if)#exit R4(config)interface serial 0/0/1.1 point-to-point R4(config-subif)#ip address R4(config-subif)#frame-relay interface-dlci 401 R4(config- subif)#exit R4(config)#router rip R4(config-router)#network R4(config-router)#network 实验调试在各个路由器上检查路由表, 注意路由的下一跳 R3#show ip route ( 此处省略 ) R /8[120/1]via ,00;00;14,Serial0/0/1.1 C /24 is directly connected,serial0/0/1.1 R /24[120/1]via ,00;00;14,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 R /8[120/2]via ,00;00;14,Serial0/0/ 帧中继命令汇总 表 8-1 是本章出现的命令 表 8-1 本章命令汇总命令 frame-relay switching encapsulation frame-relay frame-relay lmi-type cisco frame-relay intf-type dce frame-relay route show frame-relay route show frame pvc 作用把路由器当成帧中继交换机接口封装成帧中继配置 LMI 的类型配置接口是帧中继的 DCE 还是 DTE 配置帧中继交换表显示帧中继交换表显示帧中继 PVC 状态

153 show frame lmi show frame-relay map no frame-relay inverse-arp ip split-horizon int s0/0/0.1 multipoint int s0/0/0.3 point-to-point frame-relay interface-dlci 104 显示帧中继 LMI 信息查看帧中继映射关闭帧中继自动映射打开水平分割创建点到多点子接口创建点到点子接口在点到点子接口上配置 DLCI

154 第 9 章 ACL 随着大规模开施工网络的开发, 网络面临的威胁也就越来越多 网络安全问题成为网络管理员最为头病的问题 一方面, 为了业务的发展, 必须允许对网络资源的开发访问 ; 另一方面, 又必须确保数据和资源的尽可能安全 网络安全采用的技术很多, 而通过访问控制列表 (ACL) 可以对数据流进行过滤, 是实现基本的网络手段之一 本章只研究基于 IP 的 ACL 9.1 ACL 概述 访问控制列表简称为 ACL, 它使用包过滤技术, 在路由器上读取第 3 层及第 4 层包头中的信息, 如源地址 目的地址 源端口和目的端口等, 根据预告定义好的规则对包进行过滤从而达到访问控制的目的 ACL 分很多种, 不同场合应用不同种类的 ACL 1. 标准 ACL 标准 ACL 最简单, 是通过使用 IP 包中的源 IP 地址进行过滤, 表号范围 1~99 或 1 300~ 扩展 ACL 扩展 ACL 比标准 ACL 具有更多的匹配项, 功能更加强大和细化, 可以针对包括协议类型 源地址 目的地址 源端口 目的端口和 TCP 连接建立等进行过滤, 表号范围 100~199 或 2 000~ 命名 ACL 以列表名称代替列表编号来定义 ACL, 同样包括标准和扩展两种列表 在访问控制列表的学习中, 要特别注意以下两个术语 1 通配符掩码 : 一个 32 比特位的数字字符串, 它规定了当一个 IOP 地址与其他的 IP 地址进行比较时, 该 IP 地址中哪些位应该被忽略 通配符掩码中的 1 表示忽略 IP 地址中对应的位, 而 0 则表示该位必须匹配 两种特殊的通配符掩码是 和 , 前者等价于关键字 any, 而后者等价于关键字 host 2 Inbound 和 Outbound: 当在接口上应用访问控制列表时, 用户要指明访问控制列表是应用于流入数据, 还是流出数据 总之,ACL 的应用非常广泛, 它可以实现如下的功能 : 1 拒绝或允许流入 ( 或流出 ) 的数据流通过特定的接口 ;

155 2 为 DDR 应用定义感兴趣的数据流 ; 3 过滤路由更新的内容 ; 4 控制对虚拟终端的访问 ; 5 提供流量控制 9.2 实验 1: 标准 ACL 1. 实验目的通过本实验可以掌握 : 1 ACL 设计原则和工作过程 ; 2 定义标准 ACL; 3 应用 ACL; 4 标准 ACL 调试 2. 拓扑结构实验拓扑图如图 9-1 所示 图 9-1 标准 ACL 配置本实验拒绝 PC2 所在网段访问路由器 R2, 同时只允许主机 PC3 访问路由器 R2 的 Telnet 服务 整个网络配置 EIGRP 保证 IP 的连通性 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router eigrp 1 R1(config-router)#network R1(config-router)#network R1(config-router)#network R1(config-router)#no auto-summary (2) 步骤 2: 配置路由器 R2 R2(config)#router eigrp 1 R2(config-router)#network

156 R2(config-router)#network R2(config-router)#network R2(config-router)#no auto-summary R2(config)#access-list 1 deny // 定义 ACL R2(config)#access-list 1 permit any R2(config)#interface Serial0/0/0 R2(config-if)#ip access-group 1 in // 在接口下应用 ACL R2(config)#access-list 2 permit R2(config-if)#line vty 0 4 R2(config-line)#access-class 2 in R2(config-line)#password cisco R2(config-line)#login (3) 步骤 3: 配置路由器 R3 R3(config)#router eigrp 1 R3(config-router)#network R3(config-router)#network R3(config-router)#no auto-summary 技术要点 1 ACL 定义好后可以在很多地方应用, 接口上应用只是其中之一, 其他的常用应用包括在 route map 中的 match 应用 ( 第 21 章介绍 ) 和在 vty 下用 access-class 命令调用, 用来控制 Telnet 的访问 ; 2 访问控制列表表项的检查按自上而下的顺序进行, 并且从第一个表项开始, 所以必须考虑在访问控制列表中定义语句的次序 ; 3 路由器不对自身产生的 IP 数据包进行过滤 ; 4 访问控制列表最后一条是隐含的拒绝所有 ; 5 每一个路由器接口的每一个方向, 每一种协议只能创建一个 ACL; 6 access-class 命令只对标准 ACL 有效 4. 实验调试在 PC1 网络所在的主机上 ping , 应该通, 在 PC2 网络所在的主机上 ping , 应该不通, 在主机 PC3 上 Telnet , 应该成功 (1)show iop access-lists 该命令用来查看所定义的 IP 访问控制列表 R2#show ip access-lists Standard IP access list 1 10 deny ,wildcard bits (11 matches) 20 permit any (405 matches)

157 Standard IP access list 2 10 permit (2 matches) 以上输出表明路由器 R2 上定义的标准访问控制列表为 1 和 2, 括号中的数字表示匹配条件的数据包的个数, 可以用 clear access-list counters 命令将访问控制列表计数器清零 (2)show iop interface R2#show ip interface s0/0/0 Serial0/0/0 is up,line protocol is up Internet address is /24 Broadcast address is Address determined by setup command MTU is 1500 bytes Helper address is not set Directed broadcast forwarding is disabled Multicast reserved groups joined; Outgoing access list is not set Inbound access list is 1... 以上输出表明在接口 s0/0/0 的入方向应用了访问控制列表 实验 2: 扩展 ACL 1. 实验目的通过本实验可以掌握 : 1 定义扩展 ACL; 2 应用扩展 ACL; 3 扩展 ACL 调试 2. 拓扑结构实验拓扑图如图 9-1 所示 图 9-1 标准 ACL 配置 本实验要求只允许 PC2 所在网段的主机访问路由器 R2 的 WWW 和 Telnet 服务, 并拒绝 PC3 所在网段 ping 路由器 R2. 删除实验 1 定义的 ACL, 保留 EIGRP 配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#access-list 100 permit tcp host eq www

158 R1(config)#access-list 100 permit tcp host eq www R1(config)#access-list 100 permit tcp host eq www R1(config)#access-list 100 permit tcp host eq telnet R1(config)#access-list 100 permit tcp host eq telnet R1(config)#access-list 100 permit tcp host eq telnet R1(config)#interface g0/0 R1(config-if)#ip access-group 100 in (2) 步骤 2: 配置路由器 R2 R2(config)#no access-list 1 // 删除 ACL R2(config)#no access-list 2 R2(config)#ip http server // 将路由器配置成 Web 服务器 R2(config)#line vty 0 4 R2(config-line)#password cisco R2(config-line)#login (3) 步骤 3: 配置路由器 R3 R3(config)#access-list 101 deny icmp host log R3(config)#access-list 101 deny icmp host log R3(config)#access-list 101 deny icmp host log R3(config)#access-list 101 permit ip any any R3(config)#interface g0/0 R3(config-if)#ip access-group 101 in 技术要点 1 参数 log 会生成相应的日志信息, 用来记录经过 ACL 入口的数据包的情况 2 尽量考虑将扩展的访问控制列表放在靠近过滤源的位置上, 这样创建的过滤器就不会反过来影响其他接口上的数据流 另外, 尽量使标准的访问控制列表靠近目的, 由于标准访问控制列表只使用源地址, 如果将其靠近源会阻止数据包流向其他端口 4. 实验调试 1 分别在 PC2 上访问路由器 R2 的 Telnet 和 WWW 服务, 然后查看访问控制列表 100: R1#show ip access-lists Extended IP access list permit tcp ,host eq www(8 matches) 20 permit tcp ,host eq www 30 permit tcp ,host eq www 40 permit tcp ,host eq telnet(20 matches) 50 permit tcp ,host eq telnet(4 matches)

159 60 permit tcp ,host eq telnet(4 matches) 2 在 PC3 所在网段的主机 ping 路由器 R2, 路由器 R3 会出现下面的日志信息 *Feb 25 17;35;46.383;%SEC-6-IPACCESSLOGDP;list 101 denied icmp > (0/0),1 packet *Feb 25 17;41;08.959;%SEC-6-IPACCESSLOGDP;list 101 denied icmp > (0/0),4 packet *Feb 25 17;42;46.919;%SEC-6-IPACCESSLOGDP;list 101 denied icmp > (0/0),1 packet *Feb 25 17;42;56.803;%SEC-6-IPACCESSLOGDP;list 101 denied icmp > (0/0),1 packet 以上输出说明访问控制列表 101 在有匹配数据包的时候, 系统做了日志 3 在路由器 R3 上查看访问控制 101: R3#show ip access-lists Extended IP access list permit icmp ,host log(5 matches) 20 permit icmp ,host log(5 matches) 30 permit icmp ,host e log(5 matches) 40 permit icmp any any(5 matches) 9.4 实验 3: 命名 ACL 命名 ACL 允许在标准 ACL 和扩展 ACL 中使用字符串代替前面所使用的数字来表示 ACL, 命名 ACL 还可以被用来从某一特定的 ACL 中删除个别的控制条目, 这样可以让网络管理员方便地修改 ACL 1. 实验目的通过本实验可以掌握 : 1 定义命令 ACL; 2 应用命名 ACL 2. 拓扑结构实验拓扑如图 9-1 所示 图 9-1 标准 ACL 配置 3. 实验步骤本实验给出了如何用命名 ACL 来实现 9.2 实验 1 和 9.3 实验 2 中的要求

160 (1) 在路由器 R2 上配置命名的标准 ACL, 实现 9.2 实验 1 中的要求 R2(config)#ip access-list standard stand R2(config-std-nacl)#deny R2(config-std-nacl)#permit any R2(config)#interface Serial0/0/0 R2(config-if)#ip access-group stand in R2(config-std-nacl)#permit R2(config-if)#line vty 0 4 R2(config-line)#access-class class in (2) 在路由器 R2 上查看命名访问控制列表 R2#show ip access-lists Standard IP access list class 10 permit Standard IP access list stand 10 deny ,wildcard bits permit any (42 matches) (3) 在路由器 R1 和 R3 上配置命名的扩展 ACL, 实现实验 2 中要求 R1(config)#ip access-list extended ext1 R1(config-std-nacl)#permit tcp ,host eq www R1(config-std-nacl)#permit tcp ,host eq www R1(config-std-nacl)#permit tcp ,host eq www R1(config-std-nacl)#permit tcp ,host eq telnet R1(config-std-nacl)#permit tcp ,host eq telnet R1(config-std-nacl)#permit tcp ,host eq telnet R1(config)interface g0/0 R1(config-if)ip access-group ext1 in R3(config)#ip access-list extended ext3 R3(config-ext-nacl)#deny icmp host log R3(config-ext-nacl)#deny icmp host log R3(config-ext-nacl)#deny icmp host log R3(config-ext-nacl)#permit ip any R3(config)#interface g0/0 R3(config-if)#ip access-group ext3 in (4) 在路由器 R1 和 R3 上查看命名访问控制列表 R1#show ip access-lists Extended IP access list ext1 10 permit tcp ,host eq www

161 20 permit tcp ,host eq www 30 permit tcp ,host eq www 40 permit tcp ,host eq telnet 50 permit tcp ,host eq telnet 60 permit tcp ,host eq telnet R3#show ip access-lists Extended IP access list ext3 10 permit icmp ,host log 20 permit icmp ,host log 30 permit icmp ,host log 40 permit icmp any any 9.5 实验 4: 基于时间 ACL 1. 实验目的通过本实验可以掌握 : 1 定义 time-range; 2 配置基于时间 ACL; 3 基于时间 ACL 调试 2. 拓扑结构实验拓扑图如图 9-1 所示 图 9-1 标准 ACL 配置 本实验要求只允许 PC3 主机在周一到周五的每天 8;00 18;00 访问路由器 R2 的 Telnet 服务 3. 实验步骤 R3(config)#time-range time // 定义时间范围 R3(config-time-range)#periodic weekdays 8;00 to 18;00 R3(config)#access-list 111 permit tcp host host eq telnet time-range time // 在访问控制列表中调用 time-range R3(config)#access-list 111 permit tcp host host eq telnet time-range time R3(config)#access-list 111 permit tcp host host eq telnet time-range time R3(config)#interface g0/0 R3(config-if)ip access-group 111 in 4. 实验调试 1 用 clock 命令将系统时间调整到周一至周五的 8;00 18;00 范围内, 然后在 PC3 上 Telnet 路由器 R3, 此时可以成功, 然后查看访问控制列表 111:

162 R3#show ip access-lists Extended IP access list permit tcp host eq telnet time-range time(active)(15 matches)log 20 permit tcp host eq telnet time-range time(active) 30 permit tcp host eq telnet time-range time(active) 2 用 clock 命令将系统时间调整到 8;00 18;00 范围之外, 然后在 PC3 上 Telnet 路由器 R2, 此时不可以成功, 然后查看访问控制列表 111: R3#show ip access-lists Extended IP access list permit tcp host eq telnet time-range time(inactive)(45 matches)log 20 permit tcp host eq telnet time-range time(inactive) 30 permit tcp host eq telnet time-range time(inactive) 3show time-range: 该命令用来查看定义的时间范围 R3#show time-range time-range entry;time(active) periodic weekdays 8;00 to 18;00 used in ;IP ACL entry used in ;IP ACL entry used in ;IP ACL entry 以上输出表示在 3 条 ACL 中调用了该 time-range 9.6 实验 5 动态 ACL 动态 ACL 是 Cisco IOS 的一种安全特性, 它使用户能在防火墙临时打开一个缺口, 而不会破坏其他已配置了的安全限制 1. 实验目的通过本实验可以掌握 : 1 动态 ACL 工作原理 ; 2 配置 VTY 本地登录 ; 3 配置动态 ACL; 4 动态 ACL 调试 2. 拓扑结构实验拓扑图如图 9-1 所示 图 9-1 标准 ACL 配置本实验要求如果 PC3 所在网段想要访问路由器 R2 的 WWW 服务, 必须先 Telent 路由器 R2 成功后才能访问

163 3. 实验步骤 R2(config)username ccie password cisco // 建立本地数据库 R2(config)#access-list 120 permit tcp host eq telnet R2(config)#access-list 120 permit tcp host eq telnet R2(config)#access-list 120 permit tcp host eq telnet R2(config)#access-list 120 permit eigrp any any // 允许 EIGRP 协议 R2(config)#access-list 120 dynamic test timeout permit ip host // dynamic 定义动态 ACL, timeout 定义动态 ACL 绝对的超时时间 R2(config)#access-list 120 dynamic test1 timeout permit ip host R2(config)#access-list 120 dynamic test2 timeout permit ip host R2(config)#interface s0/0/1 R2(config-if)#ip access-group 120 in R2(config)#line vty 0 4 R2(config-line)#login local //VTY 使用本地验证 R2(config-line)#autocommand access-enable host timeout 5 // 在一个动态 ACL 中创建一个临时性的访问控制列表条目, timeout 定义了空闲超时值, 空闲超时值必须小于绝对超时值 技术要点 如果用参数 host, 那临时性条目将只为用户所用的单个 IP 地址创建, 如果不使用, 那么用户的整个网络都将被该临时性条目允许 4. 实验调试 1 没有 Telnet 路由器 R2, 在 PC3 上直接访问路由器 R2 的 WWW 服务, 不成功, 路由器 R2 的访问控制列表 : R2#show ip access-lists

164 Extended IP access list permit tcp ,host eq telnet(114 matches) 20 permit tcp ,host eq telnet 30 permit tcp ,host eq telnet 40 permit eigrp any any (159 matches) 50 dynamic test timeout permit ip host dynamic test1 timeout permit ip host dynamic test2 timeout permit ip host Telnet 路由器 R2 成功之后, 在 PC3 上访问路由器 R2 的 WWW 服务, 成功, 路由器 R2 的访问控制列表 : R2#show ip access-lists Extended IP access list permit tcp ,host eq telnet(114 matches) 20 permit tcp ,host eq telnet 30 permit tcp ,host eq telnet 40 permit eigrp any any (159 matches) 50 Dynamic test timeout permit ip host permit ip host host (15 matches)(teme left 288) 60 Dynamic test1 timeout permit ip host Dynamic test2 timeout permit ip host 从 1 和 2 的输出结果可以看到, 从主机 Telnet , 如果通过认证, 该 Telnet 会话就会被切断,IOS 软件将在动态访问控制中动态建立一临时条目 permit ip host host , 此时在主机 上访问 的 Web 服务, 成功 9.7 实验 6: 自反 ACL 1. 实验目的通过本实验可以掌握 : 1 自反 ACL 工作原理 ; 2 配置自反 ACL; 3 自反 ACL 调试 2. 拓扑结构实验拓扑图如图 9-2 所示 图 9-2 自反 ACL 配置本实验要求内网可以主支访问外网, 但是外网不能主动访问内网, 从而有效保护内网

165 3. 实验步骤 (1) 步骤 1: 分别在路由器 R1 和 R3 上配置默认路由确保 IP 连通性 R1(config)#ip route R3(config)#ip route (2) 步骤 2: 在路由器 R2 上配置自反 ACL R2(config)#ipo access-list extended ACLOUT R2(config-ext-nacl)#permit tcp any any reflect REF // 定义自反 ACL R2(config-ext-nacl)#permit udp any any reflect REF R2(config)#ip access-list extended ACLIN R2(config-ext-nacl)#evaluate REF // 评估反射 R2(config)#int s0/0/1 R2(config-if)#ip access-group ACLOUT out R2(config-if)#ip access-group ACLIN in R2(config)#ip route R2(config)#ip route 技术要点 1 自反 ACL 永远是 permit 的 ; 2 自反 ACL 允许高层 Session 信息的 IP 包过滤 ; 3 利用自反 ACL 可以只允许出去的流量, 但是阻止从外部网络产生的向内部网络的流量, 从而可以更好地保护内部网络 ; 4 自反 ACL 是在有流量产生时 ( 如出方向的流量 ) 临时自动产生的, 并且当 Session 结束时条目就删除 ; 5 自反 ACL 不是直接被应用到某个接口下的, 而是嵌套在一个扩展命名访问列表下的 4. 实验调试 1 在路由器上 R3 打开 Telnet 服务, 在 R1 上 ( 从内网到外网 )Telnet 路由器 R3 成功, 此时在路由器 R2 上查看访问控制列表 : R2#show access-lists Extended IP access list ACLIN 10 evaluate REF Extended IP access list ACLOUT 10 permit tcp any any reflect REF 20 permit udp any any reflect REF Reflexive IP access list REF permit tcp host eq telnet host eq 11002(48 matches)(time left 268)

166 以上输出说明自反列表是在有内部到外部 Telnet 流量经过的时候, 临时自动产生一条列表 2 在路由器上 R1 打开 Telnet 服务, 在 R3 上 ( 从外网到内网 )Telnet 路由器 R1 不能成功, 此时在路由器 R2 上查看访问控制列表 : R2#show access-lists Extended IP access list ACLIN 10 evaluate REF Extended IP access list ACLOUT 10 permit tcp any any reflect REF 20 permit udp any any reflect REF Reflexive IP access list REF 以上输出说明自反列表是在有外部到内部 Telnet 流量经过的时候, 不会临时自动产生一条列表, 所以不能访问成功 9.8 ACL 命令汇总 表 9-1 列出了本章涉及到的主要命令 表 9-1 本章命令汇总命令 show ip access-lists clear access-list counters access-list ip access-group access-class ip access-list time-range time username username password password autocommand 作用查看所定义的 IP 访问控制列表将访问控制列表计数器清零定义 ACL 在接口下应用 ACL 在 vty 下应用 ACL 定义命名的 ACL 定义时间范围建立本地数据库定义自动执行的命令

167 第 10 章 DHCP IP 地址已是每台计算机必定配置的参数了, 手工设置每一台计算机的 IP 地址成为管理员最不愿意做的一件事, 于是自动配置 IP 地址的方法出现了, 这就是 DHCP(Dynamic Host Configuration Protocol, 动态主机配置协议 ) DHCP 服务器能够从预告设置的 IP 地址池里自动给主机分配 IP 地址, 它不仅能够保证 IP 地址不重复分配, 也能及时回收 IP 地址以提高 IP 地址的利用率 10.1 DHCP 概述 在动态 IP 地址的方案中, 每台计算机并不设定固定的 IP 地址, 而是在计算机开机时才被分配一个 IP 地址, 这台计算机被称为 DHCP 客户端, 负责给 DHCP 客户端分配 IP 地址的计算机称为 DHCP 服务器 也就是说,DHCP 采用客户 / 服务器 (Client/Server) 模式, 有明确的客户端和服务器角色划分 DHCP 的工作过程如下 : 1 当 DHCP 客户机启动时, 客户机在当前的子网中广播 DHCPDISCOVER 报文, 向 DHCP 服务器申请一个 IP 地址 2 DHCP 服务器收到 DHCPDISCOVER 报文后, 它将从针对那台主机的地址敬意中为它提供一个尚未被分配出去的 IP 地址, 并把提供的 IP 地址暂时标记为不可用 服务器以 DHCPOFFER 报文送回给主机 如果网络里包含有不止一个的 DHCP 服务器, 则客户机可能收到好几个 DHCPOFFER 报文, 客户机通常只承认第一个 DHCPOFFER 3 客户端收到 DHCPOFFER 后向服务器发送一个含有有关 DHCP 服务器提供的 IP 地址的 DHCPREQUEST 报文 如果客户端没有收到 DHCPOFFER 报文并且还记得以前的网络配置, 此时使用以前的网络配置 ( 如果该配置仍然在有效期限内 ) 4 DHCP 服务器向客户机发回一个含有碑被发出的 IP 地址及其分配方案的一个应答报 (DHCPACK) 5 客户端接收到包含了配置参数的 DHCPACK 报文后, 利用 ARP 检查网络上是否有相同的 IP 地址 如果检查通过, 则客户机接收这个 IP 地址及其参数, 如果发现有问题, 客户机向服务器发送 DHCPDECLINE 信息, 并重新开始中新的配置过程 服务器收到 DHCPDECLINE 信息, 将该地址标为不可用 6 DHCP 服务器只能将那个 IP 地址分配给 DHCP 客户一定时间,DHCP 客户必须在该次租用过期前对它进行更新 客户机在 50% 租借时间过去以后, 每隔一段时间就开始 DHCP 服务器更新前租借 如果 DHCP 服务器应答, 则租用延期 ; 如果 DHCP 服务器始终没有应答, 在有效租借其的 87.5%, 客户应该与任何一个其他的 DHCP 服务器通信, 并请求更新它的配置信息 如果客户机不能和所有的 DHCP 服务器取得联系, 租借时间到后, 它必

168 须放弃当前的 IP 地址并重新发送一个 DHCPDISCOVER 报文开始上述的 IP 地址获得过程 7 客户端可以主动向服务器发出 DHCPRELEASE 报文, 将当前的 IP 地址释放 10.2 实验 1:DHCP 基本配置 1. 实验目的通过本实验可以掌握 : 1 DHCP 的工作原理和工作过程 ; 2 DHCP 服务器的基本配置和调试 ; 3 客户端配置 2. 拓扑结构实验拓扑图如图 10-1 所示 图 10-1 DHCP 基本配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 提供 DHCP 服务 R1(config)#service dhcp //DHCP 服务 R1(config)#no ip dhcp conflict logging // 关闭 DHCP 冲突日志 R1(config)#ip dhcp pool ccie // 定义地址池 R1(dhcp-config)#network /24 //DHCP 服务器要分配的网络和掩码 R1(dhcp-config)#domain-name cisco.com // 域名 R1(dhcp-config)#default-router // 默认网关, 这个地址要和相应网络所连接的路由器的以太口地址相同 R1(dhcp-config)#netbios-name-server //WINS 服务器 R1(dhcp-config)#dns-server //DNS 服务器 R1(dhcp-config)#option 150 ip //TFTP 服务器 R1(dhcp-config)#lease infinite // 定义租期 R1(dhcp-config)#ip dhcp excluded-address // 排除的地址段

169 (2) 步骤 2: 设置 Windows 客户端首先在 Windows 下把 TCP/IP 地址设置为自动获得 ( 如图 10-2), 如果 DHCP 服务器还提供 DNS 和 WINS 等, 也把它们设置为自动获得 图 10-2 修改 TCP/IP 属性 4. 实验调试 (1) 在客户端测试在 命令提示符 下, 执行 C;/>ipconfig/renew 可以更新 IP 地址 ; 而执行 C;/>ipconfig/all 可以看到 IP 地址 WINS DNS 和域名是否正确 ; 要释放地址用 C;/>ipconfig/release 命令 C;\>ipconfig/renew Windows IP Configuration Ethernet adapter 本地连接 ; Connection-sepecific DNS Suffix.;cisco.com IP Address...; Subnet Mask...; Default Gateway...; C;\>ipconfig/all Windows IP Configuration Ethernet adapter 本地连接 ; Connection-sepecific DNS Suffix.;cisco.com Description...;Realtek RTL8139/810x Family Fast Ethernet NIC

170 Physical Address...; DD-5B Dhcp Enabled...;YES Autoconfiguration Enabled...;YES IP Address...; Subnet Mask...; Default Gateway...; DHCP Server...; DNS Servers...; Primary WINS Server...; Lease Obtained...;2007 年 2 月 22 日 13;01;01 Lease Expires...;2038 年 1 月 19 日 11;14;07 (2)show ip dhcp pool 该命令用来查看 DHCP 地址池的信息 R1#show ip dhcp pool Pool ccie; Utilization mark(high/low) ;100/0 Subnet size(first/next) ;0/0 Total addresses ;254 // 地址池中共计 254 个地址 Leased addresses ;2 // 已经分配出去 2 个地址 Pending event ;none 1 subnet is currently in the pool; Current index IP address range Leased addresses // 下一个将要分配的地址 地址池的范围以及分配出去的地址的个数 (3)show ip dhcp binding 该命令用来查看 DHCP 的地址绑定情况 R1#show ip dhcp binding Bindings from all pools not associated with VRF; IP address Client-ID/ Lease expiration Type Hardware address/ Username f.2d Infinite Automatic dd.5b Infinite Automatic 以上输出表明 DHCP 服务器自动分配给客户端的 IP 地址以及所对应的客户端的硬件地址

171 10.3 实验 2: DHCP 中继 1. 实验目的通过本实验可以掌握通过 DHCP 中继实现跨网络的 DHCP 服务 2. 拓扑结构实验拓扑图如图 10-3 所示 图 10-3 DHCP 中继配置在本实验中,R1 仍然担任 DHCP 服务器的角色, 负责向 PC 所在网络和 PC2 所在网络的主机动态分配 IP 地址, 所以, R1 上需要定义两个地址池 整个网络运行 RIPv2 协议, 确保网络 IP 连通性 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 提供 DHCP 服务 R1(config)#interface gigabitehternet0/0 R1(config-if)#ip address R1(config-if)#no shutdown R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)# network R1(config)#service dhcp R1(config)#no ip dhcp conflict logging R1(config)#ip dhcp pool ccie // 定义第一个地址池 R1(dhcp-config)#network /24 R1(dhcp-config)#default-router R1(dhcp-config)#domain-name cisco.com

172 R1(dhcp-config)#netbios-name-server R1(dhcp-config)#dns-server R1(dhcp-config)#option 150 ip R1(dhcp-config)#lease infinite R1(dhcp-config)#ip dhcp excluded-address R1(config)#ip dhcp pool ccnp // 定义第二个地址池 R1(dhcp-config)#network R1(dhcp-config)#domain-name szpt.net R1(dhcp-config)#default-router R1(dhcp-config)#netbios-name-server R1(dhcp-config)#dns-server R1(dhcp-config)#option 150 ip R1(dhcp-config)#lease infinite R1(dhcp-config)#ip dhcp excluded-address (2) 步骤 2: 配置路由器 R2 R2(config)#interface gigabitehternet0/0 R2(config-if)#ip address R2(config-if)#ip helper-address // 配置帮助地址 R2(config-if)#no shutdown R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)# network R2(config-router)# network 技术要点 路由器是不能转发 广播的, 但是很多服务 ( 如 DHCP 和 TFTP 等 ) 的客户请求都是以泛洪广播的方式发起的, 我们不可能将每个网段都旋转这样的服务器, 因此使用 Cisco IOS 帮助地址特性是很好的选择 通过使用帮助地址, 路由器可以被配置为接受对 UDP 服务的广播请求, 然后将之以单点传送的方式发给某个具体的 IP 地址, 或者以定向广播形式向某个网段转发这些请求, 这就是中继 4. 实验调试 (1)show ip dhcp binding 在 PC1 和 PC2 上自动获取 IP 地址后, 在 R1 上执行 : R1#show ip dhcp binding Bindings from all pools not associated with VRF; IP address Client-ID/ Lease expiration Type

173 Hardware address/ Username dd.5b f.2d Infinite Automatic ef.31 Infinite Automatic 以上输出表明两个地址池都为相应的网络上的主机分配了 IP 地址 (2)show ip dhcp pool R1#show ip dhcp pool Pool ccie; Utilization mark(high/low) ;100/0 Subnet size(first/next) ;0/0 Total addresses ;254 Leased addresses ;2 Pending event ;none 1 subnet is currently in the pool; Current index IP address range Leased addresses Pool ccnp; Utilization mark(high/low) ;100/0 Subnet size(first/next) ;0/0 Total addresses ;254 Leased addresses ;1 Pending event ;none 1 subnet is currently in the pool; Current index IP address range Leased addresses (3)debug ip dhcp server events 在 PC2 上先执行 ipconfig/release, 再执行 ipconfig/renew, 显示如下 : R1#debug ip dhcp server R1#clear ip dhcp binding * *Feb 2 05;50;24.475;DHCPD;Sending notification of DISCOVER; *Feb 2 05;50;24.475;DHCPD;htype 1 chaddr dd5b *Feb 2 05;50;24.475;DHCPD;circuit id *Feb 2 05;50;24.475;DHCPD;Seeing if there is an internally specified pool class; *Feb 2 05;50;24.475;DHCPD;htype 1 chaddr dd5b *Feb 2 05;50;24.475;DHCPD;circuit id *Feb 2 05;50;26.475;DHCPD;client requests *Feb 2 05;50;26.475;DHCPD;Adding binding to radix tree ( ) *Feb 2 05;50;26.475;DHCPD;Adding binding to hash tree

174 *Feb 2 05;50;26.475;DHCPD;assigned IP address to client dd.5b *Feb 2 05;50;26.519;DHCPD;Sending notification of ASSIGNMENT; *Feb 2 05;50;26.519;DHCPD;address mask *Feb 2 05;50;26.519;DHCPD;htype 1 chaddr dd5b *Feb 2 05;50;26.519;DHCPD;lease time remaining(secs)= (4)show ip interface R2#show ip interface gigabitethernet0/0 GigabitEthernet0/0 is up,line protocol is up Internet address is /24 Broadcast address is Address determined by setup command MTU is 1500 bytes Helper address is 从以上输出看到 gigabitethernet0/0 接口使用了帮助地址 DHCP 命令汇总 表 10-1 列出了本章涉及到的主要命令表 10-1 本章命令汇总命令 show ip dhcp pool show ip dhcp binding show ip dhcp database show ip interface debug ip dhcp server events service dhcp no ip dhcp conflict logging ip dhcp pool network default-router domain-name netbios-name-server dns-server option 150 ip lease ip dhcp excluded-address ip helper-address 作用查看 DHCP 地址池的信息查看 DHCP 的地址绑定情况查看 DHCP 数据库查看接口信息动态查看 DHCP 服务器的事件开启 DHCP 服务关闭 DHCP 冲突日志配置 DHCP 分配的地址池 DHCP 服务器要分配的网络的掩码默认网关域名 WINS 服务器域名服务器 FTP 服务器配置租期排除地址段配置 DHCP 中继的地址

175 第 11 章 NAT Internet 技术的飞速发展, 使越来越多的用户加入到 Internet, 因此,IP 地址短缺已成为一个十分突出的问题 NAT (Network Address Translation, 网络地址翻译 ) 是解决 IP 地址短缺的重要手段 11.1 NAT 概述 NAT 是一个 IETF 标准, 允许一个机构以一个地址出现在 Internet 上 NAT 技术使一个私有网络可以通过 Internet 注册 IP 连接到外部世界, 位于 Inside 网络和 Outside 网络中的 NAT 路由器在发送数据包之前, 负责把内部 IP 地址翻译成外部合法的 IP 地址 NAT 将每个局域网节点的 IP 地址转换成一个合法的 IP 地址, 反之亦然 它也可以应用到防火墙技术中, 把个别 IP 地址隐藏起来不被外界发现, 对内部网络设备起到保护的作用, 同时, 它还可以帮助网络超越地址的限制, 合理地安排网络中的公有 Internet 地址和私有 IP 地址的使用 NAT 有 3 种类型 : 静态 NAT 动态 NAT 和端口地址转换 (PAT) 1. 静态 NAT 在静态 NAT 中, 内部网络中的每个主机都被永久映射成外部网络中的某个合法的地址 静态地址转换将内部本地地址与内部合法地址进行一对一的转换, 且需要指定和哪个合法地址进行转换 如果内部网络有 服务器或 FTP 服务器等可以为外部用户提供的服务, 这些服务器的 IP 地址必须采用静态地址转换, 以便外部用户可以使用这些服务 2. 动态 NAT 动态 NAT 首先要定义合法地址池, 然后采用动态分配的方法映射到内部网络 动态 NAT 是动态一对一的映射 3.PAT PAT 则是把内部地址映射到外部网络的 IP 地址的不同端口上, 从而可以实现多对一的映射 PAT 对于节省 IP 地址是最为有效的 11.2 实验 1: 静态 NAT 配置 1. 实验目的通过本实验可以掌握 :

176 1 静态 NAT 的特征 ; 2 静态 NAT 基本配置和调试 2. 拓扑结构实验拓扑图如图 11-1 所示 图 11-1 静态 NAT 配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 提供 NAT 服务 R1(config)#ip nat inside source static // 配置静态 NAT 映射 R1(config)#ip nat inside source static R1(config)#interface g0/0 R1(config)#ip nat inside // 配置 NAT 内部接口 R1(config)#interface s0/0/0 R1(config)#ip nat outside // 配置 NAT 外部接口 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network (2) 配置 2: 配置路由器 R2 R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)#network R2(config-router)#network

177 4. 实验调试 (1) debug ip nat 该命令可以查看地址翻译的过程 在 PC1 和 PC2 上 ping ( 路由器 R2 的环回接口 ), 此时应该是通的, 路由器 R1 的输出信息如下 : R1#debug ip nat *Mar 4 02;02;12.779;NAT*;s= > , d= [20240] *Mar 4 02;02;12.779;NAT*;s= , d= > [14435]... *Mar 4 02;02;12.779;NAT*;s= > , d= [25] *Mar 4 02;02;12.779;NAT*;s= , d= > [25] 以上输出表明了 NAT 的转换过程 首先把私有地址 和 分别转换成公网地址 和 访问地址 , 然后回来的时候把网地址 和 分别转换成私有地址 和 (2) show ip nat translations 该命令用来查看 NAT 表 在静态映射时,NAT 表一直存在 R1#show ip nat translations Pro Inside global Inside local Outside local Outside global 以上输出表明了内部全局地址和内部局部地址的对应关系 术语 1 内部局部 (Inside Local) 地址 : 在内部网络使用的地址, 往往是 RFC1918 地址 ; 2 内部全部 (Inside Global) 地址 : 用来代替一个或多个本地 IP 地址的 地外的 向 NIC 注册过的地址 ; 3 外部局部 (Outside Local) 地址 : 一个外部主机相对于内部网络所用的 IP 地址, 不一定是合法的地址 ; 4 外部局部 (Outside Global) 地址 : 外部网络主机的合法 IP 地址

178 11.3 实验 2: 动态 NAT 1. 实验目的通过本实验可以掌握 : 1 动态 NAT 的特征 : 2 动态 NAT 配置和调试 2. 拓扑结构实验拓扑如图 11-1 所示 图 11-1 静态 NAT 配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 提供 NAT 服务 R1(config)#ip nat pool NAT netmask // 配置动态 NAT 转换的地址池 R1(config)ip nat inside source list 1 pool NAT // 配置动态 NAT 映射 R1(config)#access-list 1 permit // 允许动态 NAT 转换的内部地址范围 R1(config)#interface g0/0 R1(config-if)#ip nat inside R1(config-if)#interface s0/0/0 R1(config-if)#ip nat outside 4. 实验调试在 PC1 访问 ( 路由器 R2 的环回接口 ) 的 WWW 服务, 在 PC2 上分别 Telnet 和 ping ( 路由器 R2 的环回接口 ), 调试结果如下 : (1)debug ip nat R1#debug ip nat IP NAT debugging is on R1#clear ip nat translation *// 清除动态 NAT 表 *Mar 4 01;34;23.075;NAT*;s= > , d= [19833] *Mar 4 01;34;23.087;NAT*;s= , d= > [62333]... *Mar 4 01;28;49.867;NAT*;s= > , d= [62864] *Mar 4 01;28;49.875;NAT*;s= , d= > [54062]... 提示 如果动态 NAT 地址池中没有足够的地址进行动态映射, 则会出现类似下面的信息, 提示 NAT 转换失败, 并丢弃数据包 *Feb 22 09;02;59.075;NAT;translation failed(a),dropping packet s= d=

179 (2)show ip nat translations R1#show ip nat translations Pro Inside global Inside local Outside local Outside global tcp ; ; ; ; icmp ; ; ; ;3 tcp ; ; ; ; 以上信息表明当 PC1 和 PC2 第一次访问 地址时,NAT 路由器 R1 为主机 PC1 和 PC2 动态分配两个全局地址 和 , 在 NAT 表中生成两条动态映射的记录, 同时会在 NAT 表中生成和应用相对应的协议和端口号的记录 ( 过期时间为 60 s) 在动态没有过期( 过期时间为 s) 之前, 再有应用从相同主机发起时,NAT 路由器直接查 NAT 表, 然后为应用分配相应的端口号 (3)show ip nat statistics 该命令用来查看 NAT 转换的统计信息 R1#show ip nat statistics Total active translations;5(0 static, 5 dynamic;3 extended) // 有 5 个转换是动态转化 Outside interfaces; Serial0/0/0 //NAT 外部接口 Inside interfaces; GigabitEthernet0/0 //NAT 内部接口 Hits;54 Misses;6 CEF Translated packets;60,cef Punted packets;5 Expired translations;12 //NAT 表中过期的转换 Dynamic mappings; // 动态映射 --Inside Source [Id; 1] access-list 1 pool NAT refcount 2 pool NAT;netmask // 地址池名字和掩码 start end // 地址池范围 type generic,total addresses 98,allocated 2 (2%),misses 0 // 共 98 个地址, 分出去 2 个 Queued Packets;0

180 11.4 实验 3:PAT 配置 1. 实验目的通过本实验可以掌握 : 1 PAT 的特征 ; 2 overload 的使用 ; 3 PAT 配置和调试 2. 拓扑结构实验拓扑图如图 11-1 图 11-1 静态 NAT 配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 提供 NAT 服务 R1(config)#ip nat pool NAT netmsask R1(config)#ip nat side source list 1 pool NAT over // 配置 PAT R1(config)#access-list 1 permit R1(config)#interface g0/0 R1(config-if)#ip nat inside R1(config-if)#interface s0/0 R1(config-if)#ip nat outside 4. 实验调试在 PC1 访问 ( 路由器 R2 的环回接口 ) 的 WWW 服务, 在 PC2 上分别 Telnet 和 ping ( 路由器 R2 的环回接口 ), 调试结果如下 : (1)debug ip nat R1#debug ip nat *Mar 4 01;53;47.983;NAT*;s= > , d= [20056] *Mar 4 01;53;47.995;NAT*;s= , d= > [46201]... *Mar 4 01;54;03.015;NAT*;s= > , d= [20787] *Mar 4 01;54;03.219;NAT*;s= , d= > [12049]... (2)show ip nat translations R1#show ip nat translations Pro Inside global Inside local Outside local Outside global tcp ; ; ; ;80 icmp ; ; ; ;4

181 tcp ; ; ; ;23 以上输出表明进行 PAT 转换使用的是同一个 IP 地址的不同端口号 (3)show ip nat statistics Total active translations;3(0 static,3 dynamic;3 extended) Outside interfaces; Serial0/0/0 Inside interfaces; GigabitEthernet0/0 Hits;762 Misses;22 CEF Translated packets;760,cef Punted packets;47 Expired translations;19 Dynamic mappings; --Inside Source [Id; 1] access-list 1 pool NAT refcount 3 pool NAT;netmask start end type generic,total addresses 98,allocated 1 (1%),misses 0 Queued Packets;0 提示 动态 NAT 的过期时间是 s,pat 的过期时间是 60 s, 通过 show ip nat translations verbose 命令可看 也可以通过下面的命令来修改超时时间 : R1(config)#ip nat translation timeout timeout 参数 timeout 的范围是 0~ 如果主机的数量不是很多, 可以直接使用 outside 接口地址配置 PAT, 不必定义地址池, 命令如下 : R1(config0#ip nat inside source list 1 interface s0/0/0 overload 11.5 NAT 命令汇总 表 11-1 列出了本章涉及到的主要命令 表 11-1 本章命令汇总命令 clear ip nat translation * show ip nat translation show iop nat statistics 作用清除动态 NAT 表查看 NAT 表查看 NAT 转换的统计信息

182 debug ip nat ip nat inside source static ip nat inside ip nat outside ip nat pool ip nat inside source list access-list-number pool name ip nat inside source list access-list-number pool name overload 动态查看 NAT 转换过程配置静态 NAT 配置 NAT 内部接口配置 NAT 外部接口配置动态 NAT 地址池配置动态 NAT 配置 PAT

183 第 12 章交换机基本配置 交换机是局域网中最重要的设备, 交换机是基于 MAC 来进行工作的 和路由器类似, 交换机也有 IOS,IOS 的基本使用方法是一样的 本章将简单介绍交换的一些基本配置, 以及交换机独特的密码恢复和 IOS 恢复步骤 关于 VLAN 和 Trunk 等将在后面章节介绍 12.1 交换机简介 交换机是第 2 层的设备, 可以隔离冲突域 交换机是基于收到的数据帧中的源 MAC 地址和目的 MAC 地址来进行工作的 交换机的作用主要有两个 : 一个是维护 CAM(Conetxt Address Memory) 表, 该表是计算机的 MAC 地址和交换端口的映射表 ; 另一个是根据 CAM 来进行数据帧的转发 交换对帧的处理有 3 种 : 交换机收到帧后, 查询 CAM 表, 如果能查询到目的计算机所在的端口, 并且目的计算机所在的端口不是交换接收帧的源端口, 交换机将把帧从这一端口转发出去 (Forward); 如果该计算机所在的端口和交换机接收帧的源端口是同一端口, 交换机将过滤掉该帧 (Filter); 如果交换机不能查询到目的计算机所在的端口, 交换机将把帧从源端口以外的其他所有端口上发送出去, 这称为泛洪 (Flood), 当交换机接收到的帧是广播帧或多播帧, 交换机也会泛洪帧 以太网交换机转发数据帧有 3 种交换方式, 如图 12-1 所示 种交换方式的比较 (1) 存储转发 (Store-and-Forward) 存储转发方式是先存储后转发的方式, 它把从端口输入的数据帧先全部接收并存储起来, 然后进行 CRC( 循环冗余码校验 ) 检查, 把错误帧丢弃, 最后才取出数据帧目的地址, 查找 CAM 后进行过滤和转发 存储转发方式延迟大, 但是它可以对进入交换机的数据包进行高级别的检测, 该方式可以支持不同速度的端口间的转发 (2) 直接转发 (Cut-Through) 当交换机在输入端口检测到一个数据帧时, 检查该帧的帧头, 只要获取了帧的目的地址, 就开始转发帧 它的优点是 : 开始转发前不需要读取整个完整的帧, 延迟非常小 它的缺点是 :

184 不能提供检测能力 (3) 无碎片 (Fragment-Free) 这是改进后的直接转发, 是一种介于前两者之间的解决方法 无碎片方法在读取数据帧的前 64 字节后, 就开始转发该帧 这种方式虽然也不提供数据校验, 但是能够避免大多数的错误 它的数据处理速度比直接转发方式慢, 但比存储转发方式快许多 Cisco 交换机和路由器一样, 本质上也是台特殊的计算机, 也有 CPU 和 RAM 等部件, 也采用 IOS, 所以交换的很多基本配置 ( 如密码和主机名等 ) 和路由器类似的 12.2 实验 1: 交换机基本配置 1. 实验目的通过本实验, 读者可以掌握交换机的基本配置这项技能 2. 实验拓扑实验拓扑图如图 12-2 所示 图 12-2 实验 1 拓扑图 3. 实验步骤 (1) 步骤 1: 配置主机名 Switch>enable Switch#conf terminal Enter configuration commands,one per line. End with CNTL/Z Switch(config)#hostname S1 (2) 步骤 2: 配置密码 S1(config)#enable secret cisco S1(config)#line vty 0 15 S1(config-line)#passwrod cisco S1(config-line)#login (3) 步骤 3: 接口基本配置默认时, 交换机的以太网接口是开启的, 对于交换机的以太网口可以配置其双工模式和速率等

185 S1(config)#interface f0/1 switch(config-if)#duples{full half auto} //duplex 来用配置接口的双工模式 :full 全双工 ;half 半双工 ;auto 自动检测双工的模式 switch(config-if)#speed{ auto} //speed 命令用来配置交换机的接口速度,10 10Mbps; Mbps; Mbps;auto 自动检测接口速度 (4) 配置管理地址交换机也允许被 Telnet, 这时需要在交换机上配置一个 IP 地址, 这个地址是在 Vlan 接口上配置的 如下 : S1(config)#int vlan 1 S1(config-if)#ip address S1(config-if)#no shutdown S1(config)#ip default-gateway // 以上在 VLAN1 接口上配置了管理地址, 接在 VLAN1 上的计算机可以直接进行 Telnet 该地址 为了其他网段的民可以 Telnet 交换机, 我们在交换上配置了默认网关 (5) 保存配置 S1#copy running-config startup-config Destination filename[startup-config]? Building configuration... [OK] 12.3 实验 2: 交换机端口安全 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解交换机的 CAM 表 ; 2 理解交换机的端口安全 ; 3 配置交换的端口安全特性 2. 实验拓扑实验拓扑图如图 12-3 所示 图 12-3 实验 2 拓扑图

186 3. 实验步骤交换机端口安全特性可以让我们配置交换机端口, 使得当具有非法 MAC 地址的设备接入时, 交换机会自动关闭接口或者拒绝非法设备接入, 也可以限制某个端口上最大的 MAC 地址数 在这里限制 f0/ 接口只允许 R1 接入 (1) 步骤 1: 检查 R1 的 g0/0 接口的 MAC 地址 R1(config)#int g0/0 R1(config-if)#no shutdown R1(config-if)#ip address R1#show int g0/0 GigabitEthernet0/0 is up,line protocol is up Hardware is MV96340 Ethernet,address is b828(bia b828) // 这里可以看到 g0/0 接口的 Mac 地址, 记下它 Internet address is /16 MTU 1500 bytes, BW Kbit,DLY 100 usec, ( 此处省略 ) (2) 步骤 2: 配置交换端口安全 S1(config)#int f0/1 S1(config-if)#shutdown S1(config-if)#switch mode access // 以上命令把端口改为访问模式, 即用来接入计算机, 在下一章将详细介绍该命令的含义 S1(config-if)#switch port-security // 以上命令是打开交换机的端口安全功能 S1(confg-if)#switch port-security maximum 1 // 以上命令只允许该端口下的 MAC 条目最大数量为 1, 即只允许一个设备接入 S1(config-if)#switch port-security violation shutdown switch port-security violation{protect shutdown restrict} // 命令含义如下 : protect; 当新的计算机接入时, 如果该接口的 MAC 条目超过最大数量, 则这个新的计算机将无法接入, 而原有的计算机不受影响 ; shutdown; 当新的计算机接入时, 如果该接口的 MAC 条目超过最大数量, 则该接口将会被关闭, 则这个新的计算机和原有的计算机都无法接入, 需要管理员使用 no shutdown 命令重新打开 ; restrcit; 当新的计算机接入时, 如果该接口的 MAC 条目超过最大数量, 则这个新的计算机可以接入, 然而交换机将向发送警告信息 S1(config-if)#switchport port-security mac-address b828 // 允许 R1 路由器从 f0/1 接口接入 S1(confgi-if)#no shutdown

187 S1(config)#int vlan1 S1(config-if)#no shutdown S1(config-if)#ip address // 以上配置交换机的管理地址 (3) 步骤 3: 检查 MAC 地址表 S1#show mac-address-table Mac Address Table ( 此处省略 ) Vlan Mac Address Type Ports All cccc.cccc STATIC CPU ba11.eb91 DYNAMIC Fa0/ 子 8 STATIC Fa0/1 Total Mac Addresses for this criterion;24 //R1 的 MAC 已经被登记在 f0/1 接口, 并且表明是静态加入的 (4) 步骤 4: 模拟非法接入这时从 R1 ping 交换机的管理地址, 可以 ping 通, 如下 : R1#ping Type escape sequence to abort. Sending 5,100-byte ICMP Echos to ,timeout is 2 seconds;!!!!! Success rate is 100 percent(5/5),round-trip min/avg/max=1/1/4 ms 在 R1 上修改 g0/0 的 MAC 地址为另一个地址, 模拟是另外一台设备接入, 如下 : R1(config)#int g0/0 R1(config-if)#mac-address 几秒钟后, 则在 S1 上出现 : 00;09;39;%PM-4-ERR_DISABLE; psecure-violation error detected on Fa0/1,putting Fa0/1 inerr-adisable state 00;09;39;%PORT_SECURITY-2-PSECURE_VIOLATION;Security violation occurred, caused by MAC address on port FastEthernet0/1. 00;09;40;%LINEPROTO-5-UPDOWN;Line protocol on Interface FastEthernet0/1 changed state to down // 以上提示 f0/1 接口被关闭 S1#show int f0/1

188 FastEthernet0/0 is down,line protocol is down(err-disabled) Hardware is Fast Ethernet,address is 0018.ba11.f503(bia 0018.ba11.f503) MTU 1500 bytes, BW Kbit,DLY 100 usec, reliability 255/255,txload 1/255,rxload 1/255 // 以上表明 f0/1 接口因为错误而被关闭 当非法设备移除后, 在 f0/1 接口下, 执行 shutdown 和 no shutdown 命令可以重新打开该接口 4. 实验调试 S1#show port-security Secure Port MaxSecureAddr CurrentAddrr SecurityViolation Security Action (Count) (Count) (Count) Fa0/ Shutdown Total Addresses in System (excluding one mac per port) :0 Max Addresses limit in System(excluding one mac per port) :6272 // 以上可以查看端口安全的设置情况 12.4 实验 3: 交换机的密码恢复 1. 实验目的通过本实验, 读者可以掌握交换机的密码恢复这项技能 2. 实验拓扑实验拓扑图如图 12-2 所示 图 12-2 实验 1 拓扑图 3. 实验步骤 Cisco 交换机的密码恢复步骤和路由器的密码恢复方法差别较大, 并且不同型号的交换机恢复方法也有所差异 以下是 Catalyst 3560(Catalyst 2950 也类似 ) 交换的密码恢复步骤 1 拨掉交换机的电源, 按住交换机前面板的 Mode 键不放, 接上电源, 你会看到如下 : Base ethernet MAC Address; 00;18;ba;11;f5;00 Xmodem file system is available. The password-recovery mechanism is enabled. The system has been interrupted prior to initializing the flash file system.the following commands will initialize

189 the flash filesystem and finish loading the operating system software; flash_init load_helper bootswitch; 2 输入 flash_init 命令 Initializing Flash... flashfs[0]; 3 files, 1 directories flashfs[0]; 0 orphaned files, 0 orphaned directories flashfs[0]; Total bytes; flashfs[0]; Bytes used; flashfs[0]; Bytes available; flashfs[0]; flashfs fsck took 12 second...done initializing flash. Boot Sector Filesystem (bs;) installed, fsid; 3 Setting console baud rate to 输入 load helper 命令 4 输入 dir flash; Directory of flash;/ 2 rwx <date> c3560 ipbasek9 mz SEB4.bin 3 rwx 1455 <date> config.text 5 rwx 24 <date> private-config.text bytes available bytes used) //config.text 就是交换机的启动配置文件, 和路由器的 start-config 类似 5 输入 :rename flash;config.text flash;config.old 命令 // 以上是将启动配置文件改名, 这样交换机启动时就读不到 config-text 了, 从而没有了密码 6 输入 boot 命令引导系统, 这时就不要再按住 Mode 键了 7 当出现如下提示时, 输入 N; Continue with the configuration dialog?[yes/no];n 8 用 enable 命令, 进入特权模式, 并将文件 config.old 改回 config.text, 命令如下 : rename flash;config.old flash;config.text 9 将原配置装入内存, 命令如下 : copy flash;config.text system;running-config

190 10 修改各个密码 S1#conf t S1#(config)#enable secret cisco S1(config)#exit ⑾ 将配置写入 nvram S1#copy running-config start-config 12.5 实验 4: 交换的 IOS 恢复 1. 实验目的通过本实验, 读者可以掌握交换机的 IOS 恢复这项技能 2. 实验拓扑实验拓扑图如图 12-4 所示 图 12-4 实验 4 拓扑图注意需要把计算机的串口和交换机的 Console 直接连接 3. 实验步骤如果交换机已经正常开机后 IOS 才丢失, 则 IOS 可以从 TFTP 服务器上恢复, 具体步骤请参见路由器的 IOS 恢复步骤 然而如果交换机无法正常开机,IOS 的恢复要使用 Xmodem 方式, 该方式是通过 Console 口从计算机下载 IOS, 速度为 bps, 因此速度很慢 步骤如下 : 1 把计算机的串口和交换机的 Console 口连接好, 用超级终端软件连接上交换机 ; 2 交换机开机后, 执行以下命令 : switch;flash_init switch;load_helper 3 输入复制指令 : switch;copy xmodem; flash;c2950-i6q412-mz ea5a.bin 该命令的含义是通过 Xmodem 方式复制文件, 保存在 FLASH, 文件名为

191 c2950-i6q412-mz ea5a.bin 出现如下提示 : Begin the Xmodem or Xmodem-01K transfer now... CCCC 在超级终端窗口中, 选择 传送 传送文件 菜单, 打开图 12-5 所示窗口, 选择 IOS 文件, 协议为 Xmodem 单击 发送 按钮开始发送文件 由于速度很慢, 请耐心等待, 通信速率为 bps 4 传送完毕后执行以下命令 : switch;boot 启动系统 图 12-5 选择 IOS 文件 12.6 交换机基本配置命令汇总 表 12-1 是本章出现的命令 表 12-1 本章命令汇总 命令 作用 duples{full half auto} 配置以太口的双工属性 speed{ auto} 配置以太口的速率 ip default-gateway 配置默认网关 switch mode access 把端口以为访问模式 switch port-security 打开交换机的端口安全功能 switch port-security maximum 1 允许该端口下的 MAC 条目最大数量为 1 switch port-security violation{protect shutdown restrict} 配置交换机端口安全 switch port-security mac-address b828 允许 MAC 为 b828 的设备接入本接口 show mac-address-table 显示 MAC 地址表 mac-address 改变接口的 MAC 地址 rename flash;config.text flash;config.old 将 FLASH 中的文件改名 copy xmodem; flash;c2950-i6q412-mz ea5a.bin 通过 Xmodem 模式把文件复制到 FLASH 中 boot 重启交换机

192 第 13 章 VLAN,Trunk 和 VTP Cisco 交换机不仅仅具有 2 层交换功能, 它还具有 VLAN 功能 VLAN 技术使我们很容易地控制广播域的大小 有了 VLAN, 交换机之间的级联链路就需要 Trunk 技术来保证望该链路可以同时传输多个 VLAN 的数据 同时为了方便管理各交换机上的 VLAN 信息,VTP 也被引入了 交换贡之间的级联链路带宽如果不够, 我们可以把多条链路捆绑起来形成链路 本章将一一介绍以上各种技术的具体配置 13.1 VLAN,Trunk 和 VTP 简介 VLAN 如图 13-1 所示, 虚拟局域网 (Virtual LAN,VLAN) 是交换机端口的逻辑组合 VLAN 工作在 OSI 的第 2 层, 一个 VLAN 就是一个广播域,VLAN 之间的通信是通过第 3 层的路由器来完成的 VLAN 有以下优点 13-1 VLAN.JPG

193 1 控制网络的广播问题 : 每一个 VLAN 是一个广播域, 一个 VLAN 上的广播不会扩散到另一 VLAN; 2 简化网络管理 : 当 VLAN 中的用户位置移动时, 网络管理员只需设置几条命令即可 ; 3 提高网络的安全性 :VLAN 能控制广播,VLAN 之间不能直接通信 ; 定义交换机的商品在哪个 VLAN 上的常用方法, 如下所述 1 基于端口的 VLAN: 管理员把交换机某一商品指定为某一 VLAN 的成员 ; 2 基于 MAC 地址的 VLAN: 交换机根据节点的 MAC 地址, 决定将其旋转于哪个 VLAN 中 Trunk 当一个 VLAN 跨过不同的交换机时, 在同一 VLAN 上但是却是在不同的交换机上的计算机进行通过时需要使用 Trunk Trunk 技术使得一条物理线路可以传送多个 VLAN 的数据 交换机从属于某一 VLAN( 例如 VLAN 3) 的端口接收到数据, 在 Trunk 链路上进行传输前, 会加上一个标记, 表明该数据是 VLAN 3 的 ; 到了对方交换机, 交换机会把该标记去掉, 只发送到属于 VLAN 3 的端口上 有两种常见的帧标记技术 :ISL 和 802.1Q ISL 技术在原有的帧上重新加了一个帧头, 并重新生成了帧检验序列 (FCS), ISL 是 Cisco 特有的技术, 因此不能在 Cisco 交换机和非 Cisco 交换机之间使用 而 802.1Q 技术在原有帧的源 MAC 地 址字段后插入标记字段, 同时用新的 FCS 字段替代了原有的 FCS 字段, 该技术是国际标准, 得到所有厂家的支持 Cisco 交换机之间的链路是否形成 Trunk 是可以自动协商的, 这个协议称为 DTP(Dynamic Trunk Protocol),DTP 还可 以协商 Trunk 链路的封装类型 表 13-1 链路两端是否会形成 Trunk 的总结 表 13-1 DTP 总结 negotiate desirable auto nonegotiate negotiate desirable auto nonegotiate VTP VTP(VLAN Trunk Protocol) 提供了一种用于在交换机上管理 VLAN 的方法, 该协议使得我们可以在一个或者几个中央点 (Server) 上创建 修改和删除 VLAN,VLAN 信息通过 Trunk 链路自动扩散到其他交换机, 任何参与 VTP 的交换都可以接受这些修改, 所有交换机保持相同的 VLAN 信息 VTP 被组织成管理域 (VTP Domain), 相同域中的交换机能共享 VLAN 信息 根据交换机在 VTP 域中的作用不同, VTP 可以分为以下 3 种模式 1 服务器模式 (Server): 在 VTP 服务器上能创建 修改和删除 VLAN, 同时这些信息会通告给域中的其他的交换机 在默认情况下, 交换机是服务器模式 每个 VTP 域必须至少有一台服务器, 域中的 VTP 服务器可以有多台 2 客户机模式 (Llient):VTP 客户机上不允许创建 修改和删除 VLAN, 但它会监听来自其他交换机的 VTP 通告并更改自己的 VLAN 信息 接收到的 VTP 信息也会在 Trunk 链路上向其他交换机转发, 因此这种交换机还能充当 VTP 中继

194 3 透明模式 (Transparent): 这种模式的交换机不参与 VTP 可以在这种模式的交换机创建 修改和删除 VLAN, 但是这些 VLAN 信息并不会通告给其他交换机, 它也不接受其他交换机的 VTP 通告而更新自己的 VLAN 信息 然而需要注意的是, 它会通过 Trunk 链路转发接收到的 VTP 通告, 从而充当了 VTP 中继的角色, 因此完全可以把该交换机看成是透明的 VTP 通告是以组播帧的方式发送的,VTP 通告中有一个字段称为修订号 (Revision), 初始值为 0. 只要在 VTP Server 上创建 修改和删除 VLAN, 通告的 Revision 就增加 1, 通告中还包含了 VLAN 的变化信息 需要注意的是 : 高 Revision 的通告会覆盖低 Revision 的通告, 而不管发送者是 Server 还是 Client 交换机只打官腔比本地在哪保存的 Resivison 号更高的通告 ; 如果交换机收到比自己的 Resivison 号更低的通告, 会用自己的 VLAN 信息反向覆盖 EtherChannel EtherChannel( 以太通道 ) 是由 Cisco 公司开发的, 应用于交换机之间的多链路捆绑技术 它的基本原理是 : 将两个 设备间多条快速以太或千兆以太物理链路捆绑在一起组成一条逻辑链路, 从而达到带宽倍增的目的 除了增加带宽外, EtherChannel 还可以在多条链路上均衡分配流量, 起到负载分担的作用 当一条或多条链路出现故障时, 只要还有链 路正常, 流量将转移到其他的链路上, 整个过程在几毫秒内完成, 从而直到冗余的作用 在 EtherCnahnel 中, 负载在 各个链路上的分布可以根据源 IP 地址 IP 地址 源 MAC 地址 目的 MAC 地址 源 IP 地址和 IP 地址组合, 以及源 MAC 地址和目的 MAC 地址组合等来进行分布 两台交换机之间是否形成 EtherChannel 也可以用协议自动协商 目前有两个协商协议 : PAGP 和 LACP, 前者是 Cisco 专有的协议, 而 LACP 是公共的标准 表 13-2 是 PAGP 协商的规律总结, 表 13-3 是 LACP 协商的规律总结 表 13-2 PAGP 协商的规律总结 ON Desirable auto ON Desirable auto 表 13-3 LACP 协商的规律总结 ON active passive ON active passive 13.2 实验 1: 划分 VLAN 1. 实验目的通过本实验, 读者可以掌握如下技能 :

195 1 熟悉 VLAN 的创建 ; 2 把交换机接口划分到特定 VLAN 2. 实验拓扑实验拓扑图如图 13-2 所示 图 13-2 实验 1 拓扑图 3. 实验步骤本配置 VLAN, 首先要创建 VLAN, 然后才把交换机的端口划分到特定的端口上 1 步骤 1: 在划分 VLAN 前, 配置路由器 R1 和 R2 的 g0/0 接口, 从 R1 ping 进行测试 默认时, 交换机的全部接口都在 VLAN 1 上,R1 和 R2 应该能够通信 2 步骤 2: 在 S1 上创建 VLAN S1#vlan database // 进入到 VLAN 配置模式 S1(vlan)#vlan 2 name VLAN2 VLAN 2 added; Name; VLAN2 // 以上创建 VLAN,2 就是 VLAN 的编号,VLAN 号的范围为 1~1 001,VLAN2 是该 VLAN 的名字 S1(vlan)#vlan 3 name VLAN3 VLAN 3 added; Name; VLAN3 S1(vlan)#exit APPLY completed. Exiting... // 退出 VLAN 模式, 创建的 VLAN 立即生效 提示 交换机中的 VLAN 信息存放在单独的文件中 flash;vlan.dat, 因此如果要完全清除交换机的配置, 除了使用 erase starting-config 命令外, 还可使用 delete flash;vlan.dat 命令把 VLAN 数据删除

196 提示 新的 IOS 版本中, 可以在全局配置模式中创建 VLAN, 如下所述 S1(config)#vlan 2 S1(config-vlan)#name VLAN 2 S!(config-vlan)#exit S1(config)#vlan 3 S1(config-vlan)#name VLAN 3 3 步骤 3: 把端口划分在 VLAN 中 S1(config)#interface f0/1 S1(config-if)#switch mode access // 以上把交换机端口的模式改为 access 模式, 说明该端口是用于连接计算机的, 而不是用于 Trunk S1(config-if)#switch access vlan 2 // 然后把该端口 f0/1 划分到 VLAN2 中 S1(config)#interface f0/2 S1(config-if)#switch mode access S1(config-if)#switch access vlan 3 提示 默认时, 所有交换机接口都在 VLAN 1 上,VLAN 1 是不能删除的 如果有多个接口需要划分到同一 VLAN 下, 也可以采用如下节约时间, 注意 - 前的空格 S1(config)#interface range f0/2-3 S1(config-if-range)#switch mode access S1(config-if-range)#switch access vlan 2 提示 如果要删除 VLAN, 使用 no vlan 2 命令即可 删除某一 VLAN 后, 要记得把该 VLAN 上的端口重新划分到别的 VLAN 上, 否则将导致端口的 消失 4. 实验调试 (1) 查看 VLAN 使用 show vlan 或者 show vlan brief 命令查看 VLAN 信息, 以及每个 VLAN 上有什么端口 要注意这里只能看到的是本交换机上哪个端口在 VLAN 上, 而不能看到其他交换机的端口在什么 VLAN 上 如下 : SwA#show vlan VLAN Name Status Ports

197 1 default active Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5,Fa0/6, Fa0/7, Fa0/8 Fa0/9, Fa0/10, Fa0/11, Fa0/12, Fa0/13, Fa0/14, Fa0/15, Fa0/16 Fa0/17, Fa0/18, Fa0/19, Fa0/20 Fa0/21, Fa0/22, Fa0/24,Gi0/1,Gi0/2 2 VLAN2 active 3 VLAN3 active 1002 fddi-default act/unsup 1003 token-ring-default act/unsup 1004 fddinet-default act/unsup ( 此处省略 ) // 在交换机,VLAN1 是默认 VLAN, 不能删除, 也不能改名 此外, 还有 1002 和 1003 等 VLAN 存在 (2)VLAN 间的通信 由于 f0/1 和 f0/2 属于不同 VLAN, 从 R1 ping 应该不能成功了 13.3 实验 2:Trunk 配置 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 配置交换机接口的 Trunk; 2 理解 DTP 的协商规律 2. 实验拓扑实验拓扑图如图 13-3 所示 图 13-3 实验 2 拓扑图

198 3. 实验步骤在实验 1 的基础上继续本实验 1 根据实验 1 的步骤在 S2 上创建 VLAN, 并把接口划分在图 13-3 所示的 VLAN 中 2 配置 Trunk: S1(config)#int f0/13 S1(config-if)#switchport trunk encanpsulation dot1q // 以上是配置 Trunk 链路的封装类型, 同一链路的两端封装要相同 有的交换机, 例如 2950 只能封装 dot1q, 因此无须执行该命令 S1(config-if)#switch mode trunk // 以上是把接口配置为 Trunk S2(config)#int f0/13 S2(config-if)#switchport trunk encanpsulation dot1q S2(config-if)#switch mode trunk 3 检查 Trunk 链路的状态, 测试跨交换机 同一 VLAN 主机间的通信 使用 show interface f0/13 trunk 可以查看交换机端口的 trunk 状态, 如下 : Port Mode Encapsulation Status Native vlan Fa0/13 on 802.1q trunking 1 //f0/13 接口已经为 Trunk 链路了, 封装为 802.1q Port Vlans allowed on trunk Fa0/ Port Vlans allowed and active in management domain Fa0/ Port Vlans in spanning tree forwarding state and not pruned Fa0/ 需要在链路的两端都确认 Trunk 的形成 测试 R1 和 R3 以及 R2 和 R4 之间的通信 由于 R1 和 R3 在同一 VLAN 上, 所以 R1 应该能 ping 通 R3 R2 和 R4 之间也应该能相互 ping 通 4 配置 Native VLAN: S1(config)#int f0/13 S1(config-if)#switchport trunk native vlan 2 // 以上是在 Trunk 链路上配置 Native VLAN, 我们把它改为 VLAN 2 了, 默认是 VLAN 1 S2(config)#int f0/13 S2(config-if)#switchport trunk native vlan 2 S1#show interface f0/13 trunk

199 Port Mode Encapsulation Status Native vlan Fa0/13 on 802.1q trunking 2 技术要点 之前介绍说在 Trunk 链路上, 数据帧会根据 ISL 或者 802.1Q 被重新封装, 然而如果是 Native VLAN 的数据, 是不会被重新封装而就在 Trunk 链路上传输 很显然链路两端 Native VLAN 是要一样的 如果不一样, 交换机会提示出错 5DTP 配置 技术要点 和 DTP 配置有关的命令如下所述, 这些命令不能任意组合 switchport trunk encapsulation{negotiate isl dot1q} : 配置 Trunk 链路上的封装类型, 可以是双方协商确定, 也可以是指定的 isl 或者 dot1q switchport nonegotiate :Trunk 链路上不发送协商包, 默认是发送的 switch mode {trunk dynamic desirable dynamic auto} : Turnk 该设置将端口置为永久 trunk 模式, 封装类型由 switchport trunk encapsulation 命令决定 ; Dynamic desirable 端口主动变为 trunk, 如果另一端为 negotiate,dynamic desirable 和 dynamic auto, 将成功协商 ; Dynamic auto 被动协商, 如果另一端为 negotiate 和 dynamic desirable, 将成功协商 如果想把接口配置为 negotiate, 使用 : S1(config-if)#switchport trunk encapsulation {isl dot1q} S1(config-if)#switchport mode trunk S1(config-if)#no switchport negotiate 如果想把接口配置为 nonegotiate, 使用 : S1(config-if)#switchport trunk encapsulation {isl dot1q} S1(config-if)#switchport mode trunk S1(config-if)#no switchport nonegotiate 如果想把接口配置为 desirable, 使用 : S1(config-if)#switchport mode dynamic desirable S1(config-if)#switch trunk encapsulation{negotiate isl dot1q} 如果想把接口配置为 auto, 使用 : S1(config-if)#switchport mode dynamic auto S1(config-if)#switch trunk encapsulation{negotiate isl dot1q}

200 在这里, 进行如下配置 : S1(config-if)#switchport mode dynamic desirable S1(config-if)#switch trunk encapsulation negotiate S2(config-if)#switchport mode dynamic auto S2(config-if)#switch trunk encapsulation negotiate S1#show interfaces f0/13 trunk Port Mode Encapsulation Status Native vlan Fa0/13 desirable n-isl trunking 1 // 可以看到 Trunk 已经形成, 封装为 n-isl, 这里的 n 表示封装类型也是自动协商的 需要在两端都进行检查, 确 认两端都形成 Trunk 才行 Port Vlans allowed on trunk Fa0/ Port Vlans allowed and active in management domain Fa0/ Port Vlans in spanning tree forwarding state and not pruned Fa0/ 提示 由于交换机有默认配置, 进行以上配置后, 使用 show running 可能看不到我们配置的命令 默认时,catalyst2950 和 3550 的配置是 desirable 模式 ; 而 catalyst 3560 是 auto 模式, 所以, 两台 3560 交换机之间不会自动形成 Trunk, 3560 交换机和 2950 交换机之间却可以形成 Trunk 13.4 实验 3:VTP 配置 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 VTP 的 3 种模式 ; 2 熟悉 VTP 的配置 2. 实验拓扑实验拓扑图如图 13-4 所示

201 13-4 实验 3 拓扑图 3. 实验步骤 (1) 把 3 台交换机配置清除干净, 重启交换机 S1#delete flash;vlan.dat S1#erase startup-config S1#reload //S2 和 S3 采用相同步骤 (2) 检查检查 S1 和 S3 之间 S3 和 S2 之间链路 Trunk 是否自动形成, 如果没有形成, 请参照实验 2 步骤配置 Trunk (3) 配置 S1 为 VTP server S1(config)#vtp mode server Device mode already VTP SERVER. // 以上配置 S1 为 VTP server, 实际上这时默认值 S1(config)#vtp domain VTP-TEST Changing VTP domain name from NULL to VTP-TEST // 以上配置 VTP 域名 S1(config)#vtp password cisco Setting device VLAN database password to cicso // 以上配置 VTP 的密码, 目的是为了安全, 防止不明身份的交换机加入到域中 (4) 配置 S3 为 VTP transparent S3#vlan database S3(vlan)#vtp transparent Setting device VTP TRANSPARENT mode. S3(vlan)#vtp domain VTP-TEST Domain name already set to VTP-TSET S3(config)#vtp password cisco Setting device VLAN database password to cicso 提示 有的 IOS 版本只支持在 VLAN Database 下配置 VLAN

202 (5) 配置 S2 为 VTP client S2(vlan)#vtp mode client Setting device VTP CLIENT mode. S2(vlan)#vtp domain VTP-TEST Domain name already set to VTP-TSET S2(config)#vtp password cisco Setting device VLAN database password to cicso 4. 实验调试 (1) 在 S1 上创建 VLAN, 检查 S2 和 S3 上的 VLAN 信息 S1(config)#vlan 2 S1(config)#vlan 3 S2#show vlan VLAN Name Status Ports default active Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5,Fa0/6, Fa0/7, Fa0/8 2 VLAN2 active 3 VLAN3 active 1002 fddi-default act/unsup // 可以看到 S2 已经学习到了在 S1 上创建 VLAN 了 S3#show vlan VLAN Name Status Ports default active Fa0/1, Fa0/2, Fa0/3, Fa0/4, Fa0/5,Fa0/6, Fa0/7, Fa0/8, Fa0/9, Fa0/10, Fa0/11, Fa0/12 2 VLAN2 active 3 VLAN3 active 1002 fddi-default active 1003 token-ring-default active 1004 fddinet-default active 1005 trnet-default active // 可以看到 S2 上有了 VLAN2 和 VLAN3, 而 S3 上并没有, 因为 S3 是透明模式 (2) 查看 VTP 信息 S1#show vtp status VTP Version ; 2 // 该 VTP 支持版本 2 Configuration Revision ; 2 // 修订号为 2, 该数值非常重要 Maximum VLANs supported locally ; 1005 Number of existing VLANs ; 7 //VLAN 数量 VTP Operating Mode ; Server //VTP 模式 VTP Domain Name ; VTP-TEST //VTP 域名

203 VTP Pruning Mode ; Disabled //VTP 修剪没有启用 VTP V2 Mode ; Disabled //VTP 版本 2 没有启用, 现在是版本 1 VTP Traps Generation ; Disabled MD5 digest ; 0xD4 0x30 0xE7 0xB7 0xDC 0xDF 0x1B 0xD8 Configuration last modified by at ;22;16 Local updater ID is (no valid interface found) (3) 观察 VTP 的 revision 数值 在 S1 上, 修改 创建或删除 VLAN, 在 S2 和 S3 上使用 Show vtp status 命令观察 revision 数值是否增加 1 (4) 配置修剪 版本 2 S1(config)#vtp pruning S1(config)#vtp version 2 S1#show vtp status VTP Version ; 2 Configuration Revision ; 2 Maximum VLANs supported locally ; 1005 Number of existing VLANs ; 7 VTP Operating Mode ; Server VTP Domain Name ; VTP-TEST VTP Pruning Mode ; Enabled //VTP 修剪启用了 VTP V2 Mode ; Enabled //VTP 版本为 2 了 VTP Traps Generation ; Disabled MD5 digest ; 0xA6 0x56 0x25 0xDE 0xE2 0x39 0x6A 0x10 Configuration last modified by at ;32;28 Local updater ID is (no valid interface found) 提示 VTP 修剪和 VTP 版本只需要在一个 VTP server 上进行即可, 其他 server 或者 client 会自动跟着更改 VTP 修剪是为 了防止不必要必要的流量从 Trunk 链路上通过, 通常需要启用 13.5 实验 4:EtherChannel 配置 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1EtherChannel 的工作原理 ; 2EtherChannel 的配置 2. 实验拓扑实验拓扑图如图 13-5 所示

204 图 13-5 实验 4 拓扑图 3. 实验步骤构成 EnterChannel 的端口必须具有相同的特性, 如双工模式 速度和 Trunking 的状态等 配置 EtherChannel 有手支配置和自动配置 (PAGP 或者 LAGP) 两种方法, 自动配置就是让 EtherChannel 协商协议自动协商 EtherChannel 的建立 (1) 手动配置 EtherChannel S1(config)#interface port-channel 1 // 以上是创建以太通道, 要指定一个唯一的通道组号, 组号的范围是 1~6 的正整数 要取消 EtherChannel 时用 no interface port-channel 1 命令 S1(config)#interface f0/13 S1(config-if)#channel-group 1 mode on S1(config)#interface f0/14 S1(config-if)#channel-group 1 mode on // 以上将物理接口指定到已创建的通道中 S1(config)#int port-channel 1 S1(config-if)#switchport 1 mode trunk S1(config-if)#speed 100 S1(config-if)#duplex full // 以上配置通道中的物理接口的速率及双工等属性 S2(config)#interface port-channel 1 S2(config)#interface f0/13 S2(config-if)#channel-group 1 mode on S2(config)#interface f0/14 S2(config-if)#channel-group 1 mode on S2(config)#int port-channel 1 S2(config-if)#switchport 1 mode trunk S2(config-if)#speed 100 S2(config-if)#duplex full S1(config)#port-channel load-balance dst-msc S2(config)#port-channel load-balance dst-msc // 以上是配置 EtherChannel 的负载平衡方式, 命令格式为 port-channel load-balance method, 负载平衡的方式有 :dst-ip dst-mac src-dst-ip src-dst-mac 等

205 (2) 查看 EtherChannel 信息 S1#show etherchannel summary Flags; D - down P - in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use f - failed to allocate aggregator u - unsuitable for bundling w waiting to be aggregated d - default port Number of channel-groups in use; 1 Number of aggregators; 1 Group Port-channel Protocol Ports Po1(SU) - Fa0/13(Pd) Fa0/14(P) // 可以看到 EtherChannel 已经形成, SU 表示 EtherChannel 正常, 如果显示为 SD, 表示把 EthernetChannel 接口关掉重新开启 (4) 配置 PAGP 或者 LAGP 技术要点 要想把接口配置为 PAGP 的 desirable 模式使用命令 : channel-group 1 mode desirable ; 要想把接口配置为 PAGP 的 auto 模式使用命令 : channel-group 1 mode auto ; 要想把接口配置为 LACP 的 active 模式使用命令 : channel-group 1 mode active ; 要想把接口配置为 LACP 的 passive 模式使用命令 : channel-group 1 mode passive 在这里进行如下配置 : S1(config)#interface range f0/13 14 S1(config-if)#channel-group 1 mode desirable S2(config)#interface range f0/13 14 S2(config-if)#channel-group 1 mode desirable S1#show etherchannel summary Flags; D - down P - in port-channel I - stand-alone s - suspended H - Hot-standby (LACP only) R - Layer3 S - Layer2 U - in use f - failed to allocate aggregator

206 u - unsuitable for bundling w waiting to be aggregated d - default port Number of channel-groups in use; 1 Number of aggregators; 1 Group Port-channel Protocol Ports Po1(SU) - Fa0/13(Pd) Fa0/14(P) // 可以看到 EtherChannel 协商成功 注意 : 应在链路的两端都进行检查, 确认两端都形成以太通道才行 13.6 VLAN Trunk 和 VTP 命令汇总 表 13-4 是本章出现的命令 表 13-4 本章命令汇总 命令 作用 vlan database 进入到 VLAN Database 配置模式 vlan 2 name VLAN 2 创建 VLAN 2 switch access vlan 2 把端口划分到 VLAN 2 中 interface range f0/2-3 批量配置接口的属性 show vlan 查看 VLAN 的信息 switchport trunk encanpsulation 配置 Trunk 链路的封装类型 switch mode trunk 把接口配置为 Trunk show interface f0/13 trunk 查看交换机端口的 Trunk 状态 switchport nonegotiate Trunk 链路上不发送 Trunk 协商包 vtp mode server 配置交换机为 VTP server vtp domain VTP-TEST 配置 VTP 域名 vtp password cisco 配置 VTP 的密码 vtp mode client 配置交换机为 VTP client vtp transparent 配置交换机为 VTP transparent show vtp status 显示 VTP 的状态 vtp pruning 启用 VTP 修剪 vtp version 2 VTP 版本为 2 interface port-channel 1 创建以太通道 channel-group 1 mode on 把接口加入到以太通道中, 并指明以太通道模式 port-channel load-balance dst-mac 配置 EtherChannel 的负载平衡方式 show etherchannel summary 查看 EtherChannel 的简单信息

207 第 14 章 STP 为了减少网络的的故障时间, 我们经常会采用冗余拓扑 STP 可以让具有冗余结构的网络在故障时自动调整网络的数据转发路径 STP 重新收敛时间较长, 通常需要要 30~50s, 为了减少这个时间, 引入了一些补充技术, 例如 Uplinkfast 和 Backbonefast 等 RSTP 则在协议上对 STP 进行了根本的改进成新的协议, 从而减少收敛时间 STP 还有许多改进, 例如 PVST MST 协议, 以及安全措施, 本章将介绍这些常用的配置 14.1 STP 简介 基本 STP 为了增加局域网的冗余性, 我们常常会在网络中引入冗余链路, 然而这样却会引起交换环路 交换环路会带来 3 个问题 : 广播风暴 同一帧的多个拷贝以及交换机 CAM 表不稳定 STP(STP,Spanning Tree Protocol) 可以解决这些问题, STP 基本思路是阻断一些交换机接口, 构建一棵没有环路的转发树 STP 利用 BPDU(Bridge Protocol Data Unit) 和其他交换机进行通信, 从而确定哪个交换机该阻断哪个接口 在 BPDU 中有几个关键的字段, 例如 : 根桥 ID 路径代价和端口 ID 等 为了在网络中形成一个没有环路的拓扑, 网络中的交换机要进行以下 3 个步骤 :1 选举根桥,2 选取根口,3 选取指定口 在这些步骤中, 哪个交换机能获胜将取决于以下因素 ( 按顺序进行 ): 1 最低的根桥 ID; 2 最低的根路径代价 ; 3 最低发送都桥 ID; 4 最低发送者端口 ID 第个交换机都具有一个唯一的桥 ID, 这个 ID 由两部分组成 : 网桥优先级 +MAC 地址 网桥优先级是一个 2 字节的数, 交换机的默认优先级为 ;MAC 地址就是交换机的 MAC 地址 具有最低桥 ID 的交换机就是根桥 根桥上的接口都是指定口, 会转发数据包 选举了根桥后, 其他的交换就成为了非根桥 每台非根桥要选举一条到根桥的根路径 STP 使用路径 Cost 来决定到达根桥的最佳路径 (Cost 是累加的, 带宽大的链路 Cost 低 ), 最低 Cost 值的路径就是根路径, 该接口就是根口 ; 如果 Cost 一样, 就根据选举顺序选举根口 根口转发数据包 交换机的其他接口还要指定口是阻断口, 交换机之间将进一步根据上面的四个因素来竞争 指定口是转发数据帧的, 剩下的其他的接口将被阻断, 不转发数据包 这样网

208 络就构建出一棵没有环路的转发树 当网络的拓扑发生变化时, 网络会从一个状态向另一个状态过渡, 重新打开或阻断某些接口 交换机的端口要经过几种状态 : 禁用 (Disable) 阻塞 (Blocking) 监听状态 (Listenning) 和学习状态 (Learning), 最后是转发状态 (Forwarding) PVST 当网络上有多个 VLAN 时,PVST(Per Vlan STP) 会为第个 VLAN 构建一棵 STP 树 这样的好处是可以独立地为每个 VLAN 控制哪些接口要转数据, 从而实现负载平衡 缺点是如果 VLAN 数量很多, 会给交换机带来沉重的负担 Cisco 交换机默认的模式就是 PVST Portfast Uplinkfast Backbonefast STP 的收敛时间通常需要 30~50 s 为了减少收敛时间, 有一些改善措施 Portfast 特性使得以太网接口一旦有设备接入, 就立即进入转发状态, 如果接口上连接的只是计算机或者其他不运行 STP 的设备, 这是非常合适的 Uplinkfast 则经常用在接入层交换机上, 当它连接到主干交换机上的主链路上故障时, 能立即切换到备份链路上, 而不需要经过 30 s 或者 50 s Uplivkfast 只需要在接入层交换机上配置即可 Backbonefast 则主要用在主干交换机之间, 当主干交换机之间的链路上有故障时, 可以比原有的 50 s 少 20 s 就切换到备份链路上 Backbonefast 需要在全部交换机上配置 RSTP RSTP 实际上就是把 STP 收敛时间的些措施整合在 STP 协议中形成新的协议 在 RSTP 中, 接口的角色有 : 根接口 指定接口 备份接口 (Backup Interface) 和替代接口 (Alternate Interface) 接口的状态有 : 丢弃 (Discarding) 学习状态 (Learning) 和转发状态 (Forwarding), 接口还分为边界接口 (Edge Port) 点到点接口 (Poing-to-Point Port) 和共享接口 (Share Port) MST 在 PVST 中, 交换机为每个 VLAN 都构建一棵 STP 树, 不仅带来 CPU 的很大负载, 也会占用大量的带宽 MST 则是把多个 VLAN 映射到一个 STP 实例上, 从而减少了 STP 实例 MST 可以同 STP 和 PVST 兼容 对于运行 STP 和 PVST 的交换机, 一个 MST 域看起来就像一台交换机 STP 防护 STP 协议并没有什么措施对交换机的身份进行谁 在稳定的网络中, 如果接入非法的交换机, 将可以给网络中的 STP 树带来灾难性的破坏 有一些简单的措施来保护网络, 虽然

209 这些措施显示软弱无力 Root Guard 特性将使得交换机的接口拒绝接收比原有根桥优先级更高的 BPDU 而 BPDUGuard 主要是和 Portfast 特性配合使用,Portfast 使得接口一有计算机接入就立即进入转发状态, 然而, 万一这个接口接入的是交换机, 很可能造成环路 BPDU Guard 可以使得 Portfast 接口一旦接收到 BPDU, 就关闭该接口 14.2 实验 1:STP 和 PVST 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 STP 的工作原理 ; 2 掌握 STP 树的控制 ; 3 利用 PVST 进行负载平衡 2. 实验拓扑图如图 14-1 所示 图 14-1 实验 1 实验 2 实验 4 拓扑图在图 14-1 中,S1 和 S2 模拟核心层的交换机, 而 S3 为接入的交换机 S1 和 S2 实际上是 3 层交换机, 我们这里并不利用其 3 层功能, 所以它们也采用 2 层交换机的图标 3. 实验步骤我们要在网络中配置 2 个 VLAN, 不同 VLAN 的 STP 具有不同的根桥, 实现负载平衡 (1) 步骤 1: 利用 VTP 在交换机上创建 VLAN2, 在 S1 和 S2 之间的链路配置 Trunk S1(config)#vtp domain VTP-TEST Changing VTP domain name from to VTP-TEST S1(config)#vlan 2 // 在 S1 上配置 VTP 的域名, 并创建 VLAN 2. 由于默认时 S2 和 S3 的 VTP 域名为空, 它们将自动学习到 S1 的 VTP 域名, 同时 S2 S3 也将自动学习到 VLAN 2, 请确认是否成功 S1(config)#int f0/14 S1(config-if)shutdown // 关闭该接口, 以免影响实验

210 S1(config)#int f0/13 S1(config)#switchport trunk encapsulation dot1q S1(config)#switchport mode trunk //S1 的 f0/13 改为 negotiate 后, 由于默认时 S2 的 f0/13 为 auto 模式,S1 和 S2 将自动协商成功 Trunk, 而默认时 S3 的以太网接口就是 desirable 模式, 所以 S3 与 S1 和 S2 的链路也自动协商成功 Trunk, 请确认 3 条链路的 Trunk 是 否成功 (2) 步骤 2: 检查初始的 STP 树 S1#show spanning-tree VLAN0001 Spanning tree enabled protocol ieee // 以上表明运行的 STP 协议是 IEEE 的 802.1D Root ID Priority Address 0009.b7a4.b181 Cost 19 Port 17(FastEthernet0/15) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec // 以上显示 VLAN 1 的 STP 树的根桥信息, 通过根桥的 MAC 地址可以确定 S3 是根桥 这是因为 S3 是较早的交换机, 具 有较低的 MAC 地址 由于 S3 是一台低端的交换机, 成为根桥显然是不合理的 Bridge ID Priority 32769(priority sys-id-ext 1) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 // 以上显示该交换机的桥 ID Interface Role Sts Cost Prio.Nbr Type Fa0/13 Altn BLK P2P Fa0/15 Root FWD P2P // 以上显示该交换机各个接口的状态,f0/13 为阻断状态,f0/15 为根口 VLAN0002 Spanning tree enabled protocol ieee Root ID Priority Address 0009.b7a4.b182 Cost 19 Port 17(FastEthernet0/15) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority 32770(priority sys-id-ext 2) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300

211 Interface Role Sts Cost Prio.Nbr Type Fa0/13 Altn BLK P2P Fa0/15 Root FWD P2P // 以上是 VLAN2 的 STP 树情况,VLAN2 的 STP 树和 VLAN1 的类似 默认时,Cisco 交换机会为每个 VLAN 都生成一个单 独的 STP 树, 称为 PVST(Per VLAN Spanning Tree) 技术要点 需要仔细分析为什么 STP 会是目前这种情况 3 个交换机的默认优先级都是 , 而 S3 的 MAC 较低, 所以成为了根 桥, 则 S3 上的 f0/1 和 f0/2 是指定口, 处于 Forward 状态 S1 有两个接口可以到达 S3, 一个接口是 f0/13, 到达 S3 的 Cost 为 19+19=38, 另一个接口是 f0/15, 到达 S1 的 Cost 为 19, 因此 f0/15 是根口, 处于 Forward 状态 同样, 在 S2 上,f0/15 也是根口, 处于 Forward 状态 在 S1 和 S2 之间的链路上, 要选举出一个指定口 根据选举的要素, 根桥的 ID 是一样的, 不能决出胜负 ; 到达根桥的 Cost 值也是一样的, 都为 19, 不能决出胜负 ; 但是发送者桥 ID 不一 样,S1 的 MAC 地址高,S2 的 MAC 地址低,S2 获胜, 所以 S2 的 f0/13 是指定口, 处于 Forward 状态,S1 的 f0/13 就处 于 Block 状态 (3) 步骤 3: 控制 S1 为 VLAN 1 的根桥,S2 为 VLAN 2 的根桥 S1(config)#spanning-tree vlan 1 priority 4096 S2(config)#spanning-tree vlan 2 priority 4096 // 对于 VLAN1 来说,S1 的优先级为 4 096, 而 S2 和 S3 保持默认值 , 这样 S1 就成为了 VLAN1 的根桥 同样我们 控制 S2 成为了 VLAN 2 的根桥 优先级通常要 的倍数 S1#show spanning-tree VLAN0001 Spanning tree enabled protocol ieee Root ID Priority 4096 Address 0018.ba11.f500 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec //S1 成为了 VLAN 1 的根桥了 Bridge ID Priority 4097(priority 4096 sys-id-ext 1) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 15 Interface Role Sts Cost Prio.Nbr Type Fa0/13 Desg FWD P2P Fa0/15 Desg FWD P2P

212 对于 VLAN 1 来说,f0/13 和 f0/15 是指定口, 都处于转发状态了 VLAN0002 Spanning tree enabled protocol ieee Root ID Priority 4096 Address 0018.ba11.eb80 Cost 19 Port 15(FastEthernet0/13) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec //S2 成为了 VLAN 2 的根桥了 Bridge ID Priority 4097(priority 4096 sys-id-ext 1) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 15 Interface Role Sts Cost Prio.Nbr Type Fa0/13 Root FWD P2P Fa0/15 Altn BLK P2P 对于 VLAN 2 来说,f0/13 是根口, 处于转发状态, 而 f0/15 却是阻断状态 S3#show spanning-tree brief VLAN1 Spanning tree enabled protocol ieee Root ID Priority 4097 Address 0018.ba11.f500 Cost 19 Port 1(FastEthernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority Address 0009.b7a4.b181 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 Interface Designated Name Port ID Prio Cost Sts Cost Bridge ID Port ID FastEthernet0/ FWD ba11.f FastEthernet0/ FWD b7a4.b //S3 上, 对于 VLAN1, S3 的 f0/1 和 f0/2 都处于转发状态

213 VLAN2 Spanning tree enabled protocol ieee Root ID Priority 4098 Address 0018.ba11.eb80 Cost 19 Port 2(FastEthernet0/2) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority Address 0009.b7a4.b182 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 Interface Designated Name Port ID Prio Cost Sts Cost Bridge ID Port ID FastEthernet0/ FWD b7a4.b FastEthernet0/ FWD ba11.eb (4) 步骤 4: 控制指定口在步骤 3 中可以看到, 对于 VLAN 1,S1 成为了根桥,S1 的 f0/13 和 f0/15 处于转发状态 ;S2 的 f0/13 是根口, 也处于转发状态 ;S3 的 f0/1 是根口, 也处于转发状态 ; 然而在 S2 和 S3 之间的链路上, 却是低端交换机 S3 的 f0/2 在转发数据, 原因在于 S2 和 S3 在竞争指定口时, 由于 S3 的 MAC 较低而获胜, 这是不合理的 VLAN 2 的情况类似 要控制指定口, 这可以通过改变优先级实现如下 : S2(config)#spanning-tree vlan 1 priority 8192 S1(config)#spanning-tree vlan 2 priority 8192 // 对于 VLAN1 来说,S2 的优先级为 8 192, 比 S1 的 低, 不至于成为根桥, 但是比 S3 的 低, 所以在竞争指定时会获胜 VLAN 2 情况类似 S3#show spanning-tree brief VLAN1 ( 此处省略 ) Interface Designated Name Port ID Prio Cost Sts Cost Bridge ID Port ID FastEthernet0/ FWD ba11.f FastEthernet0/ BLK ba11.eb //S3 上, 对于 VLAN 1,S3 的 f0/1 处于转发状态, 而 f0/2 处于阻断状态

214 VLAN2 ( 此处省略 ) Interface Designated Name Port ID Prio Cost Sts Cost Bridge ID Port ID FastEthernet0/ BLK ba11.f FastEthernet0/ FWD ba11.eb //S3 上, 对于 VLAN 2,S3 的 f0/1 处于阻断状态, 而 f0/2 处于转发状态, 这样起到了负载平衡的作用 14.3 实验 2:Portfast,Uplinkfast,Backbonefast 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 Portfast 的工作场合和配置 ; 2 理解 Uplinkfast 的工作场合和配置 ; 3 理解 Backbonefast 的工作场合和配置 2. 实验拓扑如图 14-1 所示 图 14-1 实验 1 实验 2 实验 4 拓扑图 3. 实验步骤在实验 1 的基础上继续本实验, 我们将只关心 VLAN 1 的 STP 树 (1) 步骤 1: 配置 Portfast 图 14-1 中,S1 的 f0/5 用于接入计算机 当计算机接入时,f0/5 接口进入 Listening 状态, 随后经过 Learning, 最后才成为 Forwarding, 这期间需要 30 s 的时间 这对于有些场合是不可忍受, 可以配置 Portfast 特性, 使得计算机一接入, 接口立即进入 Forwarding S1(config)#int f0/5 S1(config-if)#spanning-tree portfast %Warninng;portfast should only be enabled on ports connected to a single host.connecting hubs,conecntrators,switches,bridges,etc to this interface when portfast is enabled,can cause temporary bridging loops. Use with CAUTION %Portfast has been configured on FastEthernet0/5 but will only have effect when the interface is in a non-trunking mode // 交换机会警告该接口只能用于接入计算机或者路由器, 不要接入其他交换机

215 (2) 步骤 2: 配置 Uplinkfast 先确认实验 1 的 STP 树已经正确 在图 14-1 中的 S1 上, 关闭 f0/15 接口, 在 S3 上反复执行 show spanning-tree vlan brief, 观察 f0/2 接口的状态变化 : FastEthernet0/ LIS ba11.eb 大约 15s 后变为 : FastEthernet0/ LRN ba11.eb 大约 15s 后变为 : FastEthernet0/ FWD ba11.eb 合计大约 15+15=30 s,f0/2 变为转发状态 S3(config)#spanning-tree uplinkfast S1(config)#int f0/15 S1(config-if)#no shutdown S1(config-if)#shutdown // 等 STP 重新稳定后, 才执行该语句 在 S3 上重复执行 show spanning-tree vlan brief, 可以看到 f0/2 很快就进入了 Forwarding 状态 技术要点 没有配置 Uplink 时, 交换机 S3 如果能直接检测到 f0/1 接口上的链路故障,f0/2 会立即进入 Listen 状态, 这样 30 s 后就能进入 Forward 状态 然而如果 S1 和 S3 之间存在一个 Hub, 当 S1 上的 f0/15 接口有故障时,S3 将无法直接检测 到故障,S3 只能等待 10 个周期没有收到 S1 的 BPDU( 每个周期 2 s), 即 20 s 钟后,S3 的 f0/2 才进入 Listen 状态, 这样总共 50 s 才就能进入 Forward 状态 所以,STP 重新收敛的时间通常需要 30~50 s (3) 步骤 3: 配置 backbonefast 打开 S1 上 f0/15 接口, 确认 STP 树正确 在图 14-1 中的 S1 上, 关闭 f0/13 接口, 在 S3 上反复执行 show spanning-tree vlan brief, 观察 f0/2 接口的状态变化 : FastEthernet0/ BLK ba11.eb 大约 20s 后变为 : FastEthernet0/ LIS ba11.eb 大约 15s 后变为 : FastEthernet0/ LRN ba11.eb 大约 15s 后变为 : FastEthernet0/ FWD ba11.eb

216 合计大约 =50 s,f0/2 变为转发状态 S1(config)#spanning-tree backbonefast S2(config)#spanning-tree backbonefast S3(config)#spanning-tree backbonefast S1(config)#int f0/13 S1(config-if)#no shutdown S1(config-if)#shutdown // 等 STP 重新稳定后, 才执行该语句在 S3 上重复执行 show spanning-tree vlan brief, 可以看到 f0/2 很快就进入了 Listening 状态, 合计大约 15+15=30 s 后,f0/2 就变为转发状态, 比之前的 50 s 少了 20 s 提示 Uplinkfast 命令只需要在 S3 配置即可, 而 Backbonefast 命令需要在 S1 S2 和 S3 三台交换上配置 14.4 实验 3:RSTP 1. 实验目的通过本实验, 读者可以掌握 RSTP 的配置这项技能 2. 实验拓扑实验拓扑图如图 14-2 所示 图 14-2 实验 3 拓扑图 3. 实验步骤 (1) 步骤 1: 把两台交换机的配置清除干净, 重启交换机 S1#delete flash;vlan.dat S1#erase startup-config S1#reload S2#delete flash;vlan.dat S2#erase startup-config S2#reload (2) 步骤 2: 配置 S1 和 S2 之间的 Trunk S1(config)#int f0/13

217 S1(config-if)#switchport turnk encapsulation dot1q S1(config-if)#switchport mode trunk S1(config)#int f0/14 S1(config-if)#switchport turnk encapsulation dot1q S1(config-if)#switchport mode trunk (3) 步骤 3: 配置 S1 成为根桥 S1(config)#spanning-tree vlan 1 priority 4096 在 S1 和 S2 上用 show spanning-tree 命令检查 STP 情况,S2 的 f0/14 应该处于阻断状态 技术要点 S1 是根桥,S2 要选取到达 S1 的根路径, 有两条路径,Cost 都为 19, 这时由于 S2 在 f0/13 接口上收到的 BPDU 中, 发送者 (S1) 端口号为 13; 在 f0/14 接口上收到的 BPDU 中, 发送者端口号为 14 所以 f0/13 被选举为根口了,f0/14 则只能被阻断 (4) 步骤 4: 在 S2 上关闭 f0/13 接口, 观察 STP 树的重新生成在 S2 上关闭 f0/13 接口, 重新执行 show spanning-tree, 可以看到 f0/14 经过 30 s 后进入了 Forwarding 状态 (5) 步骤 5: 配置 RSTP S1(config)#spanning-tree mode rapid-pvst S2(config)#spanning-tree mode rapid-pvst (6) 步骤 6: 在 S2 上关闭 f0/13 接口, 观察 STP 树的重新生成在 S2 上重新打开 f0/13 接口, 确认 STP 稳定后, 在 S2 上关闭 f0/13 接口, 重新执行 show spanning-tree, 可以看到 f0/14 立即进入了 Forwarding 状态, 这说明 RSTP 的收敛比普通 STP 有了很大的改善 (7) 步骤 7: 配置链路类型 S1(config)#int range f0/13 14 S1(config-if-range)#duplex full S1(config-if-range)#spanning-tree link-type point-to-point S2(config)#int range f0/13 14 S2(config-if-range)#duplex full S2(config-if-range)#spanning-tree link-type point-to-point //S1 和 S2 之间的链路是 Trunk 链路, 自动协商为全双工,RSTP 会自动把它们的链路类型标识为点到点 我们这里强制配置了一遍 技术要点 在 RSTP 中接口分为边界接口 (Edge Port) 点到点 (Point-to-Point) 和共享

218 接口 (Share Port), 如果接口上配置了 Spanning Portfast, 接口就为边界接口 ; 如果接口是半双工, 接口就为共享接口 ; 接口是全双工, 接口就为点到点接口 在接口上明确指明接口类型有利 RSTP 的运行 14.5 实验 4:MST 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 MST 的工作原理 ; 2 掌握 MST 的配置 2. 实验拓扑实验拓扑图如图 14-1 所示 图 14-1 实验 1 实验 2 实验 4 拓扑图 3. 实验步骤我们在网中创建 4 个 VLAN,VLAN1 和 VLAN2 使用 MST 实例 1,VLAN3 和 VLAN4 使用 MST 实例 2 (1) 步骤 1:VTP 在交换机上创建 VLAN, 在 S1 和 S2 之间的链路配置 Trunk S1(config)#vtp domain VTP-TEST Changing VTP domain name from NULLto VTP-TEST S1(config)#vlan 2 S1(config)#vlan 3 S1(config)#vlan 4 S1(config)#int f0/14 S1(config-if)#shutdown // 关闭该接口, 以免影响我们的实验 S1(config)#int f0/13 S1(config-if)#switchport trunk encapsulation dot1q S1(config-if)#switchport mode trunk S2(config)#int f0/13 S2(config-if)#switchport trunk encapsulation dot1q S2(config-if)#switchport mode trunk (2) 步骤 2: 配置 MST 只有 S1 和 S2 才能支持 MST S1(config)#spanning-tree mode mst // 以上把生成树的模式改为 MST, 默认时是 PVST

219 S1(config)#spanning-tree mst configuration // 以上是进入 MST 的配置模式下 S1(config-mst)#name TEST-MST // 以上命名 MST 的名字 S1(config-mst)#revision 1 // 以上配置 MST 的 revision 号, 只有名字和 revision 号相同的交换机才是同一个 MST 区域 S1(config-mst)#interface 1 vlan 1-2 // 以上是把 VLAN 1 和 VLAN 2 的生成树映射到实例 1 S1(config-mst)#interface 3 vlan 3-4 // 以上是把 VLAN 3 和 VLAN 4 的生成树映射到实例 2, 这里一共有 3 个 MST 实例, 实例 0 是系统要使用的 S1(config-mst)#exit 要退出, 配置才能生效 S1(config)#spanning-tree mst 1 priority 8192 S1(config)#spanning-tree mst 2 priority // 以上配置 S1 为 MST 实例 1 的根桥 S2(config)#spanning-tree mode mst S2(config)#spanning-tree mst configuration S2(config-mst)#name TEST-MST S2(config-mst)#revision 1 S2(config-mst)#interface 1 vlan 1-2 S2(config-mst)#interface 3 vlan 3-4 S2(config-mst)#exit S2(config)#spanning-tree mst 1 priority S2(config)#spanning-tree mst 2 priority 8192 // 以上配置 S2 为 MST 实例 2 的根桥 (3) 步骤 3: 检查生成树 S1#show spanning-tree MST00 Spanning tree enabled protocol mstp Root ID Priority Address 0009.b7a4.b181 Cost Port 15(FastEthernet0/13) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec

220 Bridge ID Priority 32768(priority sys-id-ext 0) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Interface Role Sts Cost Prio.Nbr Type Fa0/13 Root BLK P2P Fa0/15 Altn FWD P2P Bound(PVST) // 以上的 MST00 是系统要使用的实例,BPDU 是通过它来发送的 MST01 Spanning tree enabled protocol mstp Root ID Priority 8193 Address 0018.ba11.f500 This bridge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority 8193(priority 8192 sys-id-ext 1) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Interface Role Sts Cost Prio.Nbr Type Fa0/13 Desg FWD P2P Fa0/15 Boun BLK P2P Bound(PVST) MST02 Spanning tree enabled protocol mstp Root ID Priority 8194 Address 0018.ba11.eb80 Cost Port 15(FastEthernet0/13) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority (priority sys-id-ext 2) Address 0018.ba11.f500 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Interface Role Sts Cost Prio.Nbr Type Fa0/13 Root FWD P2P Fa0/15 Boun BLK P2P Bound(PVST) // 以上显示的是 S1 上的 MST 实例情况 S3#show spanning-tree brief VLAN1 Spanning tree enabled protocol ieee Root ID Priority Address 0009.b7a4.b181

221 This bredge is the root Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Bridge ID Priority Address 0009.b7a4.b181 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 Interface Designated Name Port ID Prio Cost Sts Cost Bridge ID Port ID FastEthernet0/ FWD b7a4.b FastEthernet0/ FWD b7a4.b ( 此处省略 ) // 以上表明 S3 成为了所有 VLAN 的根桥,f0/1 和 f0/2 都处于转发状态, 这不是我样想要的 (4) 步骤 4: 控制 S1 成为根桥 S1(config)#spanning-tree mst 0 priority 4096 // 注意这里应该配置 MST 0 的优先级, 只有 MST 0 才发送 BPDU S3#show spanning-tree brief VLAN1 Spanning tree enabled protocol ieee Root ID Priority 4096 Address 0018.ba11.f500 Cost 19 Port 1(FastEthernet0/1) Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec // 以上表明 S1 是 VLAN 1 的根桥 Bridge ID Priority Address 0009.b7a4.b181 Hello Time 2 sec Max Age 20 sec Forward Delay 15 sec Aging Time 300 Interface Designated Name Port ID Prio Cost Sts Cost Bridge ID Port ID FastEthernet0/ FWD ba11.f FastEthernet0/ BLK b7a4.b ( 此处省略 ) // 对于 S3 上所有的 VLAN 来说,f0/2 都是阻断的, 无法取得负载平衡 (5) 步骤 5: 控制负载平衡 S3(cofng)#int f0/2 S3(config-if)spanning-tree vlan 3 cost 10

222 S3(config-if)spanning-tree vlan 4 cost 10 // 以上改变 VLAN 3 和 VLAN 4 在 f0/2 接口上的 Cost 值 这样对于 VLAN 3 和 VLAN 4,S3 的 f0/2 接口就处于转发状态 14.6 实验 5:STP 保护 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1ROOT GUARD 的使用 ; 2BPDU GUARD 的使用 2. 实验拓扑实验拓扑图如图 14-3 所示 图 14-3 实验 6 拓扑图 3. 实验步骤 (1) 步骤 1: 关闭不需要的接口, 配置 S1 和 S2 之间的 Trunk S1(config)#int f0/14 S1(config-if)#shutdown S1(config)#int f0/15 S1(config-if)#shutdown S1(config)#int f0/13 S1(config-if)#switchport turnk encapsulation dot1q S1(config-if)#switchport mode trunk (2) 步骤 2: 配置 S1 成为根桥 S1(config)spanning-tree vlan 1 priority 8192 (3) 步骤 3: 在 S2 的 f0/15 上配置 guard root S2(config)#int f0/15 S2(config-if)#spanning-tree guard root

223 (4) 步骤 4: 把 S3 改为根桥, 观察 S2 的动作 S3(config)spanning-tree vlan 1 priority 4096 R2#show spanning-tree inconsistentports Name Interface Inconsistency VLAN0001 FastEthernet0/15 Root Inconsistent Number of inconsistent ports(segments)in the system;1 //S2 将从 f0/15 收到 S3 发送的更优的 BPDU, 然而由于该接口上配置 Root Guard,S2 的接口进入阻断状态 S1#show spanning-tree VLAN0001 ( 此处省略 ) Interface Role Sts Cost Prio.Nbr Type Fa0/13 Root FWD P2P Fa0/15 Desg BKN* P2P*Root_Inc (5) 步骤 5: 配置 BPDU Guard S2(config)#int f0/15 S2(config-if)#shutdown // 关闭接口 S2(config-if)#no spanning-tree guard root // 去掉之前的配置 S2(config-if)#spanning-tree portfast S2(config-if)#spanning-tree bpduguard enable // 以上配置 BPDU Guard S2(config)#int f0/15 S2(config-if)#no shutdown 0;28;49;%SPANTREE-2-BLOCK_BPDUGUARD;Received BPDU on port FastEthernet0/15 with BPDU Guard enabled.disabling port 0;28;49;%PM-4Err_DISABLE;bpduguard error detected on Fa0/15,putting Fa0/15 in err-disable state 0;28;50;%LINEPROTO-5UPDOWN;Line protocol on Interface FastEthernet0/15,changed state to down // 交换机从 f0/15 接口收到 S3 的 BPDU,f0/15 被 disable 了 S2#show interfaces f0/15

224 FastEthernet0/15 is down, line protocol is down (err-disabled) // 可以看到 f0/15 接口关闭, 要重新开启, 请先移除 BPDU 源, 在接口下执行 shutdown 和 no shutdown 命令 14.7 STP 命令汇总 表 14-1 是本章出现的命令 表 14-1 本章命令汇总 命令 作用 show spanning-tree 查看 STP 树信息 spanning-tree vlan 1 priority 4096 配置 VLAN1 的桥优先级 spanning-tree portfast 配置接口为 Portfast, 当有设备接入时立即进入转发状态 spanning-tree uplinkfast 配置 Uplinkfast 特性 spanning-tree backbonefast 配置 Backbonefast 特性 spanning-tree mode rapid-pvst 把 STP 的运行模式设为 RSTP+PVST spanning-tree link-type point-to-point 把接口的链路类型改为点对点 spanning-tree mode mst 把生成树的模式改为 MST spanning-tree mst configuration 进入 MST 的配置模式 name TEST-MST 命名 MST 的名字 revision 1 配置 MST 的 revision 号 instance 1 vlan 1-2 把 VLAN 1 和 VLAN 2 的生成树映射到实例 1 spanning-tree guard root 在接口下配置 Root Guard 特性 spanning-tree bpduguard enable 在接口上配置 Bpduguard 特性

225 第 15 章 VLAN 间路由 在交换机上划分 VLAN 后,VLAN 间的计算机就无法通信了 VLAN 间的通信需要借助第 3 层设备, 可以使用路由器来实现这个功能, 如果使用路由器, 通常会采用单臂路由模式 实践上,VLAN 间的路由大多是通过 3 层交换机实现的,3 层交换机可以看成是路由器加交换机, 然而因为采用了特殊的技术, 其数据处理能力比路由器要大得多 本章将分别介绍两种方法和具体配置 15.1 VLAN 间路由简介 单臂路由 处于不同 VLAN 的计算机即使它们是在同一交换机上, 它们之间的通信也必须使用路由器 可以使每个 VLAN 上都有一个以太网口和路由器连接, 采用这种方法, 如果要实现 N 个 VLAN 间的通信, 则路由器需要要 N 个以太网接口, 同时也会占用了 N 个交换上的以太网接口 单臂提供另外一种解决方案, 路由器只需要一个以太网接口和交换机连接, 交换机的这个接口设置为 Trunk 接口 在路由器上创建多个子接口和不同的 VLAN 连接, 子接口是路由器物理接口上的逻辑接口 工作原理如图 15-1, 当交换机收到 VLAN1 的计算机发送的数据帧后, 从它的 Trunk 接口发送数据给路由器, 由于该链路是 Trunk 链路, 帧中带有 VLAN1 的标签, 帧到了路由器后, 如果数据要转发到 VLAN2 上, 路由器将把数据帧的 VLAN1 标签去掉, 重新用 VLAN2 的标签进行封装, 通过 Trunk 链路上发送到交换上的 Trunk 接口 ; 交换机收到该帧, 去掉 VLAN2 标签, 发送给 VLAN2 上的计算机, 从而实现了 VLAN 间的通信 图 15-1 路由器的子接口工作原理 层交换 单臂路由实现 VLAN 间的路由时转发速率较慢, 实际上, 在局域网内部多采用 3 层交换 3 层交换机通常采用硬件来实现, 其路由数据包的速率是普通路由器的几十倍 从使用者的角度, 可以把 3 层交换机看成 2 层交换机和路由器的组合, 如图 15-2 所示,

226 这个虚拟的路由器和每个 VLAN 都有一个接口进行连接, 不过这些接口的名称是 VLAN1 或 VLAN2.Cisco 早些年采用的基于 NetFlow 的 3 层交换技术 ; 现在 Cisco 主要采用 CEF 技术 在 CEF 技术中, 交换机利用路由表形成转发信息库 (FIB),FIB 和路由表是同步的, 着急的是,FIB 的查询是硬件化的, 其查询速度很快 除了 FIB 外, 还有邻接表 (Adjacency Table), 该表和 ARP 表类似, 主要旋转了第 2 层的封装信息 FIB 和邻接表都是数据转发之前就已经建立好了, 这样一有数据要转发, 交换机就能直接利用它们进行数据转发和封装, 不需要查询路由表和发送 ARP 请求, 所以 VLAN 间的路由速率大大提高 图 层交换机原理示意图 15.2 实验 1: 单臂路由实现 VLAN 间路由 1. 实验通过本实验, 读者可以掌握如下技能 : 1 路由器以太网接口上的子接口 ; 2 单臂路由实现 VLAN 间路由的配置 2. 实验拓扑实验拓扑图如图 15-3 所示 图 15-3 实验 1 拓扑图

227 3. 实验步骤我们要用 R1 来实现分别处于 VLAN1 和 VLAN2 的 PC1 和 PC2 间的通信 (1) 步骤 1: 在 S1 上划分 VLAN S1(config)#vlan 2 S1(config-vlan)#exit S1(config)#int f0/5 S1(config-if)#switchport mode access S1(config-if)#switchport access vlan 1 S1(config-if)#in f0/6 S1(config-if)#switchport mode access S1(config-if)#switchport access vlan 2 (2) 步骤 2: 要先把交换上的以太网接口配置成 Trunk 接口 S1(config)#int f0/1 S1(config-if)#switch trunk enacp dot1q S1(config-if)#switch mode trunk (3) 在路由器的物理以太网接口下创建子接口, 并定义封装类型 R1(config)#int g0/0 R1(config-if)#no shutdown R1(config)#int g0/0.1 R1(config-subif)#encapture dot1q 1 native // 以上是定义该子接口承载哪个 VLAN 流量, 由于交换上的 Native VLAN 是 VLAN 1, 所以我们这里也要指明该 VLAN 就是 Native VLAN 实际上, 默认时,Native VLAN 就是 VLAN 1 R1(config-subif)#ip address // 在子接口上配置 IP 地址, 这个地址就是 VLAN 1 的网关 R1(config)#int g0/0.2 R1(config-subif)#encapture dot1q 1 R1(config-subif)#ip address 实验调试在 PC1 和 PC2 上配置 IP 地址和网关,PC1 的网关指向 : , PC2 的网关指向 : 测试 PC1 和 PC2 的通信 注意 : 如果计算机有两个网卡, 去掉另一个网卡上设置的网关

228 提示 S1 实际上是 Catalyst 3560 交换机, 该交换机具有 3 层功能, 在这里如果把它当成 2 层交换机使用, 有点大材小用 15.3 实验 2:3 层交换实现 VLAN 间路由 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 3 层交换的概念 ; 2 配置 3 层交换 2. 实验拓扑实验拓扑图如图 15-4 所示 图 15-4 实验 2 拓扑图 3. 实验步骤用 S1 来实现分别处于 VLAN1 和 VLAN2 的 PC1 和 PC2 间的通信 (1) 步骤 1: 在 S1 上划分 VLAN S1(config)#vlan 2 S1(config-vlan)#exit S1(config)#int f0/5 S1(config-if)#switchport mode access S1(config-if)#switchport access vlan 1 S1(config-if)#in f0/6 S1(config-if)#switchport mode access S1(config-if)#switchport access vlan 2 (2) 步骤 2: 配置 3 层交换 S1(config)#ip routing

229 // 以上 S1 的路由功能, 这时 S1 就启用了 3 层功能 S1(config)#int vlan 1 S1(config-if)#no shutdown S1(config-if)#ip address S1(config)#int vlan 2 S1(config-if)#no shutdown S1(config-if)#ip address // 在 VLAN 接口上配置 IP 地址即可,VLAN 1 接口上的地址主是 PC1 的网关,VLAN 2 接口上的地址就是 PC2 的网关 提示 要在 3 层交换机上启用路由功能, 还需要启用 CEF( 命令为 :ip cef), 不过这是默认值 和路由器一样,3 层交换机上同样可以运行路由协议 4. 实验调试 (1) 检查 S1 上的路由表 S1#show ip route ( 此处省略 ) /24 is subnetted,2 subnets C is directly connected,vlan1 C is directly connected,vlan2 // 和路由器一样,3 层交换上也有路由表 (2) 测试 PC1 和 PC2 间的通信在 PC1 和 PC2 上配置 IP 地址和网关,PC1 的网关指向 : , PC2 的网关指向 : 测试 PC1 和 PC2 的通信 注意 : 如果计算机有两个网卡, 去掉另一个网卡上设置的网关 提示 也可以把 f0/5 和 f0/6 接口作为路由接口使用, 这时这们就和路由器的以太网接口一样了, 可以在接口上配置 IP 地址 如果 S1 上的全部以太网接口都是这样设置,S1 实际上成为具有 24 个以太网接口的路由器了 不建议这样做, 这样太浪费接口 配置示例 : S1(config)#int f0/10 S1(config-if)#no switchport // 该接口不再是交换接口了, 成为路由接口 S1(config-if)#ip address VLAN 间路由命令汇总

230 表 15-1 是本章出现的命令表 15-1 本章命令汇总命令 int g0/0.1 encapture dot1q 1 native ip routing no switchport ip cef 作用创建子接口指明子接口承载哪个 VLAN 的流量以及封装类型, 同时该 VLAN 是 Native VLAN 打开路由功能接口不作为交换机接口开启 CEF 功能

231 第 16 章网关冗余和负载平衡 为了减少交换机故障的影响, 交换上有 STP 技术 然而作为网关的路由器出故障了, 又有什么办法?HSRP 和 VRRP 是最常用的网关冗余技术 HSRP 和 VRRP 类似, 由多个路由器共同组成一个组, 虚拟一个网关, 其中的一台路由器处于活动状态, 当它出故障时, 由备份路由器接替它的工作, 从而实现对用户透明的切换 然而我们希望在冗余的同时, 能同时实现负载平衡, 以充分利用设备的能力,GLBP 同时提供了冗余和负载平衡的能力 本章将介绍它们的具体配置 16.1 网关冗余和负载平衡简介 HSRPHSRP 是 Cisco 的专有协议 HSRP(Hot Standby Router Protocol) 把多台路由器组成一个 热备份组, 形成一个虚拟路由器 这个组内只有一个路由器是活动的 (Active), 并由它来转发数据包, 如果活动路由器发生了故障, 备份路由器将成为活动路由器 从网络内的主机来看, 网关并没有改变 HSRP 路由器利用 Hello 包来互相监听各自的存在 当路由器长时间没有接收到 Hello 包时, 就认为活动路由器故障了, 备份路由器就会成为活动路由器 HSRP 协议利用优先级决定哪个路由器成为活动路由器 如果一个路由器的优先级比其他路由器的优先级高, 则该路由器成为活动路由器 路由器的默认优先级是 100. 在一个组中, 最多有一个活动路由器和一个备份路由器 HSRP 路由器发送的多播消息有以下 3 种 1 Hello;Hello 消息通知其他路由器发送路由器的 HSRP 优先级和状态信息,HSRP 路由器默认为每 3 s 发送一个 Hello 消息 ; 2 Coup; 当一个备用路由器变为一个活动路由器时, 发送一个 Coup 消息 ; 3 Resign; 当活动路由器要宕机或者当有优先级更高的路由器发送 Hello 消息时, 主动发送一个 Resign 消息 HSRP 路由器有以下 6 种状态 1 Initial;HSRP 启动时的状态,HSRP 还没有运行, 一般是在改变配置或接口刚刚启动时进入该状态 ; 2 Learn; 路由器已经得到了虚拟 IP 地址, 但是它既不是活动路由器, 也不是备份路由器, 它一直监听从活动路由器和备份路由器发来的 Hello 报文 ; 3 Listen; 路由器正在监听 Hello 消息 ;

232 4 Speak; 在该状态下, 路由器定期发送 Hello 报文, 并且积极参加活动路由器或备份路由器的竞选 ; 5 Standby; 当活动路由器失效时路由器准备接管数据传输功能 ; 6 Active; 路由器执行数据传输功能 VRRP VRRP 的工作原理和 HSRP 非常类似, 不过 VRRP 是国际上的标准, 允许在不同厂商的设备之间运行 VRRP 中虚拟网关的地址可以和接口上的地址相同,VRRP 中接口只有 3 个状态 : 初始状态 (Initialize) 主状态 (Master) 和备份状态 (Backup) VRRP 只有一种报文 GLBP HSSP 和 VRRP 能实现网关冗余, 然而, 如果要实现负载平衡, 需要创建多个组, 并让客户端指向不同的网关 GLBP (Gateway Load Balance Protocol) 也是 Cisco 的专有协议, 不仅提供冗余网关功能, 还在各网关之间提供负载均衡 GLBP 也是由多个路由器组成一个组, 虚拟一个网关出来 GLBP 选举出一个 AVG(Avtive Virtual Gateway),AVG 不是负责转发数据的 AVG 分配最多 4 个 MAC 地址给一个虚拟网关, 并在计算机进行 ARP 请求时, 用不同的 MAC 进行响应, 这样计算机实际就把数据发送给不同的路由器了, 从而实现负载平衡 在 GLBP 中, 真正负责转发数据的是 AVF (Avtive Virtual Forawarder),GLBP 会控制 GLBP 组中哪个路由器是哪个 MAC 地址的活动路由器 AVG 的选举和 HRSP 中活动路由器的选举非常类似, 优先级最高的路由器成为 AVG, 次之的为 Abckup AVG, 其余的为监听状态 一个 GLBP 组只能有一个 AVG 和一个 Backup AVG, 主 AVG 失败, 备份 AVG 顶上 一台路由器可以同时是 AVG 和 AVF AVF 是某些 MAC 的活动路由器, 也就是说, 如果计算机把数据发往这个 MAC, 它将接收 当某一 MAC 的活动路由器有故障时, 其他 AVF 将成为这一 MAC 的新的活动路由器, 从而实现冗余功能 GLBP 的负载平衡策略可以根据不同主机 简单地轮询, 或者根据路由器的权重平衡, 默认是轮询方式 16.2 实验 1:HSRP 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 HSRP 的工作原理 ; 2 掌握 HSRP 的配置 2. 实验拓扑实验拓扑图如图 16-1 所示

233 图 16-1 实验 1 和实验 2 拓扑图 3. 实验步骤 (1) 步骤 1: 配置 IP 地址和路由协议等 R1(config)#interface GigabitEthernet0/0 R1(config-if)#ip address R1(config)#interface Serial0/0/0 R1(config-if)#ip address R1(config)#router rip R1(config-router)#network R1(config-router)#network R1(config-router)#passive-interface GigabitEthernet0/0 // 之所以把 g0/0 接口设为被接口, 是为了防止从该接口发送 RIP 信息给 R3 R2(config)#interface GigabitEthernet0/0 R2(config-if)#ip address R2(config)#interface Serial0/0/0 R2(config-if)#clock rate R2(config-if)#ip address R2(config)#interface Serial0/0/1 R2(config-if)#clock rate R2(config-if)#ip address R2(config)#router rip R2(config-router)#network R2(config-router)#network R2(config-router)#network R2(config-router)#passive-interface GigabitEthernet0/0 R3(config)#interface GigabitEthernet0/0 R3(config-if)#ip address

234 R3(config)#interface Serial0/0/1 R3(config-if)#ip address R3(config)#router rip R3(config-router)#network R3(config-router)#network R3(config-router)#passive-interface GigabitEthernet0/0 (2) 步骤 2: 配置 HSRP R1(config)#interface g0/0 R1(config-if)#standby 1 ip // 启用 HSRP 功能, 并设置虚拟 IP 地址,1 为 Standby 的组号 相同组号的路由器属于同一个 HSRP 组, 所有属于同一个 HSRP 组的路由器的虚拟地址必须一致 R1(config-if)#standby 1 priority 120 // 配置 HSRP 的优先级, 如果不设置该项, 默认优先级为 100, 该值越大, 抢占为活动路由器的优先权越高 R1(config-if)standby 1 preempt // 该设置允许该路由器在优先级是最高时成为活动路由器 如果不设置, 即使该路由器权值再, 也不会成为活动路由器 R1(config-if)#standby 1 timer 3 10 // 其中 3 为 Hello Time, 表示路由器每间隔多长时间发送 Hello 信息 10 为 Hold Time, 表示在多长时间内同组的其他路由器没有收到活动路由器的信息, 则认为活动路由器出故障了 该设置的默认值分别为 3 s 和 10 s 如果要更改默认值, 所有同 HSRP 组的路由器的该项设置必须一致 R1(config-if)#standby 1 authentication md5 key-string cisco // 以上是配置认证密码, 防止非法设备加入到 HSRP 组中, 同一个组的密码必须一致 R2(config)#interface g0/0 R2(config-if)#standby 1 ip R2(config-if)standby 1 preempt R2(config-if)#standby 1 timer 3 10 R2(config-if)#standby 1 authentication md5 key-string cisco //R2 上我们没有配置优先级, 默认为 100 (3) 步骤 3: 检查 测试 HSRP R1#show standby brief

235 P indicates configured to preempt. Interface Grp Pri P State Active Standby Virtual IP Gi0/ P Active local // 以上表明 R1 就是活动路由器, 备份路由器为 R3#show standby brief P indicates configured to preempt. Interface Grp Pri P State Active Standby Virtual IP Gi0/ P Standby local // 以上表明 R3 是备份路由器, 活动路由器为 在 PC1 上配置 IP 地址 /24, 网关指向 ; 在 PC3 上配置 IP 地址 /24, 网关指向 注意去掉另一网卡的网关 在 PC1 上连续 ping PC3 上, 在 R1 上关闭 g0/0 接口观察 PC1 上 ping 的结果 如下 : C;\>ping t Reply from ; bytes=32 time=9ms TTL=254 Reply from ; bytes=32 time=9ms TTL=254 Reply from ; bytes=32 time=9ms TTL=254 Request timed out. Reply from ; bytes=32 time=9ms TTL=254 Reply from ; bytes=32 time=9ms TTL=254 Reply from ; bytes=32 time=9ms TTL=254 Reply from ; bytes=32 time=11ms TTL=254 Reply from ; bytes=32 time=9ms TTL=254 // 以上可以看到,R1 故障时,R3 很快就替代了 R1, 通信只受到短暂的影响 R3#show standby brief P indicates configured to preempt. Interface Grp Pri P State Active Standby Virtual IP Gi0/ P Active local unknown 以上表明 R3 成为活动路由器 (4) 步骤 4: 配置端口跟踪在图 16-1 中, 按照以上步骤的配置, 如果 R1 的 s0/0/0 接口出现问题,R1 将没有到达 PC3 所在网段的路由 然而,R1 和 R3 之间的以太网仍然没有问题,HSRP 的 Hello 包正常发送和接收 因此,R1 仍然是虚拟网关 的活动路由器,PC1 数据会发送给 R1, 这样会造成 PC1 无法 ping 通 R3. 可以配置端口跟踪解决这个问题, 端口跟踪使得 R1 在发现 s0/0/0 上链路出现问题后, 把自己的优先级 ( 设为 120) 减去一个数字 ( 如 30), 成为了 90 由于 R3 的优先级为默认值 100,R3 就成为活动路由器 配置如下 : R1(config)#int g0/0 R1(config-ig)#standby 1 track s0/0/0 30 // 以上表明跟踪的是 s0/0/0 接口, 如果该接口出故障了, 优先级降低 30. 降低的值应该选择合适的值, 使得其他路由器能成为活动路由器 按照步骤 3 测试 HSRP 的端口跟踪是否生效 (5) 步骤 5: 配置多个 HSRP 组之前的步骤已经虚拟了 网关, 对于这个网关只能有一个活动路由器, 于

236 是活动路由器将承担全部的数据流量 可以再创建一个 HSRP 组, 虚拟出另一个网关 , 这时,R3 是活动路由器, 让一部分计算机指向这个网关, 这样就能做到负载平衡 以下是创建 2 个 HSRP 给的完整配置 在 R1 上 : interface GigabitEthernet0/0 standby 1 ip standby 1 priority 120 standby 1 preempt standby 1 authentication md5 key-string cisco standby 1 track Serial0/0/0 30 standby 2 ip standby 2 preempt standby 2 authentication md5 key-string cisco 在 R3 上 : interface GigabitEthernet0/0 standby 1 ip standby 1 preempt standby 1 authentication md5 key-string cisco standby 2 ip standby 2 priority 120 standby 2 preempt standby 2 authentication md5 key-string cisco standby 2 track Serial0/0/0 30 技术要点 我们这里是创建了两个 HSRP 组, 第一个组的 IP 为 , 活动路由器为 R1, 一部分计算机的网关指向 第二个组的 IP 为 , 活动路由器为 R2, 另一部分计算机的网关指向 这样, 如果网络全部正常时, 一部分数据是 R1 转发的, 另一部分数据是 R2 转发的, 实现了负载平衡 如果一个路由器出现问题, 则另一个路由器就成为两个 HSRP 组的路由器, 承担全部的数据转发功能 通过这种方式实现负载平衡, 需要计算机在设置网关时有所不同, 如果计算机的 IP 是 DHCP 分配的, 就不太方便了 技术要点 HSRP 实际上在局域网用得较多, 由于局域网内大多使用 3 层交换机, 所以, 这时 HSRP 是在交换机上配置的

237 16.3 实验 2:VRRP 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 VRRP 的工作原理 : 2 掌握 VRRP 的配置 2. 实验拓扑实验拓扑图如图 16-1 所示 图 16-1 实验 1 和实验 2 拓扑图 3. 实验步骤 VRRP 的配置和 HSRP 的配置基本相同, 这里不再重复其步骤 (1) 步骤 1: 配置 IP 地址和路由协议等参见实验 1. (2) 步骤 2: 配置多个 VRRP 组并跟踪接口在 R1 上 : R1(config)#track 100 interface Serial0/0/0 line-protocol R1(config)#interface GigabitEthernet0/0 R1(config-if)#vrrp 1 ip R1(config-if)#vrrp 1 priority 120 R1(config-if)#vrrp 1 preempt R1(config-if)#vrrp 1authentication md key-string cisco R1(config-if)#vrrp 1 track 100 decrement 30 R1(config-if)#vrrp 2 ip R1(config-if)#vrrp 2 preempt R1(config-if)#vrrp 2 authentication md5 key-string cisco //VRRP 的端口跟踪和 HSRP 有些不同, 需要在全局配置模式下, 先定义跟踪目标, 才配置 VRRP 中跟踪该目标, 这里定义目标 100 是 s0/0/0 接口在 R3 上 : R3(config)#track 100 interface Serial0/0/0 line-protocol R3(config)#interface GigabitEthernet0/0 R3(config-if)#vrrp 1 ip R3(config-if)#vrrp 1 preempt R3(config-if)#vrrp 1authentication md key-string cisco R3(config-if)#vrrp 2 ip R3(config-if)#vrrp 2 priority 120 R3(config-if)#vrrp 2 preempt

238 R3(config-if)#vrrp 2 authentication md5 key-string cisco R3(config-if)#vrrp 3 track 100 decrement 30 R1#show vrrp brief Interface Grp Pri Time Own Pre State Master addr Group addr Gi0/ Y Master Gi0/ Y Backup // 以上表明 R1 是 虚拟网关的 Master 路由器, 是 虚拟网关的 Backup 路由器 R3#show vrrp brief Interface Grp Pri Time Own Pre State Master addr Group addr Gi0/ Y Backup Gi0/ Y Master // 以上表明 R3 是 虚拟网关的 Master 路由器, 是 虚拟网关的 Backup 路由器 (3) 步骤 3: 检查 测试 HSRP 参见实验 实验 3:GLBP 1. 实验目的通过本实验, 读者可以掌握如下技能 : 1 理解 GLBP 的工作原理 ; 2 掌握 GLBP 的配置 2. 实验拓扑实验拓扑图如图 16-2 所示 图 16-2 实验 3 拓扑

239 3. 实验步骤 (1) 步骤 1: 配置 IP 地址和路由协议等 R1(config)#interface GigabitEthernet0/0 R1(config-if)#ip address R1(config)#interface GigabitEthernet0/1 R1(config-if)#ip address R1(config)#router rip R1(config-router)#network R1(config-router)#network R1(config-router)#passive-interface GigabitEthernet0/0 R2(config)#interface GigabitEthernet0/0 R2(config-if)#ip address R2(config)#interface GigabitEthernet0/1 R2(config-if)#ip address R2(config)#router rip R2(config-router)#network R2(config-router)#network R2(config-router)#passive-interface GigabitEthernet0/0 R3(config)#interface GigabitEthernet0/0 R3(config-if)#ip address R3(config)#interface GigabitEthernet0/1 R3(config-if)#ip address R3(config)#router rip R3(config-router)#network R3(config-router)#network R3(config-router)#passive-interface GigabitEthernet0/0 R3(config)#interface Loopback0 R3(config-if)#ip address R3(config)#interface GigabitEthernet0/1 R3(config-if)#ip address R3(config)#router rip R3(config-router)#network R3(config-router)#network R3(config-router)#passive-interface GigabitEthernet0/0 (2) 步骤 2: 配置 GLBP R1(config)#interface GigabitEthernet0/0 R1(config-if)#glbp 1 ip

240 // 和 HSRP 类似, 创建 GLBP 组, 虚拟网关的 IP 为 R1(config-if)#glbp 1 priority 200 // 配置优先级, 优先级高的路由器成为 AVG, 默认为 100 R1(config=if)#glbp 1 preempt // 配置 AVG 抢占, 否则即使优先级再高, 也不会成为 AVG R1(config-if)#glbp 1 authentication md5 key-0-string cisco // 以上是配置认证, 防止非法设备接入 R2(config)#interface GigabitEthernet0/0 R2(config-if)#glbp 1 ip R2(config-if)#glbp 1 priority 180 R2(config=if)#glbp 1 preempt R2(config-if)#glbp 1 authentication md5 key-0-string cisco R3(config)#interface GigabitEthernet0/0 R3(config-if)#glbp 1 ip R3(config-if)#glbp 1 priority 160 R3(config=if)#glbp 1 preempt R3(config-if)#glbp 1 authentication md5 key-0-string cisco (3) 步骤 3: 查看 GLBP 信息 R1#show glbp GigabitEthernet0/0 Group 1 State is Active 4 state changes, last state change 00;18;16 Virtual IP address is // 以上是虚拟的 IP 地址 Hello time 3 sec,hold time 10 sec Next Hello sent in secs Redirect time 600 sec,forwarder time-out sec Authentication MD5,key-string cisco Preemption enabled,min delay 0 sec Active is local // 以上说明 R1 是活动 AVG Standby is ,priority 180 (expires in sec) // 以上说明 R2 是备份 AVG Priority 200(configured) Weighting 100(default 100),thresholds;lower 1,upper 100 Load balancing;round-robin Group members; b548( )authenticated

241 b828( )local ( )authenticated // 以上显示 GLBP 组中的成员 There are 3 forwarders(1 active)forwarder 1 State is Listen 4 state changes,last state change 00;17;08 MAC address is 0007.b (learnt) // 这是虚拟网关的其中一个 MAC Owner ID is b548 Redirection enabled, sec remaining(maximum 600 sec) Time to live; sec (maximum sec) Preemption enabled,min delay 30 sec Active is (primary),weighting 100(expires in sec) Client selection count;1 Forwarder 2 State is Active 3 state changes,last state change 00;18;28 MAC address is 0007.b (default) // 以上说明 R1 是 0007.b 的活动路由器, 也就是说, 如果计算机把数据发往 0007.b , 将由 R1 接收数据, 再进行转发 Owner ID is b828 Redirection enabled Preemption enabled,min delay 30 sec Active is local,weighting 100 Client selection count;1 Forwarder 3 State is Listen 2 state changes,last state change 00;18;06 MAC address is 0007.b (learnt) Owner ID is Redirection enabled, sec remaining(maximum 600 sec) Time to live; sec (maximum sec) Preemption enabled,min delay 30 sec Active is (primary),weighting 100(expires in sec) 通过查看, 可以知道 R1;0007.b 的活动路由器 ; R2;0007.b 的活动路由器 ; R3;0007.b 的活动路由器 (4) 步骤 4: 检查 GLBP 的负载平衡功能在 PC1 上配置 IP 地址, 网关指向 , 并进行如下操作

242 C;\>ping C;\>arp a Interface; x10006 Internet Address Physical Address Type b dynamic 以上表明 PC1 的 ARP 请求获得网关 ( ) 的 MAC 为 b C;\>arp d // 上以是删除 ARP 缓冲表 C;\>ping C;\>arp a Interface; x10006 Internet Address Physical Address Type b dynamic 以上表明 PC1 的再次 ARP 请求获得网关 ( ) 的 MAC 为 b , 也就是说, 在 GLBP 响应 ARP 请求时, 每次会用不同的 MAC 响应, 从而实现负载平衡 提示 默认时,GLBP 的负载平衡策略是轮询方式, 可以在接口下使用 glbp 1 load-balancing 命令修改, 有以下选项 : host-dependent: 根据不同主机的源 MAC 地址进行平衡 ; round-robin: 轮询方式, 即每响应一次 ARP 请求, 轮换一个地址 ; weighted: 根据路由器的权重分配, 权重高的被分配的可能性越大 (5) 步骤 5: 检查 GLBP 的冗余功能首先在 PC1 上用 arp a 命令确认 的 MAC 地址是什么, 从而确定出当前空间是哪个路由器在实际转发数据 在这里, 的 MAC 地址为 b , 从步骤 3 得知是 R1 在转发数据 在 PC1 上连续 ping , 并在 R1 上关闭 g0/0 接口, 观察 PC1 的通信情况 : C;\>ping t Reply from ; bytes=32 time<1ms TTL=254 Reply from ; bytes=32 time<1ms TTL=254 Request timed out. Request timed out. Reply from ; bytes=32 time<1ms TTL=254 Reply from ; bytes=32 time<1ms TTL=254 // 可以看到 R1 出故障后, 其他路由器很快接替了它的工作, 计算机的通信只受到短暂的影响 因此 GLBP 不仅有负载平衡的能力, 也有冗余的能力 可以使用 show glbp 命令查看一下认认谁是 b 这个 MAC 的新的活动路由器

243 16.5 网关冗余及负载平衡命令汇总 表 16-1 是本章出现的命令 表 16-1 本章命令汇总 命令 作用 standby 1 ip 启用 HSRP 功能, 并设置虚拟 IP 地址 standby 1 priority 120 配置本路由器的 HSRP 优先级 standby 1 preempt 配置 HSRP 抢占 standby 1 timers 3 10 设置 HSRP 的 Hello Time 和 Hold Time standby 1 authentication md5 key-string cisco 配置 HSRP 认证密码, 认证方式为 MD5 show standby brief 查看 HSRP 的简要情况 standby 1 track Serial0/0/0 30 跟踪 s0/0/0 接口, 当接口故障时,HSRP 优先级降低 30 vrrp 1 ip 启用 VRRP 功能, 并设置虚拟 IP 地址 vrrp 1 priority 120 配置本路由器的 VRRP 优先级 vrrp 1 preempt 配置 VRRP 抢占 vrrp 1 authentication md5 key-string cisco 配置 VRRP 认证密码, 认证方式为 MD5 track 100 interface Serial0/0/0 line-protocol 定义一个跟踪目标号, 被跟踪对象为 s0/0/0 接口 vrrp 1 track 100 decrement 30 跟踪目标 100, 当目标故障时, 优先级降低 30 show vrrp brief 查看 VRRP 的简要情况 glbp 1 ip 启用 GLBP 功能, 并设置虚拟 IP 地址 flbp 1 priority 200 配置本路由器的 GLBP 优先级 glbp 1 preempt 配置 GLBP 抢占 glbp 1 authentication md5 key-string cisco 配置 GLBP 认证密码, 认证方式为 MD5 show glbp 查看 GLBP 情况

244 第 17 章 帧中继上的 OSPF 帧中继是典型的 NBMA (NonBroadcast Multiple Access) 网络, 其拓扑结构通常有两种 :Full Mesh( 全互连 ) 和 Hub-and-Spoke( 中心 - 分之 ) 由于 Hub-and-Spoke 结构具有节约费用 简化配置等优点, 在实际网络工程中有着广泛的应用. 本章重点讨论的就是在 Hub-and-Spoke 结构上, 网络类型为 NBMA 模式 广播模式 点到点模式和点到多点模式的 OSPF 配置 17.1 实验 1; 帧中继环境下的 NBMA 模式 1. 实验目的通过本实验可以掌握 ; 1 帧中继静态映射及 Broadcast 参数的含义 ; 2NBMA 模式下的 DR 选举 ; 3 手工配置 OSPF 邻居 ; 4NBMA 模式下的 OSPF 的培植和调试 2. 拓扑结构实验拓扑图如图 17-1 所示 图 17-1 帧中继环境下 NBMA 模式

245 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#interface loopback0 R1(config-if)#ipaddress R1(config-if)#ip ospf network point-to-point R1(config-if)#interface Serial0/0/0 R1(config-if)#ip address R1(config-if)#encapsulation frame-relay R1(config-if)#frame-relay map ip broadcast// 帧中继静态映射 R1(config-if)#frame-relay map ip broadcast R1(config-if)#frame-relay map ip // 使得可以 ping 通自己 R1(config-if)#no shutdown R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config-router)#neighbor // 手工指 OSPF 邻居 R1(config-router)#neighbor (2) 步骤 2: 配置路由器 R3 R3(config)#interface loopback0 R3(config-if)#ip address R3(config-if)#ip ospf network point-tu-point R3(config-if)#interface Serial0/0/1 R3(config-if)#ip address R3(config-if)#encapsulation frame-relay R3(config-if)#ip ospf priority 0 // 配置 Spoke 端 OSPF 接口优先级为 0 R3(config-if)#frame-relay map ip broadcast R3(config-if)#frame-relay map ip broadcast R3(config-if)#frame-relay map ip R3(config-if)#no farame-relay inverse-arp R3(config-if)#no shutdown R3(config)#router ospf 1 R3(config-routerz)#router-id R3(config-routerz)#network area 0 R3(config-routerz)#network area 0

246 (3) 步骤 3: 配置路由器 R4 R4(config)#interface loopback0 R4(config-if)#ip address R4(config-if)#ip ospf network point-tu-point R4(config-if)#interface Serial0/0/1 R4(config-if)#ip address R4(config-if)#encapsulation frame-relay R4(config-if)#ip ospf priority 0 R4(config-if)#frame-relay map ip broadcast R4(config-if)#frame-relay map ip broadcast R4(config-if)#frame-relay map ip R4(config-if)#no farame-relay inverse-arp R4(config-if)#no shutdown R4(config)#router ospf 1 R4(config-routerz)#router-id R4(config-routerz)#network area 0 R4(config-routerz)#network area 0 技术要点 1 在帧中继网络上,OSPF 接口默认的网络类型为 NON_BROADCAST 在这种模式下,OSPF 不会在帧中继接口上发送 Hello 包, 因此无法建立最基本的邻接关系 可以手工使用 neighbor 命令来指定邻居 这时 Hello 包以单播形式传送 2NBMA 属于多路访问网络 所以要进行 DR 选举 由于 Hello 包只能传 1 跳, 所以在 Hub-and-Spoke 结构中, 必须控制在于 hub 端的路由器为 DR, 最保险的方法就是将 Spoke 端接口优先级配置为 0, 使之不参与 DR 选举, hub 端的路由器自然就成为 DR 否则, 可能会导致路由学习不正常 4 实验调试 (1) show ip ospf interface R1#show ip ospf interface s0/0/0 Serial0/0/0 is up,line protocol is up Internet Address /24,Area0 Process ID 1,Router ID Network type NON_BROADCAST,Cost;64 // 接口网络类型为 NBMA 模式 Transmit Delay is 1 sec,state DR,Priority 1 // 自己是 DR, 接口优先级为 1 Designated Router(ID) Inerface address //DR 的 ID 和接口地址 No backup designated router on this network // 没有 BDR

247 Timer intervals configured,hello 30,Dead 120,Wait 120,Retransmit5 oob-resync timeout 120 Hello due in 00;00;22 Index 2/2,flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1,maximum is 1 Last flood scan time is 0 msec,maximum is 4 msec Neighbor Count is 2,Adjacent neighbor count is 2 Adjacent with neighbor Adjacent with neighbor Suppress helo for 0 neighbor(s) //NBMA 模式下,Hello 周期为 30 s // 与路由器 R3 和 R4 形成邻接关系 (2) show ip rout R3#show ip route ospf /24 is subnetted,1 subnets O [110/65]via ;01;47,Serial0/0/ /24 is subnetted,1 subnets O [110/65]via ,00;01;47,Serial0/0/0 从以上输出表明, 到达网络 /24 的路由条目的下一跳地址为 , 而不是 , 所以, 在 R3 的 s0/0/1 接口上, 必须有到 的映射 frame-relay map ip broadcast (3)show ip ospf neighbor detail R1#show ip ospf neighbor detail Neighbor ,interface Serial0/0/0 In the area 0 via interface Serial0/0/0 Neighbor priority is 0,State is FULL,9 state changes DR is BDR is Poll interval 120 Options is 0x52 LLS Options is 0x1(LR) Dead timer due in 00;01;53 Neighbor is up for 00;06;54 Inedx 1/1,retransmission queue length 0,number of retransmission 1 First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0) Last retransmission scan length is 1,maximum is 1 Last retransmission scan time is 0 masec,maximum is 0 msec Neighbor ,interface address

248 In the area 0 via interface Serial0/0/0 Neighbor priority is 0,State is FULL,9 state changes DR is BDr is poll interval 120 Options is 0x52 LLS Options is 0x1(LR) Dead timer due in 00;06;54 Index 2/2,retransmission queue length 0,number of retransmission 1 First 0x0(0)/0x0(0) Next 0x0(0)/0x0(0) Last retransmission scan length is 1,maximum is 1 Last retransmission scan time is 0 msec,maximum is 0 msec 以上输出表明 R1 的两个邻居的接口优先级为 0, 同时本网络的 BDR 为 , 这是可以的 17.2 实验 2: 帧中继环境下 BMA 模式 1. 实验目的通过本实验可以掌握 : 1 帧中继静态映射及 Broadcast 参数的含义 ; 2BMA 模式下的 DR 选举 ; 3BMA 模式 OSPF 的配置和调试 2. 拓扑结构实验拓扑图如图 17-1 所示 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#interface loopbacke0 R1(config-if)#ip address R1(config-if)#ip ospf network point-to-point R1(config-if)#interface Serial0/0/0 R1(config-if)#ip address R1(config-if)#encapsulation frame-relay R1(config-if)#frame-relay map ip broadcast R1(config-if)#frame-relay map ip broadcast R1(config-if)#frame-relay map ip R1(config-if)#no frame-relay inverse-arp 图 17-1 帧中继环境下 NBMA 模式

249 R1(config-if)#ip ospf network broadcast R1(config-if)#no shutdown R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 (2) 步骤 2: 配置路由器 R3 R3(config)#interface loopbacke0 R3(config-if)#ip address R3(config-if)#ip ospf network point-to-point R3(config-if)#interface Serial0/0/1 R3(config-if)#ip address R3(config-if)#encapsulation frame-relay R3(config-if)#ip ospf priority 0 R3(config-if)#frame-relay map ip broadcast R3(config-if)#frame-relay map ip broadcast R3(config-if)#frame-relay map ip R3(config-if)#no frame-relay inverse-arp R3(config-if)#ip ospf network broadcast R3(config-if)#no shutdown R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 0 (3) 步骤 3: 配置路由器 R4 R4(config)#interface loopbacke0 R4(config-if)#ip address R4(config-if)#ip ospf network point-to-point R4(config-if)#interface Serial0/0/1 R4(config-if)#ip address R4(config-if)#encapsulation frame-relay R4(config-if)#ip ospf priority 0 R4(config-if)#frame-relay map ip broadcast R4(config-if)#frame-relay map ip broadcast R4(config-if)#frame-relay map ip R4(config-if)#no frame-relay inverse-arp R4(config-if)#ip ospf network broadcast R4(config-if)#no shutdown R4(config)#router ospf 1

250 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0 技术要点 1 在 hub-and-spoke 结构中,BMA 也要控制 DR 选举, 确保处于 Hub 端的路由器为 DR, 实施方法和实验 1 一样 ; 2BMA 模式下, 邻居关系自动通过 Hello 包建立和维持 4. 实验调整 (1) show ip ospf interface R1#show ip ospf interface s0/0/0 Serial0/0/0 is up,line protocol is up Inetrnet Address /24,Area 0 Process ID 1,Router ID Network Type BROADST,Cost;64 Transmit Delay is 1 sec, State DR,Priority 1 Designated Router(ID) ,Interface address No backup designated router on this network Timer intervals configured,hello 10,Dead 40,Wait 40,Retransmit 5 oob-resync timeout 40 Hello due in 00;00;07 Index 2/2,flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1, maximum is 1 Last flood scan time is 0 msec,maximuum is 4 msec Neighbor Count is 2,Adjacent neighbor count is 2 Adjacent wieth neighbor Adjacent wieth neighbor Suppress hello for 0 neighbor(s) // 网络类型为 BROADCAST //BMA 模式下, Hello 周期为 10 s (2)show ip route R4#show ip route ospf /24 is subnetted,1 subnets O [110/65]via ,00;03;19,Serial0/0/ /24 is subnetted,1 subnets O [110/65]via ,00;03;19,Serial0/0/1

251 17.3 实验 3: 帧中继环境下的点到点模式 1. 实验目的 1 帧中继子接口下的静态映射 ; 2 点到点模式的特征 ; 3 点到点模式下的 OSPF 的配置和调试 2. 拓扑结构 实验拓扑图如图 17-2 所示 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#interface Loopback0 R1(config-if)#ip address R1(config-if)#ip ospf network point-to-point R1(config)#interface Serial0/0/0 R1(config-if)#no ip address R1(config-if)#encapsulation frame-relay R1(config-if)#no frame-relay inverse-arp R1(config-if)#no shutdown R1(config)interface Serial0/0/0.1 point-to-point 图 17-2 帧中继环境下的点点到模式

252 R1(config-subif)#ip address R1(config-subif)#frame-relay interface-dlci 103 R1(config)#interface Serial0/0/0.2 point-to-point R1(config-subif)#ip address R1(config-subif)#frame-relay interface-dlci 104 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 R1(config-router)#network area 0 (2) 步骤 2: 配置路由器 R3 R3(config)#interface Serial0/0/1 R3(config-if)#no ip address R3(config-if)#encapsulation frame-relay R3(config-if)#no franme-relay inverse-arp R3(config-if)#no shutdown R3(config)#interface Serial0/0/1.1 point-to-point R3(config-subif)#ip address R3(config-subif)#frame-relay interface-dlci 301 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 0 (3) 步骤 3: 配置路由器 R4 R4(config)#interface Serial0/0/1 R4(config-if)#no ip address R4(config-if)#encapsulation frame-relay R4(config-if)#no franme-relay inverse-arp R4(config-if)#no shutdown R4(config)#interface Serial0/0/1.1 point-to-point R4(config-subif)#ip address R4(config-subif)#frame-relay interface-dlci 401 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0

253 4. 实验调试 (1)show ip ospf interface R1#show ip ospf interface s0/0/0.1 Serial0/0/0.1 is up,line protocol is up Internet Address /24,Area 0 Process ID 1,Router ID ,Network Type POINT_TO_POINT,Cost;64 Transmit Delay is 1 sec,state POINT_TO_POINT Timer intervals configured,hello 10,Dead 40,Wait 40,Retransmit 5 为 10 s oob-resync timeout 40 Hello due in 00;00;09 Index 2/2,flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1,maximum is 1 Last flood time is 0 masec,maximum is 4 msec Neighbor Count is 1,Adjacent neighbor count is 1 Adjacent with neighbor Suppress hello for 0 neighbor(s) (2)show ip ospf neighbor detail R1#show ip ospf neighbor detail Neighbor ,interface address In the area 0 via interface Serial0/0/0.2 Neighbor priority is 0,State is FULL,6 state changes DR is BDR is Options is 0x52 LLS Options is 0x1(LR) Dead timer due in 00;00;34 Neighbor isup for 00;07;21 Index 2/2,retransmission queue length 0,number of retransmission 1 Fist 0x0(0)/0x0(0) Next 0x0(0)/0x0(0) Last retransmission scan length is 1,maximum is 1 Last retransmission scan time is 0 msec,maximum is 0 msec Neighbor ,interface address In the area 0 via interface Serial0/0/0.1 Neighbor priority is 0,State is FULL,6 state changes DR is BDR is Options is 0x52 LLS Options is 0x1(LR) Dead timer due in 00;00;32 //POINT_TO_POINT 模式下,Hello 周期

254 Neighbor isup for 00;08;51 Index 1/1,retransmission queue length 0,number of retransmission 1 Fist 0x0(0)/0x0(0) Next 0x0(0)/0x0(0) Last retransmission scan length is 1,maximum is 1 Last retransmission scan time is 0 msec,maximum is 0 msec 以上输出表明路由器 R1 通过两个子接口分别与路由器 R3 和 R4 建立邻接关系 技术要点 1 点倒点模式中的 DR 和 BDR 是 ; 2 在点到点模式下, 每个子接口需要配置不同的网络 ; 3 点到点模式下,Hello 周期为 10 s 17.4 实验 4: 帧中继环境下点到多点模式 1. 实验目的 1 帧中继子接口下静态映射 ; 2 点到多点模式的特征 ; 3 点到多点模式下 OSPF 的配置和调试 2. 拓扑结构 实验拓扑图如图 17-3 所示 图 17-3 帧中继环境下的点到多点模式

255 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)interface Serial0/0/0 R1(config-if)#no ip address R1(config-if)#encapsulation frame-relay R1(config-if)#no frame-relay inverse-arp R1(config-if)#no shutdown R1(config)interface Serial0/0/0.1 multipoint R1(config-subif)#ip address R1(config-subif)#ip ospf network point-to-multipoint R1(config-subif)#frame-relay map ip broadcast R1(config-subif)#frame-relay map ip broadcast R1(config-subif)#no frame-relay inverse-arp R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 0 R1(config-router)#network area 0 (2) 步骤 2: 配置路由器 R3 R3(config)#interface Serial0/0/1 R3(config-if)#ip address R3(config-if)#encapsulation frame-relay R3(config-if)#ip ospf network point-to-multipoint R3(config-if)#frame-relay map ip broadcast R3(config-if)#frame-relay- inverse-arp R3(config-if)#no shutdown R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 0 (3) 步骤 3: 配置路由器 R4 R4(config)#interface Serial0/0/1 R4(config-if)#ip address R4(config-if)#encapsulation frame-relay R4(config-if)#ip ospf network point-to-multipoint R4(config-if)#frame-relay map ip broadcast R4(config-if)#frame-relay- inverse-arp R4(config-if)#no shutdown

256 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0 4. 实验调试 (1)show ip ospf interface R1#show ip ospf interface s0/0/0.1 Serial0/0/0.1 is up,line protocol is up Internet Address /24,Area 0 Process ID 1Router ID ,Network Type POINT_TO_MULTIPONT,Cost;64 Transmit Delay is sec,state POINT_TO_MULTIPONT, Timer intervals configured,hello30,dead 120,Wait 120,Retransmit 5 //POINT_TO_MULTIPONT 模式下, Hello 周期为 30 s oob-resync timeout 120 Hello due in 00;00;00 Index 2/2,flood queue length 0 Next 0x0(0)/0x0(0) Last flood scan length is 1,maximum is 1 Last flood scan time is 0 msec,maximum is 0 msec Neighbor Count is 2,Adjacent neighbor count is2 Adjacent with neighbor Adjacent with neighbor Suppress hllo for 0 neighbor(s) (2)show ip route R1#show ip route ospf /32 is subnetted,1 subnets O [110/65]via ,00;02;11,Serial0/0/ /32 is subnetted,1 subnets O [110/65]via ,00;02;11,Serial0/0/ /16 is variably subnetted,3 subnets,2 masks O /32[110/64]via ,00;02;11,Serial0/0/0.1 O /32[110/64]via ,00;02;11,Serial0/0/0.1 R3#show ip route ospf /32 is subnetted,1 subnets O [110/65]via ,00;03;41,Serial0/0/ /32 is subnetted,1 subnets O [110/65]via ,00;03;41,Serial0/0/ /16 is variably subnetted,3 subnets,2 masks

257 O /32[110/128]via ,00;03;41,Serial0/0/0.1 O /32[110/64]via ,00;03;41,Serial0/0/0.1 以上输出表明在点到多点模式中, 在路由表中会产生该网段其他各个接口的主机路由, 因此在做帧中继映射的时候, 只做到中心点的映射就可以了 技术要点 1 点到多点广播模式可以被看成多个点到多点接口的集合, 然而, 和点到点不同的是, 帧中继口是在同一个子网上 ; 2 在点多点的模式中, 不需要选举 DR/BDR; 3Hello 包每 30 s 发送一次, 无须手工配置邻居 17.5 帧中继上的 OSPF 命令汇总 表 17-1 列出了本章涉及到的主要命令 命令 show ip route show ip ospf interface show ip ospf neighbor detail ip ospf network encapsulation frame-relay no frame-relay inverse-arp frame-relay interface-dlci frame-relay map ip 作用查看路由表查看运行 OSPF 的接口的相关信息查看 OSPF 邻居路由器的详细信息配置 OSPF 网络类型接口封装帧中继关闭帧中继逆向 ARP 解析帧中继映射帧中继映射

258 第 18 章 多区域 OSPF 在一个大型 OSPF 网络中,SPF 算法的反复计算, 庞大的路由表和拓扑表的维护以及 LSA 的泛洪等都会占用路由器的资源, 因而会降低路由器的运行效率 OSPF 协议可以利用区域的概念来减小这些不利的影响 因为在一个区域内的路由气将不需要了解它们所在区域为的拓扑细节 OSPF 多区域的拓扑结构有如下优势 : 1 降低 SPF 计算频率 ; 2 减小路由表 ; 3 降低了通告 LSA 的开销 ; 4 将不稳定限制在特定的区域 18.1 多区域 OSPF 概述 OSPF 路由器类型 当一个 AS 划分成几个 OSPF 区域时, 根据一个路由器在相应的区域之间内的作用, 可以将 OSPF 路由器作如下分类, 如图 18-1 所示 图 18-1 OSPF 路由器类型 1 内部路由器 :OSPF 路由器上的所有直接的链路都处于同一个区域 ; 2 主干路由器 : 具有连接区域 0 接口的路由器 ; 3 区域边界路由器 (ASR): 路由器与多个区域相连 ; 4 自治系统边界路由器 (ASBR); 与 AS 外部的路由器相连并互相交换路由信息

259 LSA 类型 一台路由器中所有有效的 LSA 通告都被存放在它的链路状态数据库中, 正确的 LSA 通过可以描述一个 OSPF 区域 的网络拓扑结构 常见的 LSA 有 6 类, 相应的描述如表 18-1 所示 表 18-1 LSA 类型及相应的描述 类型代码 名称及路由代码 描述 1 路由器 LSA 所有的 OSPF 路由器会产生这种数据包, 用于描述路由器上连接到某个区域的链路或者是某一 (O) 接到的状态信息. 该 LSA 只会在某一个特定的区域或内域扩散, 而不会扩散至其他的区域 2 网络 由 DR 产生, 只会在包含 DR 所处的广播网络的区域中扩散, 不会扩散至其他的 OSPF 区域 LSA(OIA) 3 网络汇总 LSA(OIA) 由 ABR 产生, 描述 ABR 和某个本地区域的内部路由器之间的链路信息, 这些条目通过主干区域被扩散到其他的 ABR 4 ASBR 汇总, 描述到 ASBR 的可达性, 由主干区域发送到其他 ABR LSA(O IA) 5 外部 LSA(O 由 ASBR 产生, 含有关于自治系统外的链路信息 E1 或 E2) 6 NSSA 外部 LSA(O N1 或 N2) 由 ASBR 产生的关于 NSSA 的信息, 可以在 NSSA 区域内扩散,ABR 可以将类型 7 的 LSA 转换为类型 5 的 LSA 区域类型 一个区域所在设置的特性控制着它所有能接受到的链路状态信息的类型 区分不同 OSPF 区域类型的关键在于它们对外部路由的处理方式 OSPF 区域类型如下所述 1 标准区域 : 可以接收链路更新信息和路由汇总 ; 2 主干区域 : 连接各个区域的中心实体, 所有其他的区域都要连接到这个区域上交换路由信息 ; 3 末节区域 (Stub Area): 不接收外部自治系统的路由信息 ; 4 次末节区域 (Not-S0-Stubby Area,NSSA): 允许接收以类型 7 的 LSA 发送的外部路由信息, 并且 ABR 要负责把类型 7 的 LSA 转换成类型 5 的 LSA 18.2 实验 1: 多区域 OSPF 基本配置 1 实验目的通过本实验可以掌握 :

260 1 在路由器上启动 OSPF 的路由进程 ; 2 启动参与路由协议的接口, 并且通告网络及所在的区域 ; 3LSA 的类型和特征 ; 4 不同路由器类型的功能 ; 5OSPF 拓扑结构数据库的特征和含义 ; 6E1 路由和 E2 路由的区别 ; 7 查看和调试 OSPF 路由协议相关信息 2 实验拓扑本实验的拓扑结构 18-2 所示 图 18-2 多区域 OSPF 基本配置在配置时, 采用环回接口尽量靠近区域 0 的原则 路由器 R4 的环回接口不在 OSPF 进程通告, 通过重分布的方法进入 OSPF 网络 3 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 1 R1(config-router)#network area 1 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 1 R2(config-router)#network area 0 R2(config-router)#network area 0 (3) 步骤 3 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 1 R3(config-router)#network area 2

261 R3(config-router)#network area 0 (4) 步骤 4: 配置路由器 R4 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 2 R4(config-router)#redistribute connected subnets // 将直连路由重分布的内容在后面的章节详细介绍 4 实验调试 (1)show ip route R2#show ip route ospf O /24 is subnetted,1 subnets [110/65]via ,00;04;36,Serial0/0/ /24 is subnetted,1 subnets O [110/65]via ,00;02;46,Serial0/0/ /24 is subnetted,1 subnets OE [110.20]via ,00;02;11,Serial0/0/1 OIA /24[110/128]via ,00;02;46,Serial0/0/1 以上输出表明路由器 R2 的路由表中既有区域内的路由 和 , 又有区域间的路由 , 还有外部区域的路由 , 这就是为什么在 R4 上要用重分布, 就是为了构造自治系统外的路由 技术要点 OSPF 的外部路由分为 : 类型 1( 在路由表中用代码 E1 表示 ) 和类型 2( 在路由表中间代码 E2 表示 ), 它们计算外部路由度量值的方式不同 : 1 类型 1(E1) 外部路径成本 + 数据包在 OSPF 网络所经过各链路成本 ; 2 类型 2(E2) 外部路径成本, 既 ASBR 上的默认设置 在重分布的时候, 可以通过 meitric-type 参数设置是类型 1 或 2, 也可以通过 metric 参数设置外部路径成本, 默认值为 20 下面的是洋具体的实例: R4(config-router)#redistribute connected subnets metric 50 metric-type 1 则在 R2 上关于 路由条目的信息如下 ; OE [110/178]via ,00;01;27,Serial0/0/1 (2)show ip ospf database R1#show ip ospf database

262 OSPF Router with ID( )(ProcessID 1) Router Link States(Area 1)// 区域 1 类型 1 的 LSA Link ID ADV Router Age Seq# Checksunm Link count x x00A0ED x x002E71 2 Summary Net Link States(Area1)// 区域 1 类型 3 的 LSA Link ID ADV Router Age Seq# Checksunm x x00A0ED x x000D x x006B7E x x001E x x Summary ASB Link States(Area1)// 区域 1 类型 4 的 LSA Link ID ADV Router Age Seq# Checksunm x x Type-5 AS External Link States// 类型 5 的 LSA Link ID ADV Router Age Seq# Checksunm Tag x x OSPF Router with ID( )(ProcessID1) Router Link States(Area 0)// 区域 0 类型 1 的 LSA Link ID ADVRouter Age Seq# Checksunm Link count x x x x00F56C 3 Summary Net Link States(Area0)// 区域 0 类型 3 的 LSA Link ID ADV Router Age Seq# Checksunm x x00B53B x x0099E5

263 x x0088DC Summary ASB Link States(Area0)// 区域 0 类型 4 的 LSA Link ID ADV Router Age Seq# Checksunm x x00EAF4 Router Link States(Area 1)// 区域 1 类型 1 的 LSA Link ID ADV Router Age Seq# Checksunm Link count x x00A2EC x x Summary Net Link States(Area1)// 区域 1 类型 3 的 LSA Link ID ADV Router Age Seq# Checksunm x x000F1F x x006D7D x x x x0029FF Summary ASB Link States(Area0)// 区域 0 类型 4 的 LSA Link ID ADV Router Age Seq# Checksunm x x008B18 Type-5 AS External Link States// 类型 5 的 LSA Link ID ADV Router Age Seq# Checksunm Tag x x00865F 0 以上输出结果包含了区域 1 的 LSA 类型 1 LSA 类型 3 LSA 类型 4 LSA 类型 5 的链路状态信息, 以及区域 0 的 LSA 类型 1,LSA 类型 3,LSA 类型 4 的链路状态信息 同时可以看到路由器 R1 和 R2 的区域 1 的链路状态数据库完全相同 技术要点 1 相同区域内的路由器具有相同的链路状态数据库, 只是在虚链路的时候略有不同 ; 2 命令 show ip ospf database 所显示的内容并不是数据库中存储的关于每条 LSA 的全部信息, 而仅仅是 LSA 的头部信息, 要看 LSA 的全部信息, 该命令后面还有跟详细的参数如 show ip ospf database router, 结果显示如下所述 R1#show ip ospf database router

264 OSPF Routr with ID( )(Process ID 1) Router Link States(Area 1) LS age;1355 OPTIons;(No TOS-capability,DC) LS Type;Router Links Link State ID; Advertising Router; LS Seq Number; Checksum;0x9EEE Length;60 Number of Links;3 Link connected to;a Stub Network (Link ID)Network/subnet number; (Link Data)Network Mask; Number of TOS metrics;0 TOS 0 Metrics;64 Link connected to;another Router(point-to-point) (Link ID)Network Router ID; (Link Data)Router Inerface address; Number of TOS metrics;0 TOS 0 Metrics;64 Link connected to;a Stub Network (Link ID)Network/subnet number; (Link Data)Network Mask; Number of TOS metrics;0 TOS 0 Metrics;64 Routing Bit Set on this LSA LS age;1267 Options;(No TOS-capability,DC) LS Type;Router Links Link State ID; Advertising Router; LS Seq Number; Checksum;0x2C72

265 Length;48 Area Border Router Number of Links;2 Link connected to;another Router(point-to-point) (Link ID)Network Router ID; (Link Data)Router Inerface address; Number of TOS metrics;0 TOS 0 Metrics;64 Link connected to;a Stub Network (Link ID)Network Router ID; (Link Data)Router Inerface address; Number of TOS metrics;0 TOS 0 Metrics;64 以上输出是路由器 R1 在区域 1 的 LSA 类型 1 的全部信息 (3)show ip ospf R4#show ip ospf1 Routing Process ospf 1 with ID Supports only single TOS(TOS0)routes Supports opaque LSA Supports Link-local Signaling(LLS) It is an autonomous system boundary router Redisributing External Routers from,... 以上信息表明路由器 R4 是一台 ASBR 18.3 多区域 OSPF 高级配置 实现 2:OSPF 手工汇总 1. 实验目的通过本实验可以掌握 : 1 路由汇总的目的 ; 2 区域间路由汇总 ; 3 外部自治系统路由汇总

266 2. 实验拓扑本实验的拓扑本实验的拓扑结构图 18-3 所示 图 18-3 OSPF 手工汇总路由器 R1 R2 和 R3 之间运行 OSPF, 路由器 R3 和 R4 之间运行 RIPv2, 路由器 R1 上的 4 个环回接口是为在路由器 R2 上进行区域间路由汇总准备的, 路由器 R2 上进行区域间路由汇总准备的, 路由器 R4 上的 4 个环回接口是为在路由器 R3 上进行外部路由汇总准备的 由于路由器 R3 是边界路由器, 所以要完成双像重分布 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 1 R1(config-router)#network area 1 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 1 R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config-router)#area 1 range // 配置区域间路由汇总 (3) 步骤 3: 配置路由器 R3 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config-router)#summary-address R2(config-router)#redistribut rip subnets // 配置外部自治系统路由汇总 // 将 RIP 路由重分布到 OSPF 中

267 R3(config)#router rip R3(config-router)#version 2 R3(config-router)#no auto-summary R3(config-router)#network R3(config-router)#redistribute ospf metric 2 // 将 OSPF 路由重分布到 RIP 中 (4) 步骤 4: 配置路由器 R4 R3(config)#router rip R3(config-router)#version 2 R3(config-router)#no auto-summary R3(config-router)#network R3(config-router)#network 技术要点 1 区域间路由汇总必须在 ABR 上完成 ; 2 外部路由汇总必须在 ASBR 上完成 4. 实验调试 (1) 在 R2 上查看路由表具体显示如下 R2#show ip route ospf O O O O O /8is variably subnetted,5 subnets,3 masks /32[110/65]via ,00;17;16,Seria10/0/ /24[110/65]via ,00;17;16,Seria10/0/ /22 is a summary,00;17;16,null /32[110/65]via ,00;17;16,Seria10/0/ /32[110/65]via ,00;17;16,Seria10/0/0 O /24 is subnetted,1 subnets [110/65]via ,00;12;14,Seria10/0/ /24 is subnetted,1 subnets OE [110/20]via ,00;11;09,Seria10/0/1 OE /24[110/20]via ,00;12;15,Seria10/0/1 以上输出表明 R2 对 R1 的 4 条环回接口的路由汇总后, 会产生一条指向 NullO 的路由 ; 同时收到经路由器 R3 汇总的路由, 因为是重分布进来的外部路由, 所以路由代码为 OE2

268 (2) 在 R3 上查看路由表具体显示如下 R3#show ip route ospf OIA /24[110/128]via ,00;23;20,Serial0/0/ /22 is subnetted,1 subnets OIA [110/129]via ,00;23;20,Serial0/0/ /24 is subnetted,1 subnets O [110/65]via ,00;23;20,Serial0/0/ /8is variably subnetted,5 subnets,2 masks O /22is a summary,00;20;29,nullo 以上输出表明 R3 对 4 条环回接口的 RIP 路由汇总后, 会产生一条指向 NULLO 的路由 ; 同时收到经路由 R2 汇总的路由, 由于是区域间路由汇总, 所以路由代码为 OIA 实验 3 OSPF 末节区域和完全末节区域 1. 实验目的通过本实验可以掌握 : 1 末节区域的条件 ; 2 末节区域的特征 ; 3 完全末节区域的特征 ; 4 末节区域的配置 ; 5 完全末节区域的配置 2. 实验拓扑本实验的拓扑结构图 18-4 所示 图 18-4 OSPF 末节区域的配置本实验在路由器 R2 上将环回接口 0 以重分布的方式注入 OSPF 区域, 用来构造 5 类的 LSA 把区域 1 配置成末节区域, 将区域 2 配置成完全末节区域

269 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 1 R1(config-router)#network area 1 R1(config-router)#area 1 stub // 把区域 1 配置成末节区域 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 1 R2(config-router)#network area 0 R2(config-router)#redistribute connected subnets // 将直连重分布进 OSPF 区域 R2(config-router)#area 1 stub (3) 步骤 3: 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 0 R3(config-router)#network area 2 R3(config-router)#area 2 sutb no-summary // 把区域 2 配置成完全末节区域 技术要点 no-summary 阻止区域间的路由进入末节区域, 所以叫完全末节区域 只需在 ABR 上启用本参数即可 (4) 步骤 4: 配置路由器 R4 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 2 R1(config-router)#network area 2 R1(config-router)#area 2 stub 技术要点 末节和完全末节区域需要满足如下的条件 : 1 区域只有一个出口 ; 2 区域不需要作为虚连路的过渡区 ;

270 3 区域内没有 ASBR; 4 区域不是主干区域 4. 实验调试 (1) 在 R1 上查看路由表具体显示如下 R1#show ip route ospf /24 is subnetted,1 subnets OIA [110/129]via ,00;12;29,Serial0/0/ /32 is subnetted,1 subnets OIA [110/193]via ,00;12;29,Serial0/0/0 OIA /24[110/128]via ,00;12;29,Serial0/0/0 OIA /24[110/192]via ,00;12;29,Serial0/0/0 O*IA /0[110/65]via ,00;12;29,Serial0/0/0 以上的输出表明 R2 重分布近来的环回接口的路由并没有在 R1 的路由表中出现, 说明末节区域不接收类型 5 的 LSA, 也就是外部路由 ; 同时, 末节区域 1 的 ABR R2 自动向该区域内传播 /0 的默认路由 ; 末节区域可以接收区域间路由 (2) 在 R4 上查看路由表具体显示如下 R4#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network /24 is subnetted, 1 subnets C is directly connected,loopback0 C /24 is directly connected,serial0/0/0 O*IA /0[110/65]via ,00;24;36,Serial0/0/0 以上输出表明在完全末节区域 2 中,R4 的路由表中除了直连和区域内路由, 全部被默认路由代替, 证明完全末节区域不接收外部路由和区域间路由, 只有区域内的路由和一条由 ABR 向该区域注入的默认路由

271 实验 4:OSPF NSSA 区域 1. 实验目的通过本实验可以掌握 : 1NSSA 的特征 ; 2NSSA 的配置 ; 3NSSA 的产生默认路由方法 2. 实验拓扑 本实验的拓扑结构图如图 18-5 所示 图 18-5 OSPF NSSA 区域配置本实验在路由器 R1 上将环回接口 0 以重分布的方式注入 OSPF 区域, 用来验证 5 类 LSA 在 NSSA 区域的传递方式 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(cofnig-router)#router-id R1(cofnig-router)#network area 1 R1(cofnig-router)#redistribute connected subnets R1(cofnig-router)#area 1 nssa // 将区域 1 配置成 NSSA (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 1 R2(config-router)#network area 0 R2(config-router)#network area 0 R2(config-router)#area 1 nssa

272 (3) 步骤 3: 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 0 R3(config-router)#network area 2 R3(config-router)#redistribut rip subnets // 将 RIP 路由重分布到 OSPF 区域 R3(cofnig)#router rip R3(cofnig-rotuer)#version 2 R3(cofnig-rotuer)#no auto-summary R3(cofnig-rotuer)#network R3(cofnig-rotuer)#redistribute ospf 1 metric 2 (4) 步骤 4: 配置路由器 R4 R4(cofnig)#router rip R4(cofnig-router)#version 2 R4(cofnig-router)#no auto-summary R4(cofnig-router)#network R4(cofnig-router)#network 实验调试 (1) 在 R1 上查看路由表具体显示如下 R1#show ip route ospf /24 is subnetted,1 subnets OIA [110/65]via ,00;06;11,Serial0/0/ /24 is subnetted,1 subnets OIA [110/129]via ,00;06;11,Serial0/0/0 OIA /24[110/128]via ,00;06;11,Serial0/0/0 以上的输出表明区域间路由是可以进入到 NSSA 区域的 ; 但是在 R1 的路由表中并没有出现在 R3 上把 RIP 重分布进来的路由, 因此, 说明 LSA 类型为 5 的外部路由不能在 NSSA 区域中传播,ABR 也没有能力把类型 5 的 LSA 转成类型 7 的 LSA 技术要点 如果不想在 NSSA 区域中出现区域间的路由, 则在 ABR 的路由器上配置 NSSA 区域时加上 no-summary 参数即可 这是 ABR 也会自动向 NSSA 区域注入一条 'O IA 的默认路由, 配置如下所述 R2(config-router)#area 1 nssa no-summary

273 R1 的路由表如下 R1show ip route Codes; C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area NI-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,W2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia-is-is inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network C /24 is directly connected Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 O*IA /0[110/65] via ,00;00;32,Serial0/0/0 本实验中, 如果在路由器 R2 配置 NSSA 时没有家 no-summary 参数, 那么对路由器 R1 来讲,RIP 部分的路由是不可达的, 为了解决此问题, 可以在路由器 R2 上配置 NSSA 区域时加上 default-information-orginate 参数即可, 此时 ABR 路由器 R2 会向 NSSA 区域注入一条 O N2 的默认路由, 配置如下 R2(config-router)#area 1 nssa default-information-originate R1#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,la-ospf inter area NI-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia-is-is inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network /24 is subnetted,1 subnets OIA [110/65]via ,00;01;57,Serial0/0/ /24 is subnetted,1 subnets OIA [110/129]via ,00;01;57,Serial0/0/0 OIA /24[110/128]via ,00;01;57,Serial0/0/0 O*N /0[110/1]via ,00;01;49,Serial0/0/0 如果在 R2 配置 NSSA 时, no-summary 参数和 default-information-originate 参数

274 都加, 如下所示 R2(config-router)#area 1 nssa default-information-originate no-summary 则 R1 的路由表如下 R1#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,la-ospf inter area NI-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia-is-is inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network C /24 is directly connected Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback0 O*IA /0[110/65] via ,00;00;20,Serial0/0/0 以上输出表明 O IA 的路由优先于 O N2 的路由 (2) 在 R2 上查看路由表具有显示如下 R2#show ip route ospf /24 is subnetted,1 subnets ON [110/20]via ,00;04;11,Serial0/0/ /24 is subnetted,1 subnets O [110/65]via ,00;04;11,Serial0/0/ /24 is subnetted,1 subnets OE [110/20]via ,00;04;11,Serial0/0/1 ON /24[110/20]via ,00;04;11,Serial0/0/1 以上输出表明 NSSA 区域的路由代码为 O N2 或 O N1 (3) 在 R2 上查看拓扑表具有显示如下 R2#show ip ospf database OSPF Router with ID( )(Process ID 1)

275 Router Link States(Area 0) Link ID ADV Router Age Seq# Checksunm Link count x x x C 0x005BFD 3 Link ID ADV Router Age Seq# Checksunm x A 0x0087EE Summary Net Link States(Area1) Link ID ADV Router Age Seq# Checksunm Link count x x002D6B x x00C1C9 2 Summary ASB Link States(Area1) Link ID ADV Router Age Seq# Checksunm x x00FC31 Type-7 AS External Link States(Area1) Link ID ADV Router Age Seq# Checksunm Tag x x00B x x00E92E 0 Type-5 AS External Link States Link ID ADV Router Age Seq# Checksunm Tag x x0060BD x x00FC8B x x0062A5 0 从输出结果中表明, 路由器 R2 将类型 7 的 LSA 转换成类型 5 的 LSA, 并且继续在网络上扩散到路由 R OSPF 虚链路 在实际网络中, 可能会存在主干区域不连续或者某一个区域与主干区域物理不相连的情

276 况, 在这两种情况下, 可以通过虚链路来解决 实验 5: 不连续区域 0 的虚链路 1. 实验目的通过本实验可以掌握 : 1 不连续区域 0 虚链路的特征 ; 2 虚链路的配置 2. 实验拓扑本实验的拓扑结构图如图 18-6 所士 图 18-6 不连续区域 0 需链路在本实验中, 区域 1 为转接区域 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#route ospf 1 R1(config-route)#router-id R1(config-route)#network area 0 R1(config-route)#network area 0 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-route)#router-id R2(config-route)#network area 0 R2(config-route)#network area 0 R2(config-route)#network area 1 R2(config-route)#area 1 virtual-link // 配置虚链路 技术要点 配置需链路的时候, virtual-link 后一定要互相指对方的路由器 ID

277 (3) 步骤 3: 配置路由器 R3 R3(config)#router ospf 1 R3(config-route)#router-id R3(config-route)#network area 0 R3(config-route)#network area 1 R3(config-route)#network area 0 R3(config-route)#area 1 virtual-link (4) 步骤 4: 配置路由器 R4 R4(config)#router ospf 1 R4(config-route)#router-id R4(config-route)#network area 0 R4(config-route)#network area 0 4. 实验调试 (1)show ip route R#show ip route ospf O /24 is subnetted,1 subnets [110/65]via ,00;04;42,Serial0/0/ /24 is subnetted,1 subnets O [110/129]via ,00;04;42,Serial0/0/ /32 is subnetted,1 subnets O [110/193]via ,00;04;42,Serial0/0/0 OIA /24[110/128]via ,00;04;42,Serial0/0/0 O /24[110/192]via ,00;04;42,Serial0/0/0 以上输出可以看出 通过虚链路可将两个不连续的区域 0 连接起来 (2)show ip ospf virtual-links R2#show io ospf virtual-links Virtual Link OSPF_VLO to router is up Run as demand circuit DoNotAge LSA allowed Transit area 1,via interface Seria10/0/1,Cost of using 64 Transmit Delay is 1 sec,state POINT_TO_POINT, Timer intervals configured,hello 10,Dead 40,Wait 40,Retransmit 5 Hello due in 00;00;03 Adjacency State FULL(Hello suppressed) Index 2/3,retransmission queue length 0,number of retransmission 1

278 First 0x0(0)/0x0(0) Next 0x0(0)/0x(0) Last retransmission scan length is 1,maximum is 1 Last retransmission scan time is 0 msec,maximum is 0 msec 以上输出表明了虚链路的基本信息 (3)show ip ospf database R2#show ip ospf database OSPF Router with ID( )(Process ID 1) Router Link States(Area 0) Link ID ADV Router Age Seq# Checksunm Link count x x00ABE x x00EEB (DNA) 0x x00C (DNA) 0x x00AB8E 3 Summary Net Link States(Area0) Link ID ADV Router Age Seq# Checksunm x x (DNA) 0x x00026E Router Link States(Area1) Link ID ADV Router Age Seq# Checksunm Link count x x00ED x x008BF1 2 以上输出表明虚链路的路由被拉进区域 0, 并带有 (DNA) 标记, 表示不老化 实验 6: 远离区域 0 的虚链路 1. 实验目的通过本实验可以掌握 : 1 远离区域 0 虚链路的特征 ; 2 虚链路的配置 2. 实验拓扑本实验的拓扑结构图 18-7 所示

279 图 18-7 远离区域 0 的虚链路在本实验中, 区域 1 为转接区域 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router ospf 1 R1(config-router)#router-id R1(config-router)#network area 2 R1(config-router)#network area 2 (2) 步骤 2: 配置路由器 R2 R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 0 R2(config-router)#network area 2 R2(config-router)#network area 1 R2(config-router)#area 1 virtuanl-link (3) 步骤 2: 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 1 R3(config-router)#network area 0 R3(config-router)#area 1 virtuanl-link (4) 步骤 2: 配置路由器 R4 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0 4. 实验调试在路由器 R4 上查看路由表

280 R4#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,la-ospf inter area NI-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia-is-is inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set OIA [110/192]via ,00;02;19,Serial0/0/ /34 is subnetted,1 subnets OIA [110/193]via ,00;02;19,Serial0/0/ /32 is subnetted,1 subnets OIA [110/129]via ,00;02;19,Serial0/0/ /32 is subnetted,1 subnets O [110/65]via ,00;02;19,Serial0/0/ /24 is subnetted,1 subnets C /24 is directly connected,loopback 0 OIA /24[100/128]via ,00;02;19,Serial0/0/0 C /24 is directly connected,serial0/0/0 从 R4 的路由表的输出, 可以看出路由器 R1 能够通过使用转接区域 1 的虚拟链路到达区域 0 技术要点 虚链路属于区域 0, 所以在进行区域 0 人证的时候, 不要忘记虚链路的认证, 例如, 如果区域 0 采用 MD5 认证, 则在虚链路上配置如下 : R3(config-router)#area 1 virtual-link message-digest-key 1 mad5 cisco 18.5 OSPF 命令汇总 表 18-2 列出了本章涉及到的主要命令 命令 show ip route show ip ospf neighbor show ip ospf database show ip ospf interface show ip ospf 表 18-2 本章命令汇总作用查看路由表查看 OSPF 邻居的基本信息查看 OSPF 拓扑结构数据库查看 OSPF 路由器接口的信息查看 OSPF 进程及其细节

281 show ip ospf database router redistribute area area-id range summary-address area area-id stub area area-id stub no-summary area area-id nssa area area-id virtual-link 查看类型 1 的 LSA 全部信息路由协议重分布区域间路右汇总外部路由汇总把某区域配置成末节区域把某区域配置成完全末节区域把某区域配置成 NSSA 区域配置虚链路

282 第 19 章 IS-IS 近几年来, 随着在 ISP 中的广泛应用,IS(Intermediate System, 中间系统 ) -IS 路由协议已经变得很普及 IS-IS 最初是国际标准化组织制定的一个 OSI( 开放系统互连 ) 路由协议, 被实际成工作在 OSI 无连接网络 (CLNS) 的环境中 19.1 IS-IS 概述 IS-IS 特点 IS-IS 是一个非常灵活的路由协议, 具有很好的可扩展性, 而且已经整合了诸如 MPLS( 多协议标记交换 ) 之类的特性, 其只要特点如下 1 维护一个链路状态数据库, 并使用 SPF 算法来计算最家路径 ; 2 用 Hello 包建立和维护邻居关系 ; 3 使用区域来构造两级层次化的拓扑结构 ; 4 在区域之间可以使用路由汇总来减少路由器的负担 ; 5 支持 VLSM 和 CIDR; 6 在广播多路访问网络通过选举指定 IS(DIS) 来管理和控制网络上的泛洪扩散 ; 7 具有认证功能 ; 8IS-IS 采用 Cost 作为度量值 ; 9IS-IS 管理距离为 115; 10 快速收敛 ; 11 适合大型网络 术语 1CLNS(Connectionless Network Service, 无连接网络服务 ); 使用数据包传输服务, 在数据传输之前不需要建立连接, 它描述了提供给传输层的服务 ; 2CLNP(Connectionless Network Protocol, 无连接网络协议 ); 是 OSI 模型中网络层中的一种无连接的网络协议, 和 IP 有相同的特制 ; 3ES(End System, 端系统 ); 没有路由能力的网络节点 ; 4IS(Intermediate System, 中间系统 ); 有数据包转发能力的网络节点, 即路由器 ; 5NSAP(Network Service Access Point, 网络服务访问点 ), 是网络层和传输层边界上概念性的点, 每一个传输层实体都会分配得到唯一的 NSAP 地址 ;

283 6Level 1 路由器 : 类似 OSPF 的内部路由器 ; 7Level 1/2 路由器 : 类似 OSPF 的 ABR; 8Level 2 路由器 : 类似 OSPF 的主干路由器 ; 9SNPA (Subnetwork Point of Attachment, 子网连接点 ); 是和 3 层地址对应的 2 层地址, 如 MAC 地址和 DLCI 等 : 10ISO 地址 :ISO 地址有两种形式,NET( 网络实体标题 ) 和 NSAP 地址, 其中 NET 和 NSEL 的值为 00x0 时的 NSAP 地址,NSAP 地址长度为 8~20 包括区域 系统 ID 和 NSAP 三部分, 其中前两部分可以分得更细 19.2 实验 1: 集成 IS-IS 的基本配置 1 实验目的通过本实验可以掌握 : 1 在路由器上启动 IS-IS 路由进程 ; 2 启用参与路由协议的接口 ; 3 度量值 cost 的计算 ; 4DIS 选举的控制 5 查看和调试 IS-IS 路由西医相关信息 2. 拓扑结构实验拓扑图如图 19-1 所示 图 19-1 集成 IS-IS 的基本配置

284 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router isis // 启动 IS-IS 路由进程 R1(cofing-router)#net // 配置 NET 地址 R1(config)#interface loopback0 R1(cofnig-if)#ip address R1(cofnig-if)#ip router isis // 接口下启用 IS-IS R1(cofnig-if)#interface Serial0/0/0 R1(cofnig-if)#ip address R1(cofnig-if)#ip router isis R1(cofnig-if)#no shutdown (2) 步骤 2: 配置路由器 R2 R2(config)#router isis R2(cofing-router)#net R2(config)#interface loopback0 R2(cofnig-if)#ip address R2(cofnig-if)#ip router isis R2(cofnig)#interface gigabitethernet0/0/0 R2(cofnig-if)#ip address R2(cofnig-if)#ip router isis R2(cofnig-if)#no shutdown R2(config)#interface Serial0/0/0 R2(config-if)#ip address R2(config-if)#clockrate R2(config-if)#ip router isis R2(config-if)#no shutdown (3) 步骤 3: 配置路由器 R3 R3(config)#router isis R3(cofing-router)#net R3(config)#interface loopback0 R3(cofnig-if)#ip address R3(cofnig-if)#ip router isis R3(cofnig)#interface gigabitethernet0/0 R3(cofnig-if)#ip address R3(cofnig-if)#ip router isis R3(cofnig-if)#no shutdown

285 (4) 步骤 4: 配置路由器 R4 R4(config)#router isis R4(cofing-router)#net R4(config)#interface loopback0 R4(cofnig-if)#ip address R4(cofnig-if)#ip router isis R4(cofnig)#interface gigabitethernet0/0 R4(cofnig-if)#ip address R4(cofnig-if)#ip router isis R4(cofnig-if)#no shutdown 4. 实验调试 (1)show clns neighbors 该命令用来显示 IS-IS 的邻居 R2#show clns neihbors SystemId Interface SNPA State Holdtime Type Protocol R1 Se0/0/0 *HDLC* UP 24 L1L2 IS-IS R2 Gi0/0 CA02.0F UP 26 L1L2 IS-IS R3 Gi0/0 CA02.0F UP 8 L1L2 IS-IS 从以上输出可以看出, 路由器 R2 有 3 个邻居, 而且都是 L1L2 类型的, 这也是启动 IS-IS 的路由器的默认类型 由于 R1 和 R2 是串行连接的, 所以 SNPA 为 *HDLC*, 而 R2 与 R3 和 R4 是通过以太网连接的, 所以 SNPA 分别 是 R3 和 R4 以太口 gigabitethernet0/0 的 MAC 地址 提示 从 IOS12.0(5) 版本开始,Ciosco 路由器支持动态主机名字映射, 可以通过命令 show isis hostname 查看 R2#show isis hostname Level System ID Dynamic Hostname (notag) R R R1 * R2 上面输出清楚地显示了系统 ID 和动态主机名的映射关系, 其中 * 表示本地路由器

286 注意 在默认情况下,Hello 包每 10 s 中发送一次,Holddown 时间为 30 s, 即 3 倍的关系 可以在接口下通过 isis hello-interval 命令修改 Hello 包发送的周期, 同时通过 isis hello-multiplier 命令定义 Holddown 是 Hello 周期的倍数 (2)show clns protocol 该命令显示和 CLNS 路由协议相关的信息 R2#show clns protocol IS-IS Router;<Null Tag> System Id; IS-Type;level-1-2 // 系统 ID 以及 IS-IS 路由器类型 Manual area address(es); Routing for area address(es); Interfaces supported by IS-IS; Gigabitethernet0/0 - IP Seria0/0/0 - IP Loopback0 - IP // 以上 4 行表示运行 IS-IS 路由协议的接口 Redistribute; static(on by default) Distance for L2 CLNS routes;110 // 管理距离 RRR level;none Generate narrow metrics;level-1-2 Accept narrow metrics; level-1-2 // 使用 窄 度量 Generate wide metrics: none Accept wide metrics: none (3)show clns interface 该命令显示 CLNS 接口状态的基本信息 R2#show clns interface s0/0/0 Serial0/0/0 is up,line protocol is up Checksums enabled,mtu 1500,Encapsulation HDLC ERPDUs enabled,min.interval 10 masec. CLNS fast switching enabled //CLNS 快速交换启动

287 CLNS SSE switching disabled //CCNS SSE 交换关闭 DEC compatibility mode OFF for this interface Next ESH/ISH in 47 seconds Routing Protocol;IS-IS Circuit Type;level-1-2 // 电路类型 Interface number 0x1,local circuit ID 0x100 Neighbor System-ID;R1 Level-1 Metric;10,Priority;64,Circuit ID;R2.00 // 接口 Level-1 的度量值 接口优先级以及电路 ID Level-1 IPv6 Metric;10 Number of active level-1 adjacencies;1 Level-2 Metric;10,Prioity;64,Circuit ID;R2.00 // 接口 Level-2 的度量值 接口优先级以及电路 ID Level-1 IPv6 Metric;10 Number of active level-2 adjacencies;1 Next IS-IS Hello in 7 seconds if state UP (4)show clns route 该命令查看 CLNS 第 2 层路由信息 R2#show clns route Codes;C-connected,S-static,d-DecntIV I-ISO-IGRP, i-is-is,e-es-is B-BGP, b-ebgp-neighbor C [1/0],Local IS-IS NET C [2/0],Local IS-IS Area 因为这条命令用于 OSI 路由选择, 所以以上输出没有太多的信息 (5)show isis topology 该命令显示 IS-IS 的拓扑结构信息, 包含到其他中间系统的路间系统的路径信息 R2#show isis topology IS-IS paths to level-1 routers SystemId Metric Next-Hop Interface SNPA R1 10 R1 Se0/0/0 *HDLC* R2 -- R3 10 R3 Gi0/0 ca02.0f

288 R4 10 R4 Gi0/0 ca03.0f IS-IS paths to level-2 routers SystemId Metric Next-Hop Interface SNPA R1 10 R1 Se0/0/0 *HDLC* R2 -- R3 10 R3 Gi0/0 ca02.0f R4 10 R4 Gi0/0 ca03.0f 以上输出表明 IS-IS 是为 L1 路由器和 L2 路由器分别存放拓扑结构数据库的, 其中 metric 是到达目标的 cost 之 和 (6)show isis database 该命令显示 IS-IS 链路状态数据库 R4#show isis database IS-IS Level-1 Link State Database; LSPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x C 0x5F4F /0/0 R *0x E 0xF57A 974 0/0/0 R x C 0x /0/0 R x B 0xA5FA 701 0/0/0 R x x9BE /0/0 IS-IS Level-2 Link State Database; LSPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x xFD8C 882 0/0/0 R *0x x125F 493 0/0/0 R x E 0x658B 869 0/0/0 R x B 0x /0/0 R x x4DB /0/0 以上输出表明 : 1IS-IS 为第一 1 层路由和第二层路由分别维护独立的链路状态数据库, 由于 IS-IS 是链路状态路由协议, 而且 4 台路 由器具有相同区域, 所以它们的链路状态数据库是相同的 2 路由器 R4 是 DIS,LSPID( 链路状态协议数据单元 ID) 由 3 个部分构成 : 第 1 部分是系统 ID, 长度为 6 字节 : 第 2 部分是伪节点 ID, 长度为 1 字节, 它代表了一个 LAN, 当这个值非 0 时, 表示该路由为 DIS; 第 3 部分是 LSP 分段号, 长度为 1 字节, 如果是 00 表示所有的数据都在单个的 LSP 中 3 系统 ID 和伪节点就构成了电路 ID(CircuitID), 如 R4.02 技术要点 DIS 的选举原则如下 : 1 只有形成邻接关系的路由器才有资格参与选举 ;

289 2 接口优先级最高成为 DIS; 3 如果接口优先级相同, 则最高的 SNPA 地址成为 DIS; 4DIS 选举是抢占的 修改接口优先级的命令是 isis priority, 默认是 64, 取值范围为 0~127 在本例中, 可以将 R2 的以太口的接口优 先级改为 100, 则 R2 马上被选为 DIS, 显示如下 R2#show isis database IS-IS Level-1 Link State Database; LSPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x x /0/0 R *0x xD /0/0 R *0x x63FE /0/0 R x xC80D /0/0 R x x68FF /0/0 IS-IS Level-2 Link State Database; LSPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x xF /0/0 R *0x x58E /0/0 R *0x x15D /0/0 R x xB0B /0/0 R x x639A /0/0 (7)show isis route 该命令查看 CLNS 第 1 层路由信息 R2#show isis route IS-IS not running in OSI mode(*)(only calculating IP routes) (*)Use show isis topology command to display paths to all routers 由于该命令是针对 OSI 路由选择协议的, 所以没有具体的输出 (8)show ip protocols 该命令显示和 IP 路由协议相关的信息 R2#show ip protocls Routing Protocol is isis Invalid afte 0 seconds,hold down 0,flushed after 0 // 更新机时器全部为 0, 表示 IS-IS 路由协议采用触发更新 Outoting update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Redistributing;isis Address Summarization; None

290 Maximum path;4 Routing for Networks; Loopback0 Seria10/0/0 Gigabitethernet0/0 // 以上 4 行表示运行 IS-IS 路由协议的接口 Routing Information Sources; Gateway Distance Last Update ;06; ;06; ;06;51 // 以上 5 行表示路由信息源 Distance;(default is 115) // 默认管理距离 (9)show ip route R2#show ip route /24 is subnetted, 1 subnets il [115/20]via ,Seria10/0/ /24 is subnetted,1 subnets il [115/20]via ,GigabitEthernet0/ /24 is subnetted,1 subnets il [115/20]via ,GigabitEthernet0/0 以上输出表明, 如果路由器类型为 L1/L2, 区域内的路由用 1 L1 表示, 即 level-1 路由 提示 在默认情况下,IS-IS 使用窄度量计算度量值, 所有链路都使用 10 作为度量值, 因为 IS-IS 不能像 OSPF 那样基于带宽自动的计算度量值 19.3 实验 2: 多区域集成的 IS-IS 1. 实验目的通过本实验可以掌握 : 1 在路由器上启动 IS-IS 路由进程 ; 2 启用参与路由协议的接口 ; 3L1 和 L2 路由的区别 ;

291 4 配置 L1 或 L2 路由器 ; 5 配置电路类型 ; 6 配置区域间路由汇总 ; 7 通告默认路由 ; 8 配置 IS-IS 人证 ; 9 查看和调试多区域 IS-IS 路由协议相关信息 2. 拓扑结构实验拓扑图如图 19-2 所示 图 19-2 多区域集成的 IS-IS 说明 IS-IS 区域的划分是基于路由器的, 也就是说, 一个路由器只能属于一个区域, 而 OSPF 区域的划分是基于链路的 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router isis R1(config-router)#net R1(config-router)#is-type level-1 // 将 R1 配置成 L1 路由器 R1(config-router)#area-password area // 启用区域认证 R1(config)#interface Loopback0 R1(config-if)#ip address R1(config-if)#ip router isis R1(config)#interface Serial0/0/0 R1(config-if)#ip address R1(config-if)#ip router isis R1(config-if)#isis password neighbor level-1 // 启用 level 1 邻居认证 R1(config-if)#no shutdown

292 (2) 步骤 2: 配置路由器 R2 R2(config)#router isis R2(config-router)#net R2(config-router)#default-information originate // 想 IS-IS 区域注入默认路由 R2(config-router)#area-password area R2(config-router)#domain-password domain // 启用域认证 R2(config)#interface Serial0/0/0 R2(config-if)#ip address R2(config-if)#clockrate R2(config-if)#ip router isis R2(config-if)#isis password neighbor level-1 R2(config-if)#no shutdown R2(config)#interface Serial0/0/1 R2(config-if)#ip address R2(config-if)#ip router isis R2(config-if)#clockrate R2(config-if)#no shutdown (3) 步骤 3: 配置路由器 R3 R3(config)#router isis R3(config-router)#net R3(config-router)#is-type level-2-only // 将 R3 配置成 L2 路由器 R3(config-router)#domain-password domain R3(config-router)#domain-password domain // 启用域认证 R3(config)#interface Serial0/0/0 R3(config-if)#ip address R3(config-if)#ip router isis R3(config-if)#isis circuit-type level-2-only // 配置接口电路类型 R3(config-if)#isis password neihborpassword level-2 // 启用 level-2 邻居认证 R3(config-if)#clockrat R3(config-if)#no shutdown R3(config)#interface Serial0/0/1 R3(config-if)#ip address R3(config-if)#ip router isis R3(config-if)#no shutdown (4) 步骤 4: 配置路由器 R4 R4(config)#router isis R4(config-router)#net R4(config-router)#summary-address // 配置区域间路由汇总 R4(config-router)#is-type level-2-only R4(config-router)#domain-password domain

293 R4(config)#interface Loopback0 R4(config-if)#ip address R4(config-if)#ip router isis R4(config)#interface Loopback1 R4(config-if)#ip address R4(config-if)#ip router isis R4(config)#interface Loopback2 R4(config-if)#ip address R4(config-if)#ip router isis R4(config)#interface Loopback3 R4(config-if)#ip address R4(config-if)#ip router isis R4(config-if)#interface Serial0/0/0 R4(config-if)#ip address R4(config-if)#ip router issi R4(config-if)#isis circuit-type lvel-2-only R4(config-if)#isis password neihborpassword level-2 R4(config-if)#no shutdown 技术要点 IS-IS 的认证只限于明文口令,Cisco 的 IOS 支持 3 个级别的认证 : 1 邻居认证 相互连接的路由器接口必须配置相同的口令, 同时必须为 L1 和 L2 类型的邻居关系配置各自的认证, L1 邻居认证的密码和 L2 邻居认证密码可以不同 邻居认证通过命令 isis password 配置 在本实验中,R1 和 R2 之间的串行链路启用 Level-1 的邻居认证, 而且 R3 和 R4 之间的串行链路起用 Level-2 的邻居认证 2 区域认证 区域内的每台路由器必须执行认证, 并且必须使用相同的口令 区域认证通过命令 area-password 配置 本实验中区域 启用区域认证 3 域认证 域内的每一个 L2 和 L1/L2 类型的路由器必须执行认证, 并且必须使用相同的口令 域认证通过命令 domain-password 配置 在本实验中 R2,R3 和 R4 都配置域认证, 因为路由器 R1 是 L1 路由器, 所以不用配置域认证 4. 实验调试 (1)show isis database R1#show isis database IS-IS Level-1 Link State Database; LsPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R *0x B 0x1F /0/0 R x x9DEE 658 1/0/0 R2#show isis database

294 IS-IS Level-1 Link State Database; LsPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x x /0/0 R *0x x02BC 902 1/0/0 IS-IS Level-2 Link State Database; LsPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x xE /0/0 R *0x xFFFD 903 0/0/0 R x xE9C /0/0 R x B 0xC /0/0 R3#show isis database IS-IS Level-2 Link State Database; LsPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R x B 0xC0D /0/0 R *0x x0FE /0/0 R x xEC /0/0 以上输出表明 : 1R1 路由器为 L1 路由器, 只维护 L1 的链路状态数据库 ; 2R2 路由器为 L1/L2 路由器, 同时为 L1 和 L2 维护单独的链路状态数据库, 也表明所在区域有另一台路由器 R1; 3R3 和 R4 路由器为 L2 路由器, 只维护 L2 的连接状态数据库 (2)show ip route R2#show ip isis il /24[115/20]via ,Serial0/0/0 i*l /0[115/10]via ,Serial0/0/0 R2#show ip route isis /24 is subnetted,1 subnets il [115/20]via ,Serial0/0/ /22 is subnetted,1 subnets il [115/30]via Serial0/0/1 il /24[115/20]via ,Serial0/0/1 R3#show ip route isis il /24[115/20]via ,Serial0/0/ /24 is subnetted,1 subnets il [115/30]via ,Serial0/0/ /22 is subnetted,1 subnets il [115/20]via ,Serial0/0/0 i*l /0[115/20]via ,Serial0/0/1 R4#show ip route isis

295 il /24[115/30]via ,Serial0/0/ /24 is subnetted,1 subnets il [115/40]via ,Serial0/0/ /8 is variably subnetted,5 subnets,2 masks isu /22[115/10]via ,Null0 il /24[115/20]via ,serial0/0/0 i*l /0[115/20]via ,Serial0/0/0 以上输出表明 : 1 由于 R1 为 L1 路由器, 所以只有 i L1 的路由和一条到最近的 L1/L2 路由器的默认路由 i*l1 ; 2 由于 R1 和 R2 在一个区域, 所以 R2 既有 il1 的路由, 又有 il2 的路由 ; 3R3 和 R4 都是 L2 路由器, 所以只有 i L2 的路由 ; 4R3 和 R4 都收到一条由 R2 注入的默认路由 i*l2 ; 5R2 和 R3 都收到 R4 的汇总路由, 同时 R4 的路由表自动生成一条 i su 的路由条目, 主要是为了避免路由环路 (3)show clns iterface R3#show clns interface0/0/0 serial0/0/0 is up,line protocol is up Checksums enabled,mtu 1500,Encapsulation HDLC ERPDUs enabled,min.interval 10 msec. CLNS fast switching enabled CLNS SSE swiching enabled DEC compatibilty mode OFF for this interface Next ESH/ISH in 12 seconds Routing Protocol;IS-IS Circuit Type;level-2... 从以上输出可以看到, 接口的电路类型为 level 帧中继上集成 IS-IS 实验 3:NBNA 上集成的 IS-IS 1. 实验目的通过本实验可以掌握 : 1 帧中继上 CLNS 映射 ; 2 在 NBMA 下 IS-IS 的配置和调试

296 2. 拓扑结构实验拓扑图如图 19-3 所示 图 19-3 NBMA 上集成 IS-IS 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router isis R1(config-router)#net R1(config)#interface Loopback0 R1(config-if)#ip address R1(config-if)#ip router isis R1(config)#interface Serial0/0/0 R1(config-if)#ip address R1(config-if)#encapsulation frame-relay R1(config-if)#frame-relay map clns 104 broadcast // 配置 CLNS 映射 R1(config-if)#frame-relay map clns 103 broadcast R1(config-if)#frame-relay map ip broadcast R1(config-if)#frame-relay map ip broadcast R1(config-if)#no frame-relay inverse-arp R1(config-if)#ip route isis R1(config-if)#no shutdown (2) 步骤 2: 配置路由器 R3 R3(config)#router isis R3(config-router)#net R3(config)#interface Loopback0 R3(config-if)#ip address R3(config-if)#ip router isis R3(config)#interface Serial0/0/1

297 R3(config-if)#ip address R3(config-if)#encapsulation frame-relay R3(config-if)#frame-relay map clns 304 broadcast R3(config-if)#frame-relay map clns 301 broadcast R3(config-if)#frame-relay map ip broadcast R3(config-if)#frame-relay map ip broadcast R3(config-if)#no frame-relay inverse-arp R3(config-if)#ip route isis R3(config-if)#no shutdown (3) 步骤 3: 配置路由器 R4 R4(config)#router isis R4(config-router)#net R4(config)#interface Loopback0 R4(config-if)#ip address R4(config-if)#ip router isis R4(config)#interface Serial0/0/1 R4(config-if)#ip address R4(config-if)#encapsulation frame-relay R4(config-if)#frame-relay map clns 403 broadcast R4(config-if)#frame-relay map clns 401 broadcast R4(config-if)#frame-relay map ip broadcast R4(config-if)#frame-relay map ip broadcast R4(config-if)#no frame-relay inverse-arp R4(config-if)#ip route isis R4(config-if)#no shutdown 4. 实验调试 (1)show clns neighbors R1#show clns neighbors SystmId Interface SNPA State Holdtime Type Protocol R3 Se0/0/0 DLCI 103 Up 23 L1L2IS-IS R4 Se0/0/0 DLCI 104 Up 8 L1L2IS-IS 以上输出表明 NBMA 网络中 IS-IS 的 SNPA 为 DLCL 号码 (2)show isis database R1#show clns databas IS-IS Level-1 Link State Database; LSPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R *0x x /0/0 R x xA /0/0

298 R x x401C /0/0 R x F 0x401C /0/0 IS-IS Level-2 Link State Database; LSPID LSP Seq Num LSP Checksum LSP Holdtime ATT/P/OL R *0x x0D6F /0/0 R x xDEC /0/0 R x x8FAC 528 0/0/0 R x E 0x /0/0 以上输出表明在 NBMA 网络中, 需要 DIS 选举, 由于各个接口没有配置优先级, 所以 R4 被选举成 DIS (3)show ip route R1#show ip route isis /24 is subnetted,1 subnets il [115/20]via ,Serial0/0/ /24 is subnetted,1 subnets il [115/20]via ,Serial0/0/0 以上输出表明路由器 R1 的路由表中有两条 il1 的路由, 因为它们都在区域 中 (3)show franme-relay map0 R1#show frame-relay map Serial0/0/0(up);CLNS dlci 103(0x67,0x1870),static, broadcast, CLSCO,status defined,active Serial0/0/0(up);CLNS dlci 104(0x67,0x1880),static, broadcast, CLSCO,status defined,active Serial0/0/0(up);ip dlci 103(0x67,0x1870),static, broadcast, CLSCO,status defined,active Serial0/0/0(up);ip dlci 103(0x67,0x1880),static, broadcast, CLSCO,status defined,active 以上输出表明接口 s0/0/0 上即需要 CLNS 的映射, 又需要 IP 的映射 CLNS 的映射是必需的, 如果没有 CLNS 的映射,CLSS 的邻居关系都不能建立 技术要点 1 在接口和多点接口下,IP 映射和 CNLS 映射应该分别分配, 命令分别是 franme-relay map clns 和 franme-relay map ip ; 2 在点到点子接口下, 命令 frame-relay interface-dlci 同时启动 IP 映射和 CNLS 映射, 所以不需要额外的 CLSN 映射

299 实验 4: 帧中继上点到点子接口下集合成的 IS-IS 1. 实验目的通过本实验可以掌握 : 1 帧中继上 CLNS 映射 ; 2 在帧中继上点到点子接口下 IS-IS 的配置和调试 2. 拓扑结构实验拓扑图 19-4 所示 图 19-4 帧中继点到点子接口下集成的 IS-IS 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router isis R1(config-router)#net R1(config)#ingerface Loopback0 R1(config-if)#ip address R1(config-if)#ip router isis R1(config)#interface serial0/0/0 R1(config-if)#encapsulation frame-relay R1(config-if)#no frame-relay inverse-arp R1(config-if)#no shutdown R1(config)#interface Serial0/0/0.1 point-to-point R1(config-subif)#ip address R1(config-subif)#frame-relay interface-dlci 103 R1(config-subif)#ip router isis R1(config)#interface Serial0/0/0.2 point-to-point R1(config-subif)#ip address R1(config-subif)#frame-relay interface-dlci 104 R1(config-subif)#ip router isis

300 (2) 步骤 2: 配置路由器 R3 R3(config)#router isis R3(config-router)#net R3(config)#ingerface Loopback0 R3(config-if)#ip address R3(config-if)#ip router isis R3(config)#interface serial0/0/1 R3(config-if)#encapsulation frame-relay R3(config-if)#no frame-relay inverse-arp R3(config-if)#no shutdown R3(config)#interface Serial0/0/1.1 point-to-point R3(config-subif)#ip address R3(config-subif)#frame-relay interface-dlci 301 R3(config-subif)#ip router isis (3) 步骤 3: 配置路由器 R4 R4(config)#router isis R4(config-router)#net R4(config)#ingerface Loopback0 R4(config-if)#ip address R4(config-if)#ip router isis R4(config)#interface serial0/0/1 R4(config-if)#encapsulation frame-relay R4(config-if)#no frame-relay inverse-arp R4(config-if)#no shutdown R4(config)#interface Serial0/0/1.1 point-to-point R4(config-subif)#ip address R4(config-subif)#frame-relay interface-dlci 401 R4(config-subif)#ip router isis 4. 实验调试 (1)show ip route R1#show ip route isis /24 is subnetted,1 subnets il [115/20]via , Serial0/0/ /24 is subnetted, 1 subnets il [115/20]via , Serial0/0/0.2

301 以上输出表明路由器 R1 的路由表中有两条 il2 的路由, 路由表是正确的 (2)show frame-relay map R1#show franme-relay map Seria0/0/0/.1(up);point-to-point dlci,dlci 103(0x67,0x1870),broadcast status defined,active Seria0/0/0/.2(up);point-to-point dlci,dlci 104(0x68,0x1880),broadcast status defined,active 以上输出表明点到点子接口的映射根本没有区分 IP 或者 CLNS, 所以命令 frame-relay interface-dlci 同时启动 IP 映射和 CNLS 映射 19.5 IS-IS 命令汇总 表 19-1 列出了本章涉及到的主要的命令 命令 show clns neighbors show clns protocols show clns interface show clns route clear clns route cler isis * show clns traffic show isis hostname show isis database show isis topology show isis route show frame-relay map show ip protocols router isis net ip router isis is-type area-password isis password domain-password default-information originate summary-addess isis circuit-type frame-relay map clns 表 19-1 本章命令汇总作用查看 CLNS 邻居查看 CLNS 路由协议相关的信息查看 CLNS 接口状态的信息查看 CLNS L2 路由清楚 CLNS 路由表清楚 IS-IS 链路状态数据库查看 CLNS 协议的统计信息查看主机名和系统 ID 的动态对应关系查看 IS-IS 链路状态数据库查看 IS-IS 拓扑结构信息查看 CLNS L1 的路由表查看帧中继映射查看 IP 路由协议相关的信息启动 IS-IS 路由进程配置 NET 地址接口下启动 IS-IS 配置 IS-IS 路由器类型配置区域认证配置邻居认证配置域认证向 IS-IS 网络注入默认路由配置区域间路由汇总配置接口电路类型配置 CLNS 映射

302 第 20 章 路由重分布 当许多运行多路的网络要集成到一起时, 必须在这些不同的路由选择协议之间共享路由信息 在路由选择协议之间交换由信息的过程被称为路由重分布 (Route Redistrbution) 20.1 路由重分布概述 路由重分布为在同一个互连网络中高校地支持多种路由协议提供了可能, 执行路由重分布的路由器被称为边界路由器, 因为它们位于两个或多个自治系统的边界上 路由重分布时计量单位和管理距离是必须要考虑的 每一种路由协议都有自己度量标准, 所以在进行重分布时必须转换度量标准, 使得它们兼容 种子度量值 (Seed Metric) 是定义在路由重分布里的, 它是一条从外部重分布进来的路由的初始度量值 路由协议默认的种子度量值如表 20-1 所示 表 20-1 路由协议默认的种子度量值路由协议默认种子度量值 RIP 无限大 EIGRP 无限大 OSPF BGP 为 1, 其他为 20 IS-IS 0 BGP IGP 的度量值 路由重分布应该考虑到如下的一些问题 1 路由环路 : 路由器有可能从一个自治系统学到的路由信息发送回该自治系统, 特别是在做双向重分布的时候, 一定要注意 ; 2 路由信息的兼容问题 : 每一种路由协议的度量标准不同, 所以, 路由器通过分布所选择的路径可能并非最佳路径 ; 3 不一致的收敛时间 : 因为不同的路由协议收敛的时间不同 20.2 实验 1:RIP,EIGRP 和 OSPF 重分布 1. 实验目的通过本实验可以掌握 : 1 种子度量值的配置 ;

303 2 路由重分布参数的配置 ; 3 静态路由重分布 ; 4RIP 和 OSPF 的重分布 ; 5EIGRP 和 OSPF 的重分布 ; 6 重分布路由的查看和调试 2. 拓扑结构实验拓扑图如图 20-1 所示 图 20-1 RIP,EIGRP 和 OSPF 重分布 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router rip R1(config-router)#version 2 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#redistribute static metric 3 // 重分布静态路由 R1(config)#ip router Serial0/0/1 注意 在向 RIP 区域重分布路由的时候, 必须指定度量值, 或者通过 default-metric 命令设置默认种子度量值, 因为 RIP 默认种子度量值为无限大, 只有重分布静态特殊, 可以不指定种子度量值 (2) 步骤 2: 配置路由器 R2 R2(config)#router eigrp 1 R2(config-router)#no auto-summary R2(config-router)#network R2(config-router)#redistribute rip metric // 将 RIP 重分布到 EIGRP 中

304 提示 因为 EIGRP 的度量相对复杂, 所以, 在重分布时, 需要分别指定带宽 延迟 可靠性 负载以及 MTU 参数的值 R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)#network R2(config-router)#redistribute eigrp 1 // 将 EIGRP 重分布到 RIP 中 R2(config-router)#default-metric 4 // 配置默认种子度量值 注意 在 redistribute 命令中用参数 metric 指定的种子度量值优先于在路由模式下使用 defarult-metric 命令设定的默认的种子度量值 (3) 步骤 3: 配置路由器 R3 R3(config)#router eigrp 1 R3(config-rotuer)#no auto-summary R3(config-router)#network R3(config-router)#network R3(config-router)#redistribute ospf 1 metric // 将 OSPF 重分布到 EIGRP 中 R3(config-router)#distance eigrp // 配置 EIGRP 默认管理距离 R3(config)#router ispf1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#redistribute eigrp 1 metric 30 metric-type 1 subnets // 将 EIGRP 重分到 OSPF 中 R3(config-router)#defaunlt-information originate always (4) 步骤 4: 配置路由器 R4 R4(config)#router ospf 1 R4(config-router)#router-id R4(config-router)#network area 0 R4(config-router)#network area 0 4. 实验调试 (1) 在 R1 上查看路由表 R1#show ip route

305 Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network C /24 is directly connected,seria0/0/ /24 is subnetted,1 subnets R [120/4]via ,00;00;08,Serial0/0/ /32 is subnetted,1 subnets R [120/4]via ,00;00;08,Serial0/0/0 C /24 is directly connected,serial0/0/1 R /24[120/4]via ,00;00;08,Serial0/0/0 R /24[120/4]via ,00;00;08,Serial0/0/0 S* /0 is directly connected,serial0/0/1 以上输出表明路由器 R1 通过 RIPv2 学到从路由器 R2 重分布进 RIP 的路由 (2) 在 R2 上查看路由表 R2#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network C /24 is directly connected,seria0/0/ /24 is subnetted,1 subnets D [120/4]via ,00;00;21,Serial0/0/ /32 is subnetted,1 subnets DEX [170/ ]via ,00;00;21,Serial0/0/1 C /24 is directly connected,serial0/0/1 DEX /24[170/ ]via ,00;00;21,Serial0/0/1 R* /0[120/3]via ,00;00;05,Serial0/0/0

306 以上输出表明从路由器 R1 上重分布进 RIP 的默认路由被路由器 R2 学习到, 路由代码为 R* ; 在路由器 R3 上重分布进来的 OSPF 路由也被路由器 R2 学习到, 路由代码为 DEX, 这也说明 EIGRP 能够识别内部路由和外部路由, 默认的时候, 内部路由的管理距离是 90, 外部路由的管理距离是 170 (3) 在 R3 上查看路由表 R3#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network DEX /24[150/ ]via ,00;13;43,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback /32 is subnetted,1 subnets O [110/65]via ,00;13;43,Serial0/0/0 C /24 is directly connected,serial0/0/1 C /24 is directly connected,serial0/0/0 D*EX /0[150/ ]via ,00;06;08,Serial0/0/1 以上输出表明, 从路由器 R2 上重分布进 EIGRP 的路由被路由器 R3 学习到, 默认路由代码为 D*EX, 同时,EIGRP 外部路由的管理距离被修改成 150 (4) 在 R4 上查看路由表 R4#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is to network O E /24[110/94]via ,00;25;26,Serial0/0/0

307 /24 is subnetted,1 subnets O E [110/94]via ,00;25;26,Serial0/0/ /32 is subnetted,1 subnets C is directly connected,loopback0 O E /24[110/94]via ,00;25;26,Serial0/0/0 C /24 is directly connected,serial 0/0/0 O*E /0[110/1]via ,00;25;26,Serial0/0/0 以上输出表明, 从路由器 R3 上重分布进 OSPF 的路由被路由器 R4 学习到, 路由代码为 O E1 ; 同时 R4 也学到了由 R3 注入的路由代码为 O E2 的默认路由 (5)show ip protocols R3#show ip protocols Routing Protocol is eigrpp 1 // 运行 AS 为 1 的 EIGRP 进程 Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Default networks flagged in outgoing updates Default networks accepted from incoming updates EIGRP metric weight K1=1,K2=0,K3=1,k4=0,k5=0 EIGRP maximum hopcount 100 EIGRP maximum metric variance 1 Redistributing;eigrp 1,ospf 1 (internal,external 1 & 2,nssa-external 1 & 2) // 将 OSPF 进程 1 重分布 EIGRP 中 EIGRP NSF-aware route hold timer is 240s Automatic network summarization is not in effect Maximum path;4 Routing for Netoworks; / Routing Informaition Sources; Gateway Distance Last Update ;51;05 Distance:internal 90 external 150 Routing Protocol is ospf 1 // 运行 OSPF 进程, 进程号为 1 Outgoing update filter list for all interfaces is not set Incoming update filter list for all interfaces is not set Router ID It is an autonomous system boundary router // 自治系统边界路由器 (ASBR) Redistributing External Routes from, eigrp 1 with metric mapped to 30,includes subnets in redistribution // 将 EIGRP1 重分布 OSPF 中

308 Number of areas in this router is 1.1 normal 0 stub 0 nssa Maximum path;4 Routing for Networks; area 0 Routing Information Sources; Gateway Distance Last Update ;58; ;58;42 Distance;(default is 110) 以上输出表明路由器 R3 运行了 EIGRP 和 OSPF 两种路由协议, 而且实现了双向重分布 20.3 实验 2:IS-IS 和 OSPF 重分布 1. 实验目的通过本实验可以掌握 : 1 直连路由的重分布 ; 2IS-IS 和 OSPF 的重分布 ; 3 重分布路由的查看和调试 2. 拓扑结构实验拓扑图如图 20-2 所示 图 20-2 IS-IS 和 OSPF 重分布 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#router isis R1(config-router)#net R1(config-router)#is-type level-2 only R1(config)#interface Loopback0 R1(config-if)#ip address

309 R1(config-if)#ip router isis R1(config)#interface Serial0/0/0 R1(config-if)#ip address R1(config-if)#ip router isis R1(config-if)#no shutdown (2) 步骤 2: 配置路由器 R2 R2(config)#router isis R2(config-router)#net R2(config-router)#is-type level-2-only R2(config-router)#redistribut ospf 1 metric 20 // 将 OSPF 重分布到 IS-IS 中 R2(config)#interface Loopback0 R2(config-if)#ip address R2(config-if)#ip router isis R2(config)#interface Serial0/0/0 R2(config-if)#ip address R2(config-if)#clockrate R2(config-if)#ip router isis R2(config-if)#no shutdown R2(config)#router ospf 1 R2(config-router)#router-id R2(config-router)#network area 1 R2(config-if)#redistribut isis level-2 metric 50 subnets // 将 IS-IS 重分布到 OSPF 中 技术要点 在重分布 IS-IS 路由协议的时候, 只能将 L1 和 L2 的路由重分布进来, 而运行 IS-IS 路由协议的本地接口是不能被重分布进来的, 要通过重分布直连才可以 本实验中, 如果不重分布直连, 那么,R3 和 R4 的路由表中将没有 的路由条目, 造成局部网络不可达 (3) 步骤 3: 配置路由器 R3 R3(config)#router ospf 1 R3(config-router)#router-id R3(config-router)#network area 0 R3(config-router)#network area 1 R3(config-router)#network area 0

310 (4) 步骤 4: 配置路由器 R4 R4(config)#ip prefix-list 1 seq 5 permit /24// 定义前缀列表 R4(config)#ip prefix-list 2 seq 5 permit /24 R4(config)#route-map conn permit 10 // 定义策略,21 章详细介绍 R4(config-route-map)#match ip address prefix-list 1 // 匹配条件 R4(config-route-map)#set metric 50 R4(config-route-map)#set metric-type type-1 R4(config)#router-map conn permit 20 R4(config-route-map)#match ip address prefix-list 2 R4(config-route-map)#set metric 100 R4(config)#router ospf 1 R4(config-route)#router-id R4(config-route)#network area 0 R4(config-route)#redistrbute connected subnets route-map conn // 将直连重分布到 OSPF 中 说明 1 路由器 R4 在重分布直连的环回接口时, 对 进行的控制是种子度量值设为 50, 度量值的类型为 1 而对 进行的控制是种子度量值设为 100, 度量值的类型采用默认, 即类型 2; 2 由于要重分布直连接口, 所以, 一定不能在 OSPF 的路由进程中通告 和 ; 3 前缀列表 (Prefix-list) 在路由过滤和路由控制中使用非常的广泛, 它比访问控制列表具有更大的灵活性, 匹配更加精确 4. 实验调试 (1) 在上查看路由表 R1#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set C /24 is directly connected,serial0/0/0

311 /24 is subetted,1 subnets C is directly connected,loopback /24 is subnetted,1 subnets il [115/20]via ,Serial0/0/ /32 is subnetted,1 subnets il [115/30]via ,Serial0/0/ /24 is subnetted,2 subnets il [115/30]via ,Serial0/0/0 il [115/30]via ,Serial0/0/0 il /24[115/30]via ,Serial0/0/0 il /24[115/30]via ,Serial0/0/0 以上输出表明路由器 R1 学到整个网络的路由信息, 其中路由条目 是 IS-IS 内部路由, 而其他的 i L2 路由条目全部是通过路由器 R2 重分布进来的 (2) 在 R2 上查看路由表 R2#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set C /24 is directly connected,serial0/0/ /24 is subetted,1 subnets il [115/20]via ,Serial0/0/ /32 is subnetted,1 subnets C is directly connected,loopback /32 is subnetted,1 subnets OIA [110/65]via ,00;00;27,Seriall0/0/0/ /24 is subnetted,2 subnets OE [110/178]via ,00;00;27,Serial0/0/1 OE [110/100]via ,00;00;27,Serial0/0/1 C /24 is directly connected,serial0/0/1 OIA /24[110/128]via ,00;00;27,Serial0/0/1 以上输出表明路由器 R2 既学到了 i L2 的路由, 又学到 OSPF 的 O IA 的路由, 也学到了从 R4 重分布进来的 O E2 路由 特别是对于 R4 两个环路接口的路由条目, 确实达到了预期的控制要求

312 (3) 在 R3 上查看路由表 R3#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set OE /24[110/20]via ,00;01;27,Serial0/0/ /24 is subnetted,1 subnets OE [110/50]via ,00;01;23,Serial0/0/ /24 is subnetted,1 subnets OE [110/50]via ,00;01;27,Serial0/0/ /24 is subnetted,1 subnets C is directly connected,loopback /24 is subnetted,2 subnets OE [110/114]via ,00;01;28,Serial0/0/0 OE [110/100]via ,00;01;28,Serial0/0/0 C /24 is directly connected,serial0/0/1 C /24 is directly connected,serial0/0/0 以上输出值得注意的是路由条目 和 , 如果在路由器 R2 上 OSPF 重分不得时候, 没有将直接连接口重分布进来, 那么, 路由器 R3 是不能收到这些路由条目 (4) 在 R4 上查看路由表 R4#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set

313 OE /24[110/20]via ,00;01;42,Serial0/0/ /24 is subnetted,1 subnets OE [110/50]via ,00;01;41,Serial0/0/ /24 is subnetted,1 subnets OE [110/20]via ,00;01;42,Serial0/0/ /32 is subnetted,1 subnets O [110/65]via ,00;01;42,Serial0/0/ /24 si subnetted,2 subnets C is directly connected,loopback0 C is directly connected,loopback1 OIA /24[110/128]via ,00;01;42,Serial0/0/0 C /24 is directly connected,serial0/0/0 以上输出表明路由器 R4 既学到了 OSPF 的 o 和 OIA 的路由, 也学到从 R2 重分布进来的 OE2 路由 20.4 路由重分布命令汇总 表 20-2 列出了本章涉及到的主要的命令 命令 show ip route show ip protocols redistribute default-metric ip prefix-list distance eigrp 表 20-2 本章命令汇总作用查看路由表查看和路由协议相关的信息配置路由协议重分布配置默认种子度量值定义前缀列表配置 EIGRP 默认管理距离

314 第 21 章 路由优化 在当今高性能的网络中, 为了保证网络的伸缩性 稳定性 安全性和快速收敛, 必须对网络进行优化 路由过滤和策略路由是路由优化的常用方法 21.1 路由优化概述 路由过滤是指在路由更新中抑制某些路由不被发送和接收, 被动接口 分布控制列表和重分布结合路由策略等都可以实现路由过滤 策略路由提供了根据网络管理者指定的标准来进行数据包转发的一种机制 基于策略的路由比传统路由能力更强, 使用更灵活, 它使网络管理者不仅能够根据目的地址来选择转发路径, 而且能够根据协议类型 报文大小 应用或 IP 源地址来选择转发路径 策略路由的策略由路由映射图 (Route Map) 来定义 Route Map 命令中最为重要的是 Match 和 Set Match 用来定义匹配的条件, 匹配语句在路由器的输入端口对数据包进行检测 常用匹配条件包括 IP 地址 接口 度量值以及数据包长度等 Set 定义对符合匹配条件的语句采取的行为 通常的行为如表 21-1 所示 表 21-1 Set 的行为 Ser 行为描述 Set ip next hop 设置数据包的下一跳 Set interface 设定数据包出口接口 Set ip default next hop 设定默认的下一跳地址, 用于当路由表里没有到数据包目的的地址路由条目时 Set default interface 设定默认的接口 Set ip tos 设定 IP 数据包的 IP ToS 值 Set ip precedence 设定 IP 数据包的优先级 注意 1 第一 Route map 最后默认 Deny Any 这个 Deny 的使用结果依赖于这个 Route Map 是怎样使用的 如果一个数据包对于 Route Map 没有匹配项, 它会按照正常的目的地址路由转发, 而对于路由条目如果 Route Map 没有匹配项, 则被拒绝 ; 2 一个 Route Map 可以包含多哥 Route Map 陈述, 这些语句的执行顺序像 ACL 一样, 从上到下被执行

315 21.2 实验 1: 用分布控制列表控制路由更新 1. 实验目的通过本实验可以掌握 : 1 被动接口的配置 ; 2 分布控制列表的配置 2. 拓扑结构实验拓扑图 21-1 所示 图 21-1 用分布控制列表控制路由更新本实验通过使用分布列表控制路由器 R1 只发送环回接口中第 3 位为奇数的路由和 g0/0 接口的路由更新给 R2, 整个网络运行 RIPv2 路由协议 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(congfig)#access-list 1 permit R1(congfig)#access-list 1 permit // 允许第三为奇数的路由 R1(congfig)#router rip R1(congfig-router)#version 2 R1(congfig-router)#no auto-summary R1(congfig-router)#network R1(congfig-router)#network R1(congfig-router)#network R1(congfig-router)#passive-interface default // 默认为被动接口 R1(congfig-router)#no passive-interface Serial0/0/0 R1(congfig-router)#distribute-list 1 out Serial0/0/0 注意 distribute-list 命令可以全局地在一个出域入方向的路由更新中过滤路由, 也可以为一个路由进程所涉及到的每一个接口的入方向或出方向设置路由过滤

316 (2) 步骤 2: 培植路由器 R2 R2(config)#router rip R2(config-router)#version 2 R2(config-router)#no auto-summary R2(config-router)#network R2(config-router)#network 实验调试 (1) 在 R2 上查看路由表 R1#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospf inter area N1-OSPF NSSA external type 1,N2-OSPF NSSA external type 2 E1-OSPF external type 1,E2-OSPF external type 2 i-is-is,l1-is-is level-1,l2-is-is level-2,ia -IS-IS inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set C R R R R C R /24 is directly connected,serial0/0/ /24 is subnetted,4 subnets [120/1]via ,00;00;01,Serial0/0/ [120/1]via ,00;00;01,Serial0/0/ [120/1]via ,00;00;01,Serial0/0/ [120/1]via ,00;00;01,Serial0/0/ /24 is subnetted,1 subnets is directly connected,loopback /24 is subnetted,1 subnets [120/1]via ,00;00;01,Serial0/0/0 以上输出表明路由器 R2 只收到 R11 的以太口第 3 位奇数的环回接口的路由 (2)show ip protocols R1#show ip protocols Routing Protocol is rip Sending updates every 30 seconds,next due in 2 seconds Invalid after 180 seconds,hold down 180,flushed aftr 240 Outgoing update filter list for all interfaces is not set

317 Serial0/0/0 filtred by 1 (per-user),default is 1 Incoming update filter list for all interfaces is not set Redistributing;rip Default version control;send version 2,receive version 2... 以上输出信息表明, 全局下没有作用分布控制列表, 在 s0/0/0 接口的出方向作用了分布控制列表 策略路由 实验 2: 基于源 ip 地址的策略路由 1. 实验目的 通过本实验可以掌握 : 1 用 Route-map 定义路由策略 ; 2 在接口下应用路由策略 ; 3 基于源 IP 地址的策略路由的调试 2. 拓扑结构 实验拓扑图如图 21-2 所示 图 21-2 基于源 IP 地址的策略路由 本实验设计如下 : 在路由器 R1 的 g0/0 接口应用 IP 策略路由 CCNA, 使得从主机 A 来的数据设置下一跳地址为 ; 从主机 B 数据设置下一跳地址为 , 所有其他的数据包正常转发, 整个网络运行 EIGRP 路由的协议 3. 实验步骤 具体步骤 : 配置路由器 R1: R1(config)#access-list 1 permit R1(config)#access-list 2 permit

318 R1(config)#route-map CCNA permit 10 R1(config-route-map)#match ip address 1 R1(config-route-map)#set ip next-hop R1(config)#route-map CCNA permit 20 R1(config-route-map)#match ip address 2 R1(config-route-map)#set ip next-hop R1(config)#interface g0/0 R1(config-if)#ip policy route-map CCNA R1(config)#router eigrp 1 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#network R1(config-router)#network 实验调试 1 在主机 A 上 ping 地址 , 路由器 R1 上显示的调试信息如下 R#debug ip policy *Feb 20 00;18;33;368;IP;s= (GigabitEthernet0/0),d= ,len 60,policy match *Feb 20 00;18;33;368;IP;route map CCNA,item 10,permit *Feb 20 00;18;33;372;IP;s= (GigabiEthernet0/0),d= (Serial0/0/0),len 60,policy routed *Feb 20 00;18;33;381;IP;GigabitEthernet0/0 to Serial0/0/ 以上输出信息表明源地址为 的主机发送给目的的主机 的数据包在接口 GigabitEthernet0/0 匹配 route-map CCNA 的序列号 10 所定义的策略, 执行策略路由, 设置数据包一下跳地址为 在主机 B 上 ping 地址 , 路由器 R1 上显示的调试信息如下 *Feb 20 00;21;12;449;IP;s= (GigabitEthernet0/0),d= ,len 60,policy match *Feb 20 00;21;12;449;IP;route map CCNA,item 20,permit *Feb 20 00;21;12;453;IP;s= (GigabiEthernet0/0),d= (Serial0/0/0),len 60,policy routed *Feb 20 00;21;12;453;IP;GigabitEthernet0/0 to Serial0/0/ 以上输出信息表明源地址为 的主机发送给目的的主机 的数据包在接口

319 GigabitEthernet0/0 匹配 route-map CCNA 的序列号 20 所定义的策略, 执行策略路由, 设置数据包一下跳地址为 在主机 上 ping 地址 , 路由器 R1 上显示的调试信息如下 *Feb 20 forwarding 00;14;17;416;IP;s= (GigabitEthernet0/0),d= (Serial0/0/0),len 60, policy rejected -- normal 以上输出信息表明源地址为 的主机发送到目的主机 数据包在接口 GigabitEthernet0/0 不匹配路由策略, 数据包正常转发 (4)show ip policy 该命令显示了在哪些接口上应用了哪些策略 R1#show ip policy Interface Route map Gi0/0 CCNA 以上输出信息表明在 Gi0/0 接口应用了路由策略 CCNA 实验 3: 基于报文大小的策略路由 1. 实验目的 通过本实验可以掌握 : 1 用 route-map 定义路由策略 ; 2 在接口下应用路由策略 ; 3 基于报文大小的策略路由的调试 2. 拓扑结构 实验拓扑图如图 21-3 所示 图 21-3 基于报文大小的策略路由 本实验设计如下 : 在路由器 R1 的 g0/0 接口应用 IP 策略路由 CCNP, 使得对大小的 64~100 字节的数据包设置出接口为 S0/0/0; 大小为 101~1000 字节的数据包设置出接口为 s0/0/1, 所有其他的数据包正常转发, 整个网络运行 EIGRP 路由协议 3. 实验步骤 步骤 : 配置路由器 R1: R1(config)#route-map CCNP permit 10 R1(config-route-map)#match length R1(config-route-map)#set interface s0/0/0 R1(config)#route-map CCNP permit 20

320 R1(config-route-map)#match length R1(config-route-map)#set interface s0/0/1 R1(config)#intrface g0/0 R1(config-if)#ip policy route-map CCNP R1(config)#router eigrp 1 R1(config-route)#network R1(config-route)#network R1(config-route)#network 注意 在接口下应用的策略路由对路由器本地产生的数据包不起作用, 如果需要对本地路由器产生的数据包执行策略路由, 要用 ip local policy route-map 命令配置本地策略 4. 实验调试 1 执行扩展 ping 命令, 数据包的长度为 90, 源地址为 ( 路由器 R3 的以太口地址 ): R3#ping Protocol[ip] Target IP address; Repeat count[5];1 Datagram size[100];90 Timeout in seconds [2]; Extended commands [n];y Source address or interface; Type of service[0]; Set DF bit in IP header?[no]; Validate reply data?[no]; Data pattern[0xabcd]; Loose,Strict,Record,Timestamp,Verbose[none]; Sweep range of sizes[n]; Type escape sequence to abort. Sending 1,90-byte ICMP Echos to ,timeout is 2 seconds; Packet sent with a source address of 路由器 R1 上显示的调试信息如下 : R#debug ip policy *Feb 20 20;57;06;535;IP;s= (GigabitEthernet0/0),d= ,len 90,FIB policy match *Feb 20 20;57;06;535;IP;s= (GigabitEthernet0/0),d= (Serial0/0/0),len 90,FIB policy routed

321 以上输出信息表明长度为 90 字节的数据包在接口 GigabitEthernet0/0 匹配策略, 执行策略路由, 设置数据包出接口为 S0/0/0 2 执行扩展 ping 命令, 数据包长度为 300, 源地址 : R3#ping Protocol[ip] Target IP address; Repeat count[5];1 Datagram size[100];300 Timeout in seconds [2]; Extended commands [n];y Source address or interface; Type of service[0]; Set DF bit in IP header?[no]; Validate reply data?[no]; Data pattern[0xabcd]; Loose,Strict,Record,Timestamp,Verbose[none]; Sweep range of sizes[n]; Type escape sequence to abort. Sending 1,90-byte ICMP Echos to ,timeout is 2 seconds; Packet sent with a source address of 路由器 R1 上显示的调试信息如下 : R#debug ip policy *Feb 20 20;58;39;311;IP;s= (GigabitEthernet0/0),d= ,len 300,FIB policy match *Feb 20 20;58;39;311;IP;s= (GigabitEthernet0/0),d= (Serial0/0/1),len 300,FIB policy routed 以上输出信息表明长度为 300 字节的数据包在接口 GigabitEthernet0/0 匹配策略, 执行策略路由, 设置数据包出接口为 S0/0/1 3 执行扩展 ping 命令, 数据包长度为 1200, 源地址 : R3#ping Protocol[ip] Target IP address; Repeat count[5];1 Datagram size[100];1200 Timeout in seconds [2]; Extended commands [n];y Source address or interface; Type of service[0]; Set DF bit in IP header?[no]; Validate reply data?[no];

322 Data pattern[0xabcd]; Loose,Strict,Record,Timestamp,Verbose[none]; Sweep range of sizes[n]; Type escape sequence to abort. Sending 1,90-byte ICMP Echos to ,timeout is 2 seconds; Packet sent with a source address of 路由器 R1 上显示的调试信息如下 : R#debug ip policy *Feb 20 21;01;20;538;IP;s= (GigabitEthernet0/0),d= ,len 1200,FIB policy rejected(nomatch)-normal forwarding 以上输出信息表明长度为 1200 字节的数据包在接口 GigabitEthernet0/0 不匹配路由策略, 数据包转发正常转发 4show route-map; 该命令显示定义的所有路由策略及路由策略匹配的情况 R1#show route-map route-map CCNP,permit,sequence 10 Match clauses; length Set clauses; interface Serial0/0/0 Policy routing matches;3 packets,292 bytes route-map CCNP,permit,sequence 20 Match clauses; length Set clauses; interface Serial0/0/1 Policy routing matches;1 packets,314 bytes 5show ip policy; R1#show ip policy Interface Route map local CCNP Gi0/0 CCNP 以上输出信息表明接口 Gi0/0 和本地应用了路由策略 CCNP 实验 4: 基于应用的策略路由 1. 实验目的 通过本实验可以掌握 : 1 用 route-map 定义路由策略 ;

323 2 在接口下应用策略 ; 3 基于应用的策略路由的调试 3. 拓扑结构 实验拓扑图如图 21-4 所示 图 21-4 基于应用的策略路由 本实验设计如下 : 在路由器 R1 的 g0/0 接口应用 IP 策略路由 CCIE, 使得对 HTTP 数据包设置下一跳地址为 , 并且设置 IP 数据包优先级为 FLASH, 为 Telnet 数据包设置下一跳地址为 , 并且设置 IP 数据包优先级为 critical, 所有其他的数据包正常转发, 整个网络运行 EIGRP 路由协议 3. 实验步骤 (1) 步骤 : 配置路由器 R1 R1(config)#ip access-list extended HTTP R1(config-ext-nacl)#permit tcp any any eq 80 R1(config)#ip acceess-list extended TELNET R1(config-ext-nacl)#permit tcp any any eq 23 R1(config)#route-map CCIE permit 10 R1(config-route-map)#match ip address HTTP R1(config-route-map)#set ip precedence flash R1(config-route-map)#set ip next-hop R1(config)#route-map CCIE permit 20 R1(config-route-map)#match ip address HTTP R1(config-route-map)#set ip precedence flash R1(config-route-map)#set ip next-hop R1(config)#interface g0/0 R1(config-if)#ip policy route-map CCIE R1(config)#ip local policy route-map CCIE R1(config)#router eigrp 1 R1(config-router)#no auto-summary R1(config-router)#network R1(config-router)#network

324 R1(config-router)#network (2) 步骤 2: 匹配路由器 R2 R2(config)#router eigrp 1 R2(config-router)#network R2(config-router)#network R2(config-router)#network R2(config-router)#no auto-summary R2(config)#ip http server R2(config)#line vty 0 4 R2(config-line)#no login R2(config-line)#privilege level 实验调试 1 在主机 A 上访问 的 HTTP 服务, 路由器 R1 上显示的调试信息如下 : R1#debug ip policy *Feb 20 22;32;44;407;IP;s= (GigabitEthernet0/0),d= ,len 48,FIB policy match *Feb 20 22;32;44;407;IP;s= (GigabitEthernet0/0),d= ,g= ,len 48,FIB policy routed 以上输出信息表明 HTTP 的数据包在接口 GigabitEthernet0/0 匹配策略, 执行策略路由, 设置数据包下一跳地址为 在主机 A 上访问 的 Telnet 服务, 路由器 R1 上显示的调试信息如下 : R1#debug ip policy *Feb 20 22;29;28;127;IP;s= (GigabitEthernet0/0),d= ,len 43,FIB policy match *Feb 20 22;29;28;131;IP;s= (GigabitEthernet0/0),d= ,g= ,len 43,FIB policy routed 以上输出信息表明 Telnet 的数据包在接口 GigabitEthernet0/0 匹配策略, 执行策略路由, 设置数据包下一跳地址为 在主机 A 上访问 的 Telnet 服务, 路由器 R1 上显示的调试信息如下 : *Feb 20 22;35;12;431;IP;s= (FastEthernet0/0),d= ,len 100,FIB policy rejected(nomatch)-normal forwarding 以上输出表明 ping 的数据包在接口 GigabitEthernet0/0 不匹配路由策略, 数据包正常转发 21.4 路由优化命令汇总 表 21-2 列出了本章涉及到的主要命令

325 表 21-2 本章命令汇总 命令 Show ip policy Show route-map Debug ip policy Passive-interface Distribute-list Route-map Match Set Ip policy route-map Ip local policy route-map 作用查看策略路由及作用的接口查看定义的所有路由策略及路由策略匹配的情况动态查看策略路由路由的匹配情况配置被动接口配置分布控制列表定义路由策略定义匹配的条件定义对符合匹配条件的语句采取的行为应用路由策略本地应用路由策略

326 第 22 章 IPv6 无论是 NAT, 还是 CIDR 等都是缓解 IP 地址短缺的手段, 而 IPv6 才是解决地址短缺的最终方法 IPv6 是由 IETF 设计的下一代 Internet 协议, 目的是取代现有的 Internet 协议 IPv IPv6 概述 IPV6 优点 IPv4 的设计思想成功地造就了目前的国际 Internet, 其核心价值体现在简单 灵活和开放性 但随着新应用的不断涌现, 传统的 IPv4 协议已经难以支持 Internet 的进一步扩张和新业务的特性, 如时应用和服务质量保证等 IPv6 能够解决 IPv4 存在的许多问题, 如地址短缺和服务质量保证等 同时 IPv6 还对 IPv4 进行了大量的改进, 包括由和网络自幼配置等 IPv6 和 IPv4 将在过渡期内存几年, 并由 IPv6 渐渐取代 IPv4 IPv6 的特点如下 : 1128 比特的地址方案为将来数十年提供了足够的地址空间 ; 2 充足的地址空间将极大地满足那些伴随着网络智能设备的出现而对地址增加的需求, 例如个人数据助理 移动电话和家庭网络接入设备等 ; 3 多等级编址层次有助于路由聚合, 提高了路由选择的效率和可扩展性 ; 4 自幼配置使得在 Internet 上大规模布置新设备成为可能 ; 5ARP 广播被本地链路多播代替 ; 6IPv6 对数据包头进行了简化, 以减少处理器开销节省网络带宽 ; 7IPv6 中流标签字段可以提供流量区域 ; 8IPv6 的组播可以区分永久性与临时性地址, 更有利于组播功能的实现 ; 9IPv6 地址本身的分层体系更加支持域名解析体系中得制集聚和地址更改 ; 10IPv6 协议内置安全机制并已经标准化 ; (11)IPv6 协议能更好地支持移动性 ; (12)IPv6 提供了更加优秀的 QoS 保障 ; (13)IPv6 中没有广播地址, 它的功能正在被组播地址所代替 IPv6 地址 IPv4 地址表示为点分十进制数据格式, 而 IPv6 采用冒号十六进制数据格式 例如 : 2007;00dd3;0000;2F3B;02BB;00FF;FE28;2000 是一个完整的 IPv6 地址

327 提示 1IPv6 地址中每个 16 位分组的前导零位可以去除做简化表示 ; 2 可以将冒号分十六进制数据格式中相邻的连续零位合并, 用双冒号 表示 ; 3 要在一个 URL 中使用文本 IPv6 地址, 文本地址应该用符号 [ 和 ] 来封闭 IPv6 地址 3 种类型 : 单播 任意播和组播, 在每种地址中, 又有一个种或者多种类型的地址, 如单播有本地链路地址 本地站点地址 可聚合全球地址 回环地址和末指定地址 ; 任意播有本地链路地址 本地站点地址和可聚合全球地址 ; 多播有指定地址和请求节点地址 下面主要介绍几个常用地址类型 (1) 本地链路地址在一个节点上起用 IPv6 协议栈, 当启动时, 节点的每个接口自动配置一个本地, 前缀为 FE80V /10 (2) 本地站点地址本地站点地址与 RFC1918 所定义的私有 IPv4 地址空间类似, 因此, 本地站点地址不能在全球 IPv6 Internet 上路由, 前缀为 FEC0 /10 (3) 可聚合全球单播地址 IANA 分配 IPv6 寻址空间中的一个 IPv6 地址前缀作为可聚合全球单播地址 (4)IPv4 兼容地址与 IPv4 兼容的 IPv6 地址是由过度机制使用的特殊单播 IPv6 地址, 目的是在主机和路由器上自动创建 IPv4 隧道以上 IPv4 网络传送 IPv6 数据包 (5) 回环地址单播地址 0;0;0;0;0;0;0;1 称为回环地址, 节点用它来向自身发送 IPv6 包 它不能分配给任何物理接口 (6) 不确定地址单播地址 0;0;0;0;0;0;0;0 称为不确定地址, 它不能分配给任何节点 (7) 多播指定地址 RFC2373 在多播范围内为 IPv6 协议的操作定义和保留了几个 IPv6 地址, 这些保留地址称为多播指定地址 (8) 请求节点地址对于节点或路由器的接口上配置每个单播和任意播地址, 都自动启动一个对应的被请求节点地址 被请求节点地址手限于本地链路 22.2 IPv6 路由 实验 1:IPv6 静态路由 1. 实验目的 通过本实验可以掌握 :

328 1 启用 IPv6 流量转发 ; 2 配置 IPv6 地址 ; 3IPv6 景泰路由配置和调试 ; 4IPv6 默认路由配置和调试 2. 实验拓扑图如图 22-1 所示 图 22-1 IPv6 静态路由 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#ipv6 unicast-routing R1(config)#interface Loopback0 R1(config-if)#ipv6 address 2006;AAAA 1/64 R1(config)#interface Loopback1 R1(config-if)#ipv6 address 2006;BBBB 1/64 R1(config)#interface Serial0/0/0 R1(config-if)#ipv6 address 2007;CCCC 1/64 R1(config-if)#no shutdown R1(config)#ipv6 address 2008;DDDD /64 Serial0/0/0 // 配置 IPv6 静态路由 (2) 步骤 2: 配置路由器 R2 R2(config)#ipv6 unicast-routing R2(config)#interface Loopback0 R2(config-if)#ipv6 address 2008;DDDD 1/64 R2(config)#interface Loopback1 R2(config-if)#ipv6 address 2008;CCCC 1/64 R2(config)#interface Serial0/0/0 R2(config-if)#ipv6 address 2007;CCCC 1/64 R2(config-if)#clockrate R2(config-if)#no shutdown R2(config)#ipv6 route /0 Serial0/0/0 配置 IPv6 默认路由

329 4. 实验调试 (1)show ipv6 interface 该命令来查看 IPv6 的接口信息 R1#show ipv6 interface s0/0/0 Serial0/0/0 is up,line protocol is up IPv6 is enabled,link-local address is FE80 C800;BFF;FE80;0 // 本接口启用 IPv6, 本地链路地址自动配置 Global unicast address(es); 2007;CCCC 1,subnet is 2007;CCCC /64 // 全球聚合地址 Joined group address(es); FF02 1 // 表示本地链路上的所有节点和路由器 FF02 2 // 表示本地链路上的所有路由器 FF02 1;FF00;1 // 用于替换 ARP 机制的被请求节点的多播地址 FF02 1FF80;0 // 与单播地址 2007;CCCC 1 相关的被请求节点多播地址 MTU is 1500 bytes ICMP error messages limited to one every 100 milliseconds ICMP redirects are enabled // 启用 ICMP 重定向 ND DAD is enabled,number of DAD attempts;1 // 邻居发现和重复地址检测启动 ND reachable time is miliseconds //ND 可达时间 Hosts use stateless autoconfig for addresses. // 使用无状态自动配置地址 (2)show ipv6 route 该命令用来查看 IPv6 路由表 R1#show ipv6 route IPv6 Routing Table - 9 entries Codes;C - Connectd,L - Local,S - Static,R -RIP,B - BGP U - Per-user Static route,m - MIPv6 I1- ISIS L1,I2-ISIS L2,IA-ISIS interarea,is-isis summary O - OSPF intra,o1-ospf inter,oe1-ospf ext 1,OE2-OSPF ext 2 ON1 -OSPF NSSA ext 1,ON2-OSPF NSSA ext 2

330 D - EIGRP,EX - EIGRP external C 2006;AAAA /64[0/0] via,loopback0 L 2006;AAAA /128[0/0] via,loopback0 C 2006;BBBB /64[0/0] via,loopback1 L 2006;BBBB /128[0/0] via,loopback1 C 2007;CCCC /64[0/0] via,serial0/0/0 L 2007;CCCC /128[0/0] via,serial0/0/0 S 2008;DDDD /64[0/0] via,serial0/0/0 L FE80 /10[0/0] via Null0 L FF00 /8[0/0] via Null0 R2#show ipv6 route IPv6 Routing Table - 9 entries Codes;C - Connectd,L - Local,S - Static,R -RIP,B - BGP U - Per-user Static route,m - MIPv6 I1- ISIS L1,I2-ISIS L2,IA-ISIS interarea,is-isis summary O - OSPF intra,o1-ospf inter,oe1-ospf ext 1,OE2-OSPF ext 2 ON1 -OSPF NSSA ext 1,ON2-OSPF NSSA ext 2 D - EIGRP,EX - EIGRP external S /0[1/0] via,serial0/0/0 C 2007;CCCC /64[0/0] via,serial0/0/0 L 2007;CCCC 2/128[0/0] via,serial0/0/0 C 2008;DDDD /64[0/0] via,loopback0 L 2008;DDDD 2/128[0/0] via,loopback0 L FE80 /10[0/0] via,null0 L FF00,Null0

331 以上输出表明路由器 R1 上有一条 IPv6 的静态路由,R2 上有一条 IPv6 的静态路由,R2 上有一条 IPv6 的默认路由, IPv6 中的默认路由是没有 * 的 (3)ping R2#ping ipv6 2006;AAAA 1 Type escape sequence to abort Sending 5,100-byte ICMP Echos to 2006;AAAA 1,timeout is 2 seconds;!!!!! Success rat is 100 percent (5/5),round-trip min/avg/max=24/72/124 ms 实验 2:IPV6 RIPng 实验目的 通过本实验可以掌握 : 1 启用 IPv6 流量转发 ; 2 向 RIPng 网络注入默认路由 ; 3RIPng 配置和调试 2. 拓扑结构 实验拓扑图如图 22-2 所示 图 22-2 IPv6 RIPng 配置 3. 实验步骤 (1) 步骤 1: 配置路由器 R1 R1(config)#ipv6 unicast-routing R1(config)#ipv6 router rip cisco // 启用 IPv6 RIPng 进程 R1(config-rtr)#Split-horizon // 起用水平分割 R1(config-rtr)#poison-reverse // 启用毒化反转 R1(config)#interface Loopback0 R1(config-if)#ipv6 address 2006;1111 1/64 R1(config-if)#ipv6 rip cisco enable // 在接口上启用 RIPng R1(config)#interface Serial0/0/0 R1(config-if)#ipv6 address 2007;12 1/64

332 R1(config-if)#ipv6 rip cisco enable R1(config-if)#ipv6 rip cisco default-information originate // 向 IPv6 RIPng 区域注入一条默认路由 ( /0) R1(config-if)#no shutdown R1(config)#ipv6 route /0 Loopback0 // 配置默认路由 提示 ipv6 rip cisco default-information only 命令也可以向 IPv6 RIPng 区域注入一条默认路由, 但是该命令只从该接口发送默认的 IPv6 路由, 而该接口其他的 IPv6 的 RIPng 路由都被抑制了 (2) 步骤 2: 配置路由器 R2 R2(config)#ipv6 unicast-routing R2(config)#ipv6 router rip cisco R2(config-rtr)#split-horzon R2(config-rtr)#poison-reverse R2(config)#interface Serial0/0/0 R2(config-if)#ipv6 address 2007;12 2/64 R2(config-if)#ipv6 rip cisco enable R2(config-if)#clock rate R2(config-if)#no shutdown R2(config)#interface Serial0/0/1 R2(config-if)#ipv6 address 2007;23 2/64 R2(config-if)#ipv6 rip cisco enable R2(config-if)#clock rate R2(config-if)#no shutdown (3) 步骤 3: 配置路由器 R3 R3(config)#ipv6 unicast-routing R3(config)#ipv6 router rip cisco R3(config-rtr)#split-horzon R3(config-rtr)#poison-reverse R3(config)#interface Serial0/0/0 R3(config-if)#ipv6 address 2007;34 3/64 R3(config-if)#ipv6 rip cisco enable R3(config-if)#clockrate R3(config-if)#no shutdown R3(config)#interface Serial0/0/1 R3(config-if)#ipv6 address 2007;23 3/64 R3(config-if)#ipv6 rip cisco enable

333 R3(config-if)#no shutdown (4) 步骤 4: 配置路由器 R4 R4(config)#ipv6 unicast-routing R4(config)#ipv6 router rip cisco R4(config-rtr)#split-horzon R4(config-rtr)#poison-reverse R4(config)#interface Loopback0 R4(config-if)#ipv6 address 2008;4444 4/64 R4(config-if)#ipv6 rip cisco enable R4(config)#interface Serial0/0/0 R4(config-if)#ipv6 address 2007;34 4/64 R4(config-if)#ipv6 rip cisco enable R4(config-if)#no shutdown 4. 实验调试 (1)show ipv6 route R2#show ipv6 route IPv6 Routing Table - 9 entries Codes;C - Connectd,L - Local,S - Static,R -RIP,B - BGP U - Per-user Static route,m - MIPv6 I1- ISIS L1,I2-ISIS L2,IA-ISIS interarea,is-isis summary O - OSPF intra,o1-ospf inter,oe1-ospf ext 1,OE2-OSPF ext 2 ON1 -OSPF NSSA ext 1,ON2-OSPF NSSA ext 2 D - EIGRP,EX - EIGRP external R /0 [120/2] via FE80 C800;AFF;FE90;0,Serial0/0/0 R 2006;1111 /64[120/2] via FE80 C800;AFF;FE90;0,Serial0/0/0 C 2007;12 /64[0/0] via,serial0/0/0 L 2007;12 2/128[0/0] via,serial0/0/1 C 2007;12 /64[0/0] via,serial0/0/0 L 2007;12 2/128[0/0] via,serial0/0/1 R 2007;34 /64[120/2] via FE80 C802;AFF;FE90;0,Serial0/0/1

334 R 2008;4444 /64[120/3] via FE80 C802;AFF;FE90;0,Serial0/0/1 L FE80 /10[0/0] via,nnll0 L FF00 /8[0/0] via,nnll0 以上输出表明 R1 确实向 IPv6 RIPng 网络注入一条 IPv6 的默认路由, 同时收到 3 条 IPv6 RIPng 路由条目, 而且所有 IPv6 RIPng 路由条目的下一跳地址均为邻居路由器接口的 Iink-local 地址 可以通过 show ipv6 rip next-hops 命令查看 RIPng 的下一跳地址 R2#show ip ipv6 next-hops RIP process cisco,next Hops FE80 C800;AFF;FE90;0/Serial0/0/0[3 patahs] FE80 C802;AFF;FE90;0/Serial0/0/1[3 patahs] (2)show IP Protocols R2#show ipv6 protocols IPv6 Routing Protocol is connected IPv6 Routing Protocol is static IPv6 Routing Protocol is rip cisco Interfaces; Serial0/0/1 Serial0/0/0 Redistribution; None 以上输出表明启动的 IPv6 RIPng 进程为 Cisco, 同时在 Serial0/0/1 和 Serial0/0/1 接口上启用 RIPng (3)show ipv6 rip database 该命令用来查看 RIPng 的数据库 R2#show ipv6 rip database RIP process cisco RIB 2006;1111 /64,metric 2,installed Serial0/0/0FE80 C800;AFF;FE90;0,expires in 178 secs 2007;12 /64,metric 2 Serial0/0/0FE80 C800;AFF;FE90;0,expires in 178 secs 2007;23 /64,metric 2 Serial0/0/1FE80 C802;AFF;FE90;0,expires in 168 secs 2007;34 /64,metric 2,installed Serial0/0/1FE80 C802;AFF;FE90;0,expires in 168 secs

335 2008;4444 /64,metric 3,installed Serial0/0/1FE80 C802;AFF;FE90;0,expires in 168 secs /0,metric 2,installed Serial0/0/0FE80 C800;AFF;FE90;0,expires in 178 secs 以上输出显示了 R2 的 RIPng 的数据库 (4)debug ipv6 rip 该命令用来动态查看 RIPng 的更新 R2#debug ipv6 rip RIP Routing Protocol debugging is on R2#debug ipv6 route * *Feb 15 14;17;34.851;RIPng;Sending multicast update on Serial0/0/1 for cisco *Feb 15 14;17;34.851; src=fe02 C801;AFF;FE90;0 *Feb 15 14;17;34.855; dst=fe02 9(Serial0/0/1) *Feb 15 14;17;34.855; sport=521,dport=521,length=92 *Feb 15 14;17;34.859; command=2,version=1,mbz=0,#rte=4 *Feb 15 14;17;34.859; tag=0,metric=2,prefix=2006;1111 /64 *Feb 15 14;17;34.859; tag=0,metric=1,prefix=2007;12 /64 *Feb 15 14;17;34.863; tag=0,metric=1,prefix=2007;23 /64 *Feb 15 14;17;34.853; tag=0,metric=1,prefix= /0 *Feb 15 14;17;34.867;RIPng;Sending multicast update on Serial0/0/1 for cisco *Feb 15 14;17;34.867; src=fe80 C801;AFF;FE90;0 *Feb 15 14;17;34.871; dst=fe02 9(Serial0/0/0) *Feb 15 14;17;34.871; sport=521,dport=521,length=92 *Feb 15 14;17;34.871; command=2,version=1,mbz=0,#rte=4 *Feb 15 14;17;34.875; tag=0,metric=1,prefix=2007;12 /64 *Feb 15 14;17;34.875; tag=0,metric=1,prefix=2007;23 /64 *Feb 15 14;17;34.879; tag=0,metric=2,prefix=2007;34 /64 *Feb 15 14;17;34.879; tag=0,metric=3,prefix=2008;4444 /64 *Feb 15 14;17;43.439;RIPng;response received from FE80 C800;AFF;FE90;0 on Serial0/0/0 for cisco *Feb 15 14;17;43.443; src=fe80 C801;AFF;FE90;0(Serial0/0/0) *Feb 15 14;17;43.443; dst=fe02 9 *Feb 15 14;17;43.447; sport=521,dport=521,length=72 *Feb 15 14;17;43.447; command=2,version=1,mbz=0,#rte=3 *Feb 15 14;17;43.447; tag=0,metric=1,prefix=2007;1111 /64 *Feb 15 14;17;43.871; tag=0,metric=1,prefix=2007;12 /64 *Feb 15 14;17;43.451; tag=0,metric=1,prefix= /0 *Feb 15 14;17;57.815;RIPng;response received from FE80 C802;AFF;FE90;0 on Serial0/0/1 for cisco *Feb 15 14;17;57.819; src=fe80 C802;AFF;FE90;0(Serial0/0/1) *Feb 15 14;17;57.819; dst=fe02 9 *Feb 15 14;17;57.823; sport=521,dport=521,length=72

336 * Feb 15 14;17;57.823; command=2,version=1,mbz=0,#rte=3 *Feb 15 14;17;57.823; tag=0,metric=1,prefix=2007;23 /64 *Feb 15 14;17;57.827; tag=0,metric=1,prefix=2007;34 /64 *Feb 15 14;17;57.827; tag=0,metric=2,prefix=2008;4444 /64 以上输出显示路由器 R2 发送和接收 RIPng 的信息 实验 3:OSPFv3 1. 实验目的 通过本实验可以掌握 : 1 启用 IPv6 流量转发 ; 2 向 OSPFv3 网络注入默认路由 ; 3OSPFv3 多区域配置和调试 2. 拓扑结构 实验拓扑图 22-3 所示 图 22-3 OSPFv3P 配置 3. 实验步骤 (1) 步骤 : 配置路由器 R1 R1(config)#ipv6 unicast-routing R1(config)#ipv6 router ospf 1 // 启用 OSPFv3 路由进程 R1(config-rtr)#router-id // 定义路由器 ID R1(config-rtr)#default-information originate metric 30 metric-type 2 // 向 OSPFv3 网络注入一条默认路由 R1(config)#interface Serial0/0/0 R1(config-if)#ipv6 address 2007;12 1/64 R1(config-if)#ipv6 ospf 1 area 1 // 接口上启用 OSPFv3, 并声明接口所在区域 R1(config-if)no shutdown

337 R1(config)#ipv6 route /0 s0/0/1 // 配置默认路由 (2) 步骤 : 配置路由器 R2 R2(config)#ipv6 unicast-routing R2(config)#ipv6 router ospf 1 R2(config-rtr)#router-id R2(config)#interface Serial0/0/0 R2(config-if)#ipv6 address 2007;12 2/64 R2(config-if)#ipv6 ospf 1 area 1 R2(config-if)#clock rate R2(config-if)#no shutdown R2(config)#interface Serial0/0/1 R2(config-if)#ipv6 address 2007;23 2/64 R2(config-if)#ipv6 ospf 1 area 0 R2(config-if)#closck rate R2(config-if)#no shutdown (3) 步骤 : 配置路由器 R3 R3(config)#ipv6 unicast-routing R3(config)#ipv6 router ospf 1 R3(config-rtr)#router-id R3(config)#interface Serial0/0/0 R3(config-if)#ipv6 address 2007;34 3/64 R3(config-if)#ipv6 ospf 1 area 2 R3(config-if)#clock rate R3(config-if)#no shutdown R3(config)#interface Serial0/0/1 R3(config-if)#ipv6 address 2007;23 3/64 R3(config-if)#ipv6 ospf 1 area 0 R3(config-if)#no shutdown (4) 步骤 4: 配置路由器 R4 R4(config)#ipv6 unicast-routing R4(config)#ipv6 router ospf 1 R4(config-rtr)#router-id R4(config)#interface gigabitethernet0/0 R4(config-if)#ipv6 address 2007;4444 4/64 R4(config-if)#ipv6 ospf 1 area 2 R4(config-if)#no shutdown R4(config)#interface Serial0/0/0 R4(config-if)#ipv6 address 2007;34 4/64

338 R4(config-if)#ipv6 ospf 1 area 0 R4(config-if)#no shutdown 4. 实验调试 (1)show ipv6 route R4#show ipv6 route IPv6 Routing Table - 9 entries Codes;C - Connectd,L - Local,S - Static,R -RIP,B - BGP U - Per-user Static route,m - MIPv6 I1- ISIS L1,I2-ISIS L2,IA-ISIS interarea,is-isis summary O - OSPF intra,o1-ospf inter,oe1-ospf ext 1,OE2-OSPF ext 2 ON1 -OSPF NSSA ext 1,ON2-OSPF NSSA ext 2 D - EIGRP,EX - EIGRP external OE2 /0 [110/30],tag 1 via FE80 C800;AFF;FE90;0,Serial0/0/0 OI 2007;12 /64[110/192] via FE80 C800;AFF;FE90;0,Serial0/0/0 OI 2007;23 /64[110/128] via FE80 C802;AFF;FE90;0,Serial0/0/0 C 2007;34 /64[0/0] via,serial0/0/0 L 2007;12 4/128[0/0] via,serial0/0/0 C 2008;4444 4/64[0/0] via,gigabitethernet0/0 L 2008;4444 4/128[0/0] via,gigabitethernet0/0 L FE80 /10[0/0] via,null0 L FE00 /8[0/0] via,null0 以上输出表明 OSPFv3 的外部路由代码为 OE2 或 OE1, 区域间路由代码为 OI, 区域内路由代码为 O (2)show ip protocols R2#show ipv6 protocols IPv6 Routing Protocol is connected IPv6 Routing Protocol is staic IPv6 Routing Protocol is ospf 1 Interfaces(Area 0);

339 Serial0/0/1 Interfaces(Area 0); Serial0/0/1 Redistribution; None 以上输出表明启动的 OSPFv3 进程 ID 为 1,Serial0/0/1 和 Serial0/0/0 接口上启用 OSPFv3,Serial0/0/1 属于区域 0, Serial0/0/0 属于区域 1 (3)show ipv6 ospf database 该命令用来查看 OSPFv3 拓扑结构数据库 R4#show ipv6 ospf database OSPFv3 Router with ID( )(Process ID 1) Router Link States(Area 2) ADV Router Age Seq# Fragment ID Link count Bits x B x None Inter Area Prefix Link States(Area 2) ADV Router Age Seq# Prefix x ;23 / x ;12 /64 Inter Area Router Link States(Area 2) ADV Router Age Seq# Link ID Dest RtrID x Link(Type-8)Link States(Area 2) ADV Router Age Seq# Link ID Interface x Fa0/ x Sa1/ x Sa1/0

340 Inter Area Prefix Link States(Area 2) ADV Router Age Seq# Link ID Ref-lstype Ref-LsID x x x x Type-5 AS External Link States ADV Router Age Seq# Prefix x /0 以上输出显示了路由器 R4 的 OSPFv3 的拓扑结构数据库. (4)show ipv6 ospf neighbor R2#show ipv6 ospf neighbor NeighborID Pri State Dead Time InterfaceID Interface FULL/ - 00;00;30 5 Serial0/0/ FULL/ - 00;00;37 4 Serial0/0/0 以上输出表明路由器 R2 有两个 OSPFv3 的邻居. (5)show ip ospf interface R2#show ipv6 ospf interface s0/0/0 Serial0/0/0 is up,line protocol is up Link Local Address FE80 C801;AFF;FE90;0,Interface ID 4 Area 1,Process ID 1,Instance ID 0,Router ID Network Type POINT_TO_POINT,Cost;64 Transmit Delay is 1 sec,state POINT_TO_POINT, Timer intervals configured,hello 10,Dead 40,Wait 40,Retransmit 5 Hello due in 00;00;04 Index 1/1/1,flood queue length 0 Next 0x0(0)/0x0(0)/0x0(0) Last flood scan length is 1,maximum is 1 Last flood scan time is 0 msec,maximum is 0 msec Neighbor Count is 1,Adjacent neighbor count is 1 Adjacent with neighbor Suppress hello for 0 neighbor(s) 以上输出上 OSPFv3 路由器接口的基本信息, 和 OSPFv2 非常相似, 包括路由器 ID 网络类型 计时器的值以及邻居的数量等信息

341 2.2.4 实验 4.IPv6 EIGRP 1. 实验目的 通过本实验可以掌握 : 1 启用 IPv6 流量转发 ; 2IPv6 EIGRP 配置和调试 2. 拓扑结构 实验拓扑图如图 22-4 所示 图 22-4 IPv6 EIGRP 配置 3. 实验步骤 (1) 步骤 : 配置路由器 R1 R1(config)#ipv6 unicast-routing R1(config)#ipv6 router eigrp 1 // 配置 IPv6 eigrp R1(config-rtr)#router-id // 配置路由器 ID R1(config-rtr)#no shutdown // 启用 IPv6 EIGRP 进程 R1(config-rtr)#redistribute connected metric // 将直连重分布到 IPv6 EIGRP 中 R1(config)#interface Loopback0 R1(config-if)#ipv6 address 2006;1111 1/64 R1(config)#interface Serial0/0/0 R1(config-if)#ipv6 address 2007;12 1/64 R1(config-if)#ipv6 eigrp 1 // 在接口上启用 IPv6 EIGRP R1(config-if)#no shutdown (2) 步骤 : 配置路由器 R2 R2(config)#ipv6 unicast-routing R2(config)#ipv6 router eigrp 1 R2(config-rtr)#router-id R2(config-rtr)#no shutdown

342 R2(config)#interface Serial0/0/0 R2(config-if)#ipv6 address 2007;12 2/64 R2(config-if)#clock rate R2(config-if)#ipv6 eigrp 1 R2(config-if)#no shutdown R2(config)#interface Serial0/0/1 R2(config-if)#ipv6 address 2007;23 2/64 R2(config-if)#clock rate R2(config-if)#ipv6 eigrp 1 R2(config-if)#no shutdown (3) 步骤 3: 配置路由器 R3 R3(config)#ipv6 unicast-routing R3(config)#ipv6 router eigrp 1 R3(config-rtr)#router-id R3(config-rtr)#no shutdown R3(config)#interface Serial0/0/0 R3(config-if)#ipv6 address 2007;34 3/64 R3(config-if)#clock rate R3(config-if)#ipv6 eigrp 1 R3(config-if)#no shutdown R3(config)#interface Serial0/0/1 R3(config-if)#ipv6 address 2007;23 3/64 R3(config-if)#clock rate R3(config-if)#ipv6 eigrp 1 R3(config-if)#no shutdown (4) 步骤 4: 配置路由器 R4 R4(config)#ipv6 unicast-routing R4(config)#ipv6 router eigrp 1 R4(config-rtr)#router-id R4(config-rtr)#no shutdown R4(config)#interface Loopback0 R4(config-if)#ipv6 address 2008;4444 4/64 R4(config-if)#ipv6 eigrp 1 R4(config)#interface Serial0/0/0 R4(config-if)#ipv6 address 2007;34 4/64 R4(config-if)#ipv6 eigrp 1 R4(config-if)#no shutdown

343 4. 实验调试 (1)show ipv6 route eigrp 该命令来查看 IPv6 EIGRP 的路由 R2#show ipv6 route IPv6 Routing Table - 9 entries Codes;C - Connectd,L - Local,S - Static,R -RIP,B - BGP U - Per-user Static route,m - MIPv6 I1- ISIS L1,I2-ISIS L2,IA-ISIS interarea,is-isis summary O - OSPF intra,o1-ospf inter,oe1-ospf ext 1,OE2-OSPF ext 2 ON1 -OSPF NSSA ext 1,ON2-OSPF NSSA ext 2 D - EIGRP,EX - EIGRP external D 2007;23 /64[90/ ] via FE80 219;55FF;FE66;6320,Serial0/0/0 D 2007;34 /64[90/ ] via FE80 219;55FF;FE66;6320,Serial0/0/0 D 2008;4444 /64[90/ ] via FE80 219;55FF;FE66;6320,Serial0/0/0 R2#show ipv6 route eigrp IPv6 Routing Table - 9 entries Codes;C - Connectd,L - Local,S - Static,R -RIP,B - BGP U - Per-user Static route,m - MIPv6 I1- ISIS L1,I2-ISIS L2,IA-ISIS interarea,is-isis summary O - OSPF intra,o1-ospf inter,oe1-ospf ext 1,OE2-OSPF ext 2 ON1 -OSPF NSSA ext 1,ON2-OSPF NSSA ext 2 D - EIGRP,EX - EIGRP external EX 2006;1111 /64[170/ ] via FE80 219;55FF;FE35;B548,Serial0/0/0 D 2007;34 /64[90/ ] via FE80 219;55FF;FE35;B548,Serial0/0/1 D 2008;4444 /64[90/ ] via FE80 219;55FF;FE35;B548,Serial0/0/1 以上输出说明路由表中的下一跳是对方的本地链路地址, 同时 IPv6 EIGRP 也能够区分内部路由和外部路由, 外部路由代码为 EX. (2)show ipv6 eigrp neighbors 该命令用来查看 IPv6 EIGRP 的邻居 R2#show ipv6 eigrp neighbors IPv6-EIGRP neighbors for process 1 H Address Interface Hold Uptime SRTT RTO Q Seq (sec) (ms) Cnt Num

344 1 Link-local address; Se0/0/ ;33; FE80 219;55FF;FE35;B548 0 Link-local address; Se0/0/ ;33; FE80 219;55FF;FE35;B528 以上输出表明路由器 R2 有两个 IPv6 EIGRP 邻居, 邻居的地址用对方的本地链路地址表示 (3)show ipv6 eigrp topology 该命令用来查看 IPv6 EIGRP 的拓扑结构信息 R2#show ipv6 eigrp topology IPv6-EIGRP Topology Table for AS(1)/ID( ) Codes;P-Passive,A-Active,U-Upbate,Q-Query,R-Reply, r-reply Status,s - sia Status P2007;12 /64,1 successors,fd is via Connected,Serial0/0/0 P2006;1111 /64,1 successors,fd is via FE80 219;55FF;FE35;B828( /281600),Serial0/0/0 P2007;23 /64,1 successors,fd is via Connected,Serial0/0/1 P2007;34 /64,1 successors,fd is via FE80 219;55FF;FE35;B528( / ),Serial0/0/1 P2007;4444 /64,1 successors,fd is via FE80 219;55FF;FE35;B548( / ),Serial0/0/1 (4)show ipv6 protocols R2#show ipv6 protocols IPv6 Routing Protocol is connected IPv6 Routing Protocol is static IPv6 Routing Protocol is eigrp 1 //IPv6 EIGRP 进程 EIGRP metric weight K1=1,K2=0,K3=1,K4=0,K5=0 // 计算度量之的因子 EIGRP maximum hopcount 100 // 最大跳数 EIGRP maximum metric variance 1 //variance 值为 1, 表示默认只支持等价路由负载均衡 Interfaces; Serial0/0/0 Serial0/0/1 // 以上 3 行表示启用 IPv6 EIGRP 接口

345 Redistribution; None Maximum path;16 // 默认最大等价路由径为 16 条, 最多可以配置 64 条 Distance;internal 90 external 170 //IPv6 EIGRP 的内部路由管理距离为 90, 外部路由管理距离为 IPv6 命令汇总 表 22-1 列出了本章涉及到的主要的命令 表 22-1 本章命令汇总 命令 show ipv6 route show ipv6 interface show ipv6 protocols show ipv6 rip next-hops debug ipv6 rip show ipv6 rip datasee show ipv6 ospf neighbor show ipv6 ospf interface show ipv6 ospf database show ipv6 ospf show ipv6 route eigrp show ipv6 eigrp topology show ipv6eigro neighbors debug ipv6 rip ipv6 unicast-routing ipv6 address ipv6 route ipv6 router rip split-horizon poison-reverse ipv6 rip tag enable ipv6 rip default-information originate ipv6 router ospf router-id default-information originate ipv6 ospf process-id area area-id ipv6 router eigrp ipv6 eigrp maximum-patahs variance 作用查看 IPv6 路由表查看 IPv6 接口信息查看和 IPv6 路由协议相关的信息查看 RIPng 的下一跳地址查看 RIPng 的数据库查看 OSPFv3 邻居的基本信息查看 OSPFv3 路由器接口的信息查看 OSPFv3 拓扑结构数据库查看 OSPFv3 进程及其细节查看 IPv6 EIGRP 的路由查看 IPv6 EIGRP 的拓扑结构信息查看 IPv6 EIGRP 的邻居动态查看 RIPng 的更新启动 IPv6 流量转发在接口下配置 IPv6 地址配置 IPv6 静态路由启动 IPv6 RIPng 进程启用水平分割启用毒化反转在接口上启用 RIPng 向 IPv6 RIPng 区域注入一条默认路由启用 OSPFv3 路由进程配置路由器 ID 向 OSPFv3 网络注入一条默认路由接口上启用 OSPFv3, 并声明接口所在区域配置 IPv6 EIGRP 路由协议接口下启用 IPv6 EIGRP 配置能支持的等价路径的条数配置 IPv6 EIGRP 非等价负载均衡

346 第 23 章 组播 随着网络中的视频等应用越来越多, 组播也越来越时髦. 路由器发组播流的方式和转发单播流有很大的差别, 发送组播数据的源不知道接收者在何处 组播也很多路由协议, 它们为组播留建立一棵无环路 无重复流量的转发树 本章将介绍两个常用的 简单的协议 ;PIM Dense 和 PIM Sparse 23.1 组播简介 当有 个拥护通过网络看电视时, 如果分别为每个用户传输一路流量, 不仅服务器受不了, 网络也承载不了 组播 ( 也城多播 ) 则像电视一样, 传输一份数据, 需要接收数据的计算机加入到这个组就行了 虽然组播配置并不复杂, 但理论知识相当复杂 组播采用 ~ 的地址, 不同地址就是不同的组, 一个组可能有多个源, 而需要接收数据的设备是这个组的成员 路由器转发组播流的方式和转发单播留有很大的差别, 发送数据的组播源不知道接收者在何处 保证接收者能收到数据, 并且数据不会在不必要的网络上存在是很重要的事情 路由器必须为组播确定出一条转发路径 路由器采用反向路径转发 (RPF), 即对每个接收到的组播进行源地址测试, 如果数据是从到达源的接口上接收到的, 就往下游路由器转发 为了确定是否应该往某个网络转发组播流, 路由器使用 IGMP(Internet Group Manage Protocol) 和主机之间通信, 确定这个网络是否有某个组的成员 IGMP 有 V1,V2 和 V3, 目前 IOS 采用 V2 IGMP 有各种消息 General Query 消息和 Group-Specific Query 消息等 PIM(Protocol Independent Multicast) 是一个组播路由协议, 独立于协议的意思是, 该组播协议不关心单播路由是通过 RIP 还是 OSPF 或者其他方式学习到的 PIM 有两种模式 :PIM Dense 和 PIM Sparse, 后者通常和 DENSE 结合使用, 成为 PIM Sparse-Dense. Dense 通常用于组成员比较密集的网络中 在 Dense 模式中, 当有组播源出现时, 路由器假设所有的网络都有组成员, 构建了一棵从源开始的转发树, 全部网络就有了组播流量 然而各个路由器会紧接着查询自己的接口上是否有这个组的成员存在, 如果没有成员, 将停止往这个接口转发组播流 如果路由器上一个成员都没有, 它将向上游路由器转发消息, 把它从转发树上修剪掉 一级一级地望上发送消息, 最终多拨路由协议将构建医科以源为根 不会有多余组拨流量存在的转发树 如果有新的成员加入, 路由器将一极一级往上发送消息, 建立转发路径 在 Dense 模式中, 会为不同的源建立不同的树, 这样树的数量可能会很多 Sparse 则通常用于组成员比较系数的网络中 在 Sparse 模式中, 路由器假设所有的网络都没有组成员, 除非有主机明确表示加入该组 转发数的建立从终端的叶节点组成员开始, 向后扩展到中心根节点上 和 Dense 模式不同,Sparse 是基于工享树的, 也就是说某个组

347 的流量是先发送到中心节点上 ( 称为 RP), 然后再从 RP 转发到各个组成员上的 组成员加入到这个组时, 本地路由器向 RP 发送成员报告, 沿途的路由器将树枝假如到共享树中 当成员从组中退出时, 组才执行修剪 这样做的好处是树的数量少, 然而可能造成一些组播数据绕了一圈才到达主机 因此, 实际上在默认时, 当路由器发现不是从到达源的最佳路径的接口上收到组播流时, 会自动切换到基于源的树 在 Sparse 模式中, 可以手工为某个组指定 RP, 也可以让路由器自动选举 需要注意的是, 路由器自动选举 RP 时发送的是组播流量, 由于 RP 还没出现, 所以只能使用 Dense 模式传输这些组播流量, 所以 Sparse 通常和 Dense 结合使用 而对于交换机, 也不能说从一个接口收到组播, 就泛洪到全部接口 然而交换机并且没有 IGMP 协议和主机通信, 交换机采用 2 种方案, 一种是 IGMP Snopping; 另一种是 CGMP IGMP Snopping 中, 交换机监听主机和路由器之间的 IGMP 消息, 从而确定哪一个接口上有什么组的成员存在, 组播流则从这些特定的接口发送出去 在 2 层交换机或者低端的 3 曾交换机上,IGMP Snopping 基本是默认采用的 而 CCMP 协议则是交换机用来和路由器进行通信, 从路由获得组的成员名单, 从而确定哪些接口应该转发哪些组的流量 23.2 实验 1:PIM Dense 1. 实验目的 通过本实验, 读者可以掌握如下技能 : 1 理解 PIM Dense 的工作原理 ; 2 掌握 PIM Dense 的配置 2. 实验拓扑 实验拓扑图如图 23-1 所示 图 23-1 实验 实验 2 的拓扑图 在图 23-1 的拓扑中,R2 的 g0/0 接口以及 PC1 也是接在交换机 S1 上的, 我们把这两个

348 接口单独划分在一个 VLAN 中 图 23-1 没有画出它们和 S1 的连接情况 3. 实验步骤 (1) 步骤 1: 配置 IP 地址 把 R2 的 g0/0 和 OC1 所接的交换机接口单独划分在一个 VLAN 的各路由器的 IP 地址上, 如图 23-1 所示, 在每个路由器上创建环回 Loopback 0, 配置 IP 地址 把 R2 的 g0/0 所接的 f0/2 和 PC1 所接的 f0/5 接口单独划分在一个 VLAN, 如下所述 S1(config)#vlan 2 S1(config)#int f0/2 S1(config-if)#switch mode access S1(config-if)#switch access vlan 2 S1(config)#int f0/5 S1(config-if)#swich mode access S1(config-if)#switch access vlan 2 (2) 步骤 2: 配置路由协议 R1(config)#router rip R1(config-router)#network R1(config-router)#network R1(config-router)#network R2(config)#router rip R2(config-router)#network R2(config-router)#network R2(config-router)#network R2(config-router)#network R4(config)#router rip R4(config-router)#network R4(config-router)#network (3) 步骤 3: 配置 PIM Dense R1(config)#ip multicast-routing // 以上是启用组播路由功能 R1(config)#int loopback0

349 R1(config-if)#ip pim dense // 组播的配置相当简单, 在接口上运行 PIM Dense 协议即可 R1(config)#int s0/0/0 R1(config-if)#ip pim dense R1(config)#int g0/0 R1(config-if)#ip pim dense R2(config)#ip multicast-routing R2(config)#int loopback0 R2(config-if)#ip pim dense R2(config)#int s0/0/0 R2(config-if)#ip pim dense R2(config)#int s0/0/1 R2(config-if)#ip pim dense R2(config)#int g0/0 R2(config-if)#ip pim dense R3(config)#ip multicast-routing R3(config)#int loopback0 R3(config-if)#ip pim dense R3(config)#int s0/0/1 R3(config-if)#ip pim dense R3(config)#int g0/0 R3(config-if)#ip pim dense R4(config)#ip multicast-routing R4(config)#int loopback0 R4(config-if)#ip pim dense R4(config-if)#ip igmp join-group // 该接口加入到 组中, 利用 组做测试 R4(config)#int g0/0 R4(config-if)#ip pim dense (4) 步骤 4: 检查 PIM 邻居, 测试组播路由 R1#show ip pim neighbor PIM Neighbor Table Mode;B-Bidr Capable,DR-Designated Router,N-Default DR Priority, S-State Refresh Capable Neighbor Interface Uptime/Expires Ver DR Address Prio /Mode Serial0/0/0 06;57;59/00;01;27 v2 1 /S

350 GigabitEthernet0/0 06;25;46/00;01;24 v2 1 /S GigabitEthernet0/0 06;25;46/00;01;24 v2 1 /DR S // 以上显示了 R1 上 PIM 邻居 在 PC1 上配置 IP 地址, 执行 ping -t , 这时 PC1 实际上就是组 的组播源. 在各个路由器上检查多播路由表 ; R2#show ip mroute ( 此处省略 ) (*, ),00;03;07/stoppred,RP ,flags;D Incoming interface;null,rpe nbr Outgoing interface list; Seria0/0/1,Forward/Dense, 00;03;07/00;00;00 Seria0/0/1,Forward/Dense, 00;03;07/00;00;00 ( , ),00;03;07/00;02;52,flags;T Incoming interface;gigabitethernet0/0,rpe nbr // 以上表明 R2 是从 g0/0 接口收到多播流的 Outgoing interface list; Seria0/0/1,Forward/Dense, 00;03;08/00;00;00 Seria0/0/0,Prune/Dense, 00;01;09/00;01;50 // 可以看到 R2 上只往 s0/0/1 接口收到多播流量 ;s0/0/0 接口不转发, 处于被修剪状态 (*, ),06;49;33/stoppred,RP ,flags;DCL Incoming interface;null,rpe nbr Outgoing interface list; Seria0/0/1,Forward/Dense, 06;49;33/00;00;00 Seria0/0/0,Forward/Dense, 06;49;33/00;00;00 技术要点 需要仔细观察组播树的情况, 在各个路由器上使用 show ip mroute 命令, 应该可以看到 ; 组播数据从 R2 的 g0/0 接口接收到, 从 s0/0/1,s0/0/0 接口则不转发 ;R3 从 s0/0/1 接口接收到组播, 从 g0/0 接口转发出去到达 R4 的 g0/0;r4 从 g0/0 接口接收到组播, 从 loopback 接口转发出去. 把 R1 上的 loopback 0 接口也加入到组 中, 重新在 R2 上检查多播路由表, 如下所述 ; R1(config)#int loopback 0 R1(config)#ip igmp join-group R2#show ip mroute

351 ( 此处省略 ) ( , ),00;10;21/00;02;58,flags;T Incoming interface;gigabitethernet0/0,rpe nbr Outgoing interface list; Seria0/0/1,Forward/Dense, 00;10;22/00;00;00 Seria0/0/0,Forward/Dense, 00;00;03/00;00;00 // 可以看到 R2 上的 s0/0/0 接口开始转发数据了, 原因在于 R1 上有组成员了. 可见 PIM Dense 会根据组成员的加入或者退出, 动态低维护发树 ( 此处省略 ) R1#show ip mroute ( 此处省略 ) ( , ),00;10;44/00;02;59,flags;LT Incoming interface;serial0/0/0,rpe nbr Outgoing interface list; Loopback0,Forward/Dense, 00;02;25/00;00;00 GigabitEthernet0/0,Forward/Dense, 00;01;43/00;01;16 // 可以看到 R1 上的 g0/0 处于修剪状态, 因为 R3 已经往 /24 网络转发数据了, 这样该网段才不会有 2 份组播流量 ( 此处省略 ) R3#show ip mroute ( 此处省略 ) ( , ),06;42;14/00;02;58,flags;LT Incoming interface;serial0/0/1,rpe nbr Outgoing interface list; GigabitEthernet0/0,Forward/Dense, 00;13;21/00;00;00,A // 可以是看到 R3 在往 /24 网段转发数据 ( 此处省略 ) 在 PC1 上停止 ping, 在各个路由器上查看多播路由表, 各个路由器的多播路由表在大约 3 分钟后会消失. 这是因为没有了源, 路由器无须再维护这些路由表 (5) 步 5: 查看 IGMP 组成员 R1#show ip igmp groups IGMP Connected Group Membership GroupAddress Interface Uptime Expires LastReporter GroupAccounted Loopback0 00;15;14 00;02; // 这是我们用命令加入的成员 GigabitEthernet0/0 00;28;07 00;02; Serial0/0/0 07;30;07 stopped // 以上是查看 R1 上各个接口上各组有什么成员存在

352 (6) 步骤 6: 配置 检查 IGMP Snooping IGMP Snooping 是在交换机上工作的, 默认时就已经启用, 也可以用以下命令打开 ; S1(config)#ip igmp snooping S1#show ip igmp snooping Global IGMP Snooping configurtion; IGRP snooping ;Enabled IGRPv3 snooping(minimal) ;Enabled Report suppression ;Enabled TCN solicit query ;Disabled TCN flood query count ;2 Last Member Query Interval;1000 Vlan 1; IGMP snooping ;Enabled IGMPv2 immediate leave ;Disabled Explicit host tranking ;Enabled Multicast router learning mode ;pim-dvmrp Last Member Query Interval ;1000 CGMp interoperability mode ;IGMP_ONLY // 以上是显示交换机上的 IGMP Snooping 运行情况 S1#show ip igmp snooping groups Vlan Group Type Versio PortList igmp v2 Fa0/1,Fa0/3,Fa0/4 //f0/1 f0/3 f0/4 接口上有 组的成员存在, 则应该往这些接口转发 的多播流, 其他接口不转发, 节约了带宽 23.3 实验 2:PIM Sparse-Dense 1. 实验目的 通过本实验, 读者可以掌握如下技能 ; 1 理解 PIM Sparse-Dense 的工作原理 ; 2 掌握 PIM Sparse-Dense 的配置 2. 实验拓扑

353 实验拓扑图如图 23-1 所示

354 3. 实验步骤在实验 1 基础上继续本实验 (1) 步骤 1: 配置 PIM Sparse, 采用静态 RP R1(config)#int loopback0 R1(config-if)#ip pim sparse-dense // 接口上运行 ping sparse-dense 协议即可 R1(config)#int s0/0/0 R1(config-if)#ip pim sparese-dense R1(config)#int g0/0 R1(config-if)#ip pim sparse-dense R1(config)#ip pim rp-address // 以上静态配置 R3 为 RP R1(config)#ip pim spt-threshold infinity // 以上是防止从基于 RP 的树切换到基于源的树, 默认是切换的, 稍后介绍树的切换问题 R2(config)#int loopback0 R2(config-if)#ip pim sparse-dense R2(config)#int s0/0/0 R2(config-if)#ip pim sparse-dense R2(config)#int s0/0/1 R2(config-if)#ip pim sparse-dense R2(config)#int g0/0 R2(config-if)#ip pim sparse-dense R2(config)#ip pim rp-address R3(config)#int loopback0 R3(config-if)#ip pim sparse-dense R3(config)#int s0/0/1 R3(config-if)#ip pim sparse-dense R3(config)#int g0/1 R3(config-if)#ip pim sparse-dense R3(config)#ip pim rp-address

355 R4(config)#int loopback0 R4(config-if)#ip pim sparse-dense R4(config)#int g0/1 R4(config-if)#ip pim sparse-dense R4(config)#ip pim rp-address (2) 步骤 2; 测试组播路由在 PC1 上执行 ping-t , 在各个路由器上检查多播路由表 ; R1#show ip mroute ( 此处省略 ) (*, ),07;31;41/00;02;59,RP ,flags;SCL Incoming interface;gigabitethernet0/0,rpe nor // 可以看到 R1 是从 g0/0 接口收到组播流的, 原因在于 RP 是 R3, 而从 R1 到达 R3, 从 g0/0 是最近的, 这时, 组播留实际上是从 PC1 到 R2, 再到 R3(RP) 上, 然后从 R3 的 g0/0 再到 R1 的 G0/0 接口, 很显然绕了一圈, 这是不合理的 技术要点 在基于 RP 的树中, 组播数据是先从源到达 RP 的, 然后从 RP 到达各个组成员. 从 RP 到达各个组成员的数据转发是根据共享树的构建情况来转发的 ; 而从组播到达 RP 的组播流的转发实际上也需要一棵树, 这时采用基于源的树. (3) 步骤 3; 从基于 RP 的树切换到基于源的树 R1(config)#no ip pim spt-threshold infinty // 以上允许从基于 RP 的树切换到基于源的数, 实际上这是默认值, 在步骤 1 中被我们修改了 R1#show ip mroute ( 此处省略 ) (*, ),07;36;48/00;02;58,RP ,flias;SJCL Incoming interfacegigabitethenet,rpe nbr Outgoing interface list; Loopback0,Forward/Sparse-Dense,00;57;35/00;02;26 ( , ),00;00;01/00;02;59,flags;LJT Incoming interface;serial0/0/0,rpe nbr Outgoing interface list; Loopback0,Forward/Sparse-Dense,00;00;01/00;02;58 // 可以看到这时多了一条多播路由, 这是基于源的路由, 这时 R1 实际上是从 s0/0/0 接口收到数据, 显然这才是合理的 技术要点 数的切换是很重要的 很复杂的事情, 树的切换是避免组播流绕了一圈才到达接收者的 默认时是会切换的, 因此, 在 Sparse 模式中, 也存在基于源的树 (4) 步骤 4: 配置 Auto RP 在各个路由器上, 去掉配置静态 RP 的命令, 如下 : R1(config)#no p pim rp-address

356 R2(config)#no p pim rp-address R3(config)#no p pim rp-address R4(config)#no p pim rp-address R2(config)#ip pim send-rd-discovery loopback 0 scope 255 // 把 R2 配置为映射代理,Loopback 0 为代理地址 R3(config)#ip pim send-rd-discovery loopback 0 scope 255 // 把 R3 配置为侯选 RP,loopback 0 为 RP 地址 在各个路由器上检查 RP 的地址 : R1#show ip pim rp mapping PLM Group-to-RP Mappings Group(s) /4 RP (?),v2v1 Info source; (?),elected via Auto-RP Uptime;00;00;36,expires;00;02;19 // 在各个路由器上都可以看到, 所有的组播地址的 RP 都已经映射到 R3 再按照步骤 2 测试组播路由 23.4 组播命令汇总 表 23-1 所示是本意出现的命令 表 23-1 本章命令汇总 命令 ip multicast-routing ip pim dense ip igmp join-group show ip pim neighbor show ip mroute show ip igmp groups ip igmp snooping show ip igmp snooping show ip igmp snooping groups ip pim sparse-dense ip pim spt-threshold infinity ip pim send-rp-discovery loopback 0 scope 255 ip pim send-rp-announce Loopback0 scope 255 作用启用组泊路由功能在接口上运行 PIM Dense 协议在接口加入到 组中显示了 PIM 邻居显示组播路由表显示组成成员在交换机上配置 IGMP Snopping 功能显示交换机上的 IGMP Snooping 运行情况交换机上显示各组的成员在什么接口上在接口上运行 PIM Sparse-dense 协议静止从基于 RP 的树切换到基于源的树把路由器设为映射代理, 其 Loopback 0 为代理地址把路由器设为后选 RP, 其 Loopback 0 为代理地址

357 第 24 章 BGP 通常可以将路由协议分为 IGP( 内部网管协议 ) 和 EGP( 外部网关协议 ),EGP 主要用于 ISP 之间路由信息 目前使用最为广泛的 EPG 是 BGP 版本 4, 它是第一个支持 CIDR 和路由汇总的 BGP 版本 RFC1772 对 BGP 有详细的定义 BGP 概述 BG P 特征 BGP 被称为路径向量路由协议, 它的任务在自治系统之间交换路由信息, 同时确保没有路由环路, 其特征如下 ; 1 用属性 (Attribute) 描述路径, 而不是用度量值 ; 2 使用 TCP( 端口 179) 作为传输协议, 继承了 TCP 的可靠性和面向连接的特性 ; 3 通过 Keepaliv 信息来检验 TCP 的连接 ; 4 具有丰富的属性特征, 方便实现基于策略的路由 ; 5 拥有自己的 BGP 表 ; 6 支持 VLSM 和 CIDR; 7 适合在大型网路中使用 在详细讨论 BGP 之前, 首先应用掌握如下 BGP 术语 1 对等体 (peer): 当两台 BGP 路由器之间建立了一条基于 TCP 的连接后, 就称它们为邻居或对等体 ; 2 AS: 是一组处于统一管理控制和策略下的路由器或主机 AS 号又 Internet 注册机构分配, 范围为 1~65 535, 其中 ~ 是私有使用的 ; 3 IBGP; 当 BGP 在一个 AS 内运行时, 被称为内部 BGP(IBGP); 4 EIGRP; 当 BGP 运行在 AS 之间时, 被称为外部 BGP(EBGP). 5 NLRI( 网络层可达到信息 ):BGP 通过 NLRI 支持 CIDR,NLRI 是 BGP 更新报文的一部分, 用于列出可到达的目的的集合 ; 6 同步 ; 在 BGP 能通告路由之前, 该路由必须存在于当前的 IP 路由表中, 也就是说,BGP 和 IGP 必须在网络能被通告前同步,Cisco 允许通过命令 no synchronization 来关闭同步 ; 7 IBGP 水平分割 ; 通过 IBGP 学到的路由不能通告给其他的 IBFP 邻居..

358 24.1.2BGO 属性 BGP 具有丰富的属性, 为网络管理员进行路由控制带来很大的方便,BGP 路由属性分为以下 4 类. (1) 公认必遵 (Well Known Mandatory) BGP 更新报文必须包含的, 且必须被所有 BGP 厂商实现所能识别的属性包括 ORIGIN,AS_PATH 和 Next_Hop. 1 ORIGIN( 起源 ); 这个属性说明起源路由是怎样放到 CD 表中的. 有 3 个可能的源 ---IGP,EGP 以及 INCOMPLETE 路由器在多个路由选者的处理中使用这个信息. 路由器选者具有最低 ORIN 类型的路径.OPIGIN; 类型从低处到高的顺序为 ;JGP<EGP<INCOMPLETE. 2 AS_PATH (AS 路径 ); 指出包含在 UPDATE 报文中的路由信息所经过饿自治系统的序列. 3 NEXT_HOP ( 下一跳 ); 生命路由器所获得的 BGP 路由的下一跳. 对 EBGP 会话来说, 下一跳就是通过该路由的邻居路由器的源地址. 对于 IBGP 会话, 有良种情况, 一是起源 AS 内部的路由的下一眺就是通告该路由器的源地址 ; 二是由 EBGP 注入 AS 的路由, 它的下一跳会不变的带入 IBGP 中. (2) 公认自决 (Well-Known Discretionary) 该属性指必须被所有 BGP 实现所识别, 但是在 BGP 更新报文中可以发送, 也可以不发送的属性, 包括 LOCAL_PREF 和 ATOMIC_AGGREGATE 1LOCAL_PREF( 本地优先级 ): 本地优先级属性是用于告诉自治系统内的路由器在有多条路径的时候, 怎么离开自治系统 本地优先级越高, 路由优先级越高 该属性仅仅在 IBGP 邻居之间传递 2ATOMIC_AGGREGATE( 原字聚合 ): 原子聚合属性指出已被丢失了的信息 当路由聚合时将会导致信息的丢失, 因为聚合来自具有不同属性的不同源 如果一个路由器发送了导致信息丢失的聚合, 路由器被要求将原子聚合属性附加到该路由上 (3) 可选过渡 (Optional Transitive) 可选过渡属性并不要求所有的 BGP 实现都支持 如果该属性不能被 BGP 进程识别, 它就会去看过渡标志 如果过渡标志被设置,BGP 进程会接受这个属性并将它不加改变的传送, 包括 AGGREGATOR 和 COMMUNITY 1AGGREGATOR( 聚合者 ): 此属性标明了实施路由聚合的 BGP 路由器 ID 和聚合路由的路由器的 AS 号 2COMMUNITY( 团体 ): 此属性指共享一个公共属性的一组路由器 (4) 可选非过渡 (Optional Nontransitive) 可选非度过属性并不要求所有的 BGP 实现都支持 如果这些属性被发送到不能对其实别的路由器, 这些属性将会被丢弃, 不能传送给 BGP 邻居, 包括 MED,ORIGNATOR_ID 和 CLUSTER_LIST 1MED( 多出口区分 ): 该属性通知 AS 以外的路由器采用哪一条路经到达 AS, 它也

359 被认为是路由的外部度量, 低 MED 值表示高的优先级 MED 属性在自治系统间交换, 但 MED 属性不能传递到第三方 AS. 2ORIGNATOR_ID( 起源 ID): 路由反射器会附加到这个属性上, 它携带本 AS 源路由器的路由器 ID, 用以防止环路 3CLUSTER_LIST( 簇列表 ): 此属性显示了采用的反射路径 BGP 路由判定 BGP 使用了描述路由特性的很多属性, 这些属性和每一个路由一起在 BGP 更新报文中被发送, 路由器使用这些属性去悬着到目的地的最佳路由 理解 BGP 路由判定的过程很重要的, 下面按优先顺序给出了路由器在 BGP 路径选择中的判定过程 : 1 如果下一跳不可达, 则不考虑该路由 ; 2 优先选取工具有最大权重 (Weight) 值得路径, 权重是 Cisco 专有属性 ; 3 如果权重值相同, 优先选取具有最高本地优先级的路由 ; 4 如果本地优先级相同, 优先选区源自于本路由器 ( 即县一跳为 ) 上 BGP 的路由 ; 5 如果本地优先级相同, 并且没有源自于本路由器的路由, 优先选取具有最短 AS 路径的路由 ; 6 如果有相同的 AS 路径长度, 优先选取具有最低起源代码 (IGP<EGP<INCOMPLETE) 的路由 ; 7 如果起源代码相同, 优先选取具有最低 MED 值得路径 ; 8 如果 MED 都相同, 在 EBGP 路由和联盟 EBGP 路由中, 首选 EBGP 路由, 在联盟 EBGP 路由和 IBGP 路由中, 首选联盟 EBGP 路由 ; 9 如果前面所有属性都相同, 优先选取离 IGP 邻居最近的路径 ; 10 如果内部路径也相同, 优先选取具有最低 BGP 路由器 ID 的路径 24.2 实验 1:IBGP 和 EBGP 基本配置 1. 实验目的通过本实验可以掌握 : 1 启动 BGP 路由进程 ; 2BGP 进程中通告网络 ; 3IBGP 邻居配置 ; 4EBGP 邻居配置 ; 5BGP 路由更新源配置 ; 6next-hop-self 配置 ; 7BGP 路由汇总配置 ; 8BGP 路由调试 ;

360 2. 拓扑结构 图 实验步骤因为本实验中 IBGP 的路由器 (R1,R2 和 R3) 形成全互联 (Full Mesh) 的邻居关系, 所以路由器 R1,R2 和 R3 均关闭同步 IBGP 路由器之间运行的 IGP 是 EIGRP, 为了提供 BGP 建立邻居关系的 TCP 连接和 BGP 下一跳可达 (1) 步骤 1: 配置路由器 R1 R1(config)#routere eigrp 1 R1(config-router)#network R1(config-router)#network R1(config-router)#no auto-summary R1(config)#routere bgp 100 // 启动 BGP 进程 R1(config-router)#no synchronization // 关闭同步 R1(config-router)#bgp routere-id // 配置 BGP 路由器 ID R1(config-router)#neighbor remote-as 100 // 指定邻居路由器及所在的 AS R1(config-router)#neighbor update-source Loopback0 // 制定更新源 R1(config-router)#neighbor remote-as 100 R1(config-router)#neighbor update-source Loopback0 R1(config-router)#network mask // 通告网络 R1(config-router)#no auto-summary // 关闭自动汇总 (2) 步骤 2: 配置路由器 R2 R2(config)#routere eigrp 1

361 R2(config-router)#network R2(config-router)#network R2(config-router)#network R2(config-router)#no auto-summary R2(config)#routere bgp 100 R2(config-router)#bgp routere-id R2(config-router)#neighbor remote-as 100 R2(config-router)#neighbor update-source Loopback0 R2(config-router)#neighbor remote-as 100 R2(config-router)#neighbor update-source Loopback0 R2(config-router)#no auto-summary (3) 步骤 3: 配置路由器 R3 R3(config)#routere eigrp 1 R3(config-router)#network R3(config-router)#network R3(config-router)#no auto-summary R3(config-router)#no synchronization R3(config-router)#bgp routere-id R3(config-router)#neighbor remote-as 100 R3(config-router)#neighbor update-source Loopback0 R3(config-router)#neighbor next-hop-self // 配置下一跳自我, 即对从 EBGP 邻居传入的路由, 在通告给 IBGP 邻居的同时, 强迫路由器通告自己是发送 BGP 更新的下一跳, 而不是 EBGP 邻居 R3(config-router)#neighbor remote-as 100 R3(config-router)#neighbor update-source Loopback0 R3(config-router)#neighbor next-hop-self R3(config-router)#neighbor remote-as 200 R3(config-router)#no auto-summary (4) 步骤 4: 配置路由器 R4 R4(config)#routere bgp 200 R4(config-router)#no synchronization R4(config-router)#bgp routere-id R4(config-router)#neighbor remote-as 100 R4(config-router)#no auto-summary R4(config-router)# network mask R4(config-router)# network mask R4(config-router)# network mask

362 R4(config-router)# network mask R4(config-router)# network mask // 用 network 做路由汇总通报 R4(config)#ip route null0 // 在 IGP 表中构造该汇总路由, 否则不能用 network 通告 技术要点 1 一台路由器只能启动一个 BGP 进程 ; 2 命令 neighbor 后边跟的是邻居路由器 BGP 路由更新源的地址 3BGP 中的 network 命令与 IGP 中存在的路由条目 ( 可以是直连, 静态路由或动态路由 ) 在 BGP 中通告 同时 network 命令参数 mask 来通告单独的子网 如果 BGP 的自动汇总功能没有关闭, 如果 BGP 的自动汇总能关闭, 则通告必须严格匹配掩码长度 4 命令 neighbor 后边跟 update-source 参数, 是由来指定更新源的, 如果网络中有多条路经, 那么用环回接口建立 TCP 连接, 并作为 BGP 路由的更新源, 会增加 BGP 的稳定性 5 命令 neighbor 后边跟 next-hop-self 参数是为了解决下一跳可达的问题, 因为当路由通过 EBGP 注入到 AS 时, 从 EBGP 获得的下一跳会被不变的在 IBGP 中传递, next-hop-self 参数使得路由器会把自己作为发送 BGP 更新的下一跳来通报给 IBGP 邻居 6BGP 的下一跳是指 BGP 路由表中路由条目的下一跳, 也就是相应 network 命令所指的地址 4. 实验调试 (1)show tep brief 该命令用来查看 TCP 连接信息摘要 R3#show tep brief TCP Local Address Foreign Address (state) 64752BAC ESTAB 64753B5C ESTAB ESTAB 以上输出标明路由器 R3 和路由器 R1,R2 和 R4 的 179 端口建立了 TCP 连接 建立 TCP 连接的双方使用 BGP 路由更新源的地址 只要两台路由器之间建立了一条 TCP 连接, 就可以形成 BGP 邻居关系 (2)show ip bgp neighbors 该命令用来查看邻居的 TCP 和 BGP 连接的详细信息 R3#show ip bgp neighbors

363 BGPneighbor is remote AS 200.extenal link BGP version 4.remote router ID BGP stae=established,up for 00;50;29 Last read 00;00;21,hold time is 180,keepalive interval is 60 seconds Neighbor capabilities; Route refresh;advertised and received(old & new) Address family IPv4 Unicast;advertised and received 以上输出表明路由器有一个外部 BGP 邻居路由器 R4( ) 在 AS 200, 此邻居的路由器 ID 号是 命令 show ip bgp neighbors 显示出的信息最重要的一部分是 BGP stae= 那一行, 此行给出了 BGP 连接的状态 Established 状态表示 BGP 对等体间的会话是打开的并正在运行 如果显示的是其他状态, 如 Idle,Connect,Active, OpenSent 或 OpenConfirm, 那就 存在问题 (3)show ip bgp summary 该命令用来查看 BGP 连接的摘要信息 R3#show ip bgp summary BGP router identifier ,local AS number 100 // 路由器 ID 及本地 AS BGP table version is 11,main routing table version 11 //BGP 表的内部版本号 (BGP 表变化时号码会逐此加 1) 和注入到主路由表的最后版本号 5 network entries using 505 bytes of memory // 网络条目和使用的 memory 5 path entries using 505 bytes of memorymemory // 路径条目和使用的 memory 2 BGP path attribute entries using 120 bytes of memory 1 BGP AS-PATH entries using 24 bytes of memory 0 BGP route-map cache entries using 0 bytes of memory 0 BGP filter-list cache entries using 0 bytes of memory BGP using 889 total bytes of memory BGP activity 5/0 prefixes,6/1paths,scan interval 60 secs Neighbor V AS MsgRcvd MsgSent TblVer InQ OutQ Up/Down State/pfxrcd ;38; ;12; ;07;47 4 以上输出的邻居表的各个字段的含义如下所述. 1Neighdor;BGP 邻居的 ID; 2V;BGP 的版本为 4; 3AS; 邻居所在的 AS 号码 ;

364 4MsgRcvd; 接受的信息 ; 5MsgSent; 发送的信息 ; 6TblVer;BGP 表的内部版本号 ; 7Up/Down; 邻居关系建立的时间 ; 8State/PfxRcd;BGP 连接的状态或者通告的路由前缀 (4)show ip bgp 该命令用来查看 BGP 表的信息 R3#show ip bgp BGP table version is 11,local router ID is //BGP 表的内部版本号和本路由器的 BGP 路由器 ID Status codes;s suppressed,d damped,h history,* valid,>best,i-internal r RIP-failure,S Stale Origin codes;i-igp,e-egp,?-incomplete Network Next Hop Metric LocPrf Weight Path r>i / i *> / i *> / i *> / i *> / i *> / i 在以上输出中, 路由条目表项的状态代码 (Status Codes) 的含义解释如下所述 1s; 表示路由条目被抑制 ; 2d; 表示路由条目由于被惩罚而受到抑制, 从而阻止了不稳定路由的发布 ; 3h; 表示该路由正在被惩罚, 但还未到抑制阀值而使它被抑制 ; 4*; 表示该路由条目有效 ; 5>; 表示该路由条目最优, 可以被传递, 达到最优的重要前提是下一跳可达 ; 6i; 表示该路由条目是从 IBGP 邻居学到的 ; 7r; 表示将 BGP 表中的路由条目放入到 IP 路由表中失败 下面具体地解释 BGP 路由条目 : r>i / i 的含义 1r; 因为路由器 R3 通过 EIGRP 学到 /24 路由条目, 其管理距离为 90, 而通过 IBGP 学到 /24 路 由条目的管理距离是 200, 而且关闭了同步,BGP 表中的路由条目放入到 IP 路由表中失败, 所以出现代码 r ; 2>; 表示该路由条目最优, 可以被传递 ;

365 3i; 表示该路由条目是从 IBGP 邻居学到的 ; : 表示该 BGP 路由的下一跳 ; 50( 标题栏对应 Metric): 表示该路由外部度量值即 MED 值为 0; 6100; 表示该路由本地优先级为 100; 70( 标题栏对应 Weight): 表示该路由的权重值为 0, 如果是本地生产的, 默认权重值是 ; 如果是从邻居学来的, 默认权重值为 0; 8 由于该路由是通过相同 AS 的 IBGP 邻居传地来, 所以 PATH 字段为空 ; 9i; 表示该路由条目源为 IGP 它是路由器 R1 用 network 命令通告的 (5)show ip route R1#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospfinter area N1-OSPF NSSAexternal type 1,N2-OSPFexternal type 2 E1-OSPFexternal type 1,E2-OSPFexternal type 2 i-is-is,l1-is-is,l2-is-is level-2,ia-is-is inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set /24 is sudetted,1 sudnets C is directly connected,loopback /24 is sudetted,1 sudnets D [90/ ]via ,03;03;44,Serial0/0/ /24 is sudetted,1 sudnets D [90/ ]via ,03;03;44,Serial0/0/ /8 is sudetted,1 sudnets B /24[200/0] via ,03;02;52 B /22[200/0] via ,01;37;48 B /24[200/0] via ,03;02;52 B /24[200/0] via ,03;02;52 B /24[200/0] via ,03;02; /24 is sudetted,1 sudnets D [90/ ]via ,03;03;45,Serial0/0/ /24 is sudetted,1 sudnets C is directly connected,serial0/0/0 R3#show ip route Codes;C-connected,S-static,R-RIP,M-mobile,B-BGP D-EIGRP,EX-EIGRP external,o-ospf,ia-ospfinter area N1-OSPF NSSAexternal type 1,N2-OSPFexternal type 2

366 E1-OSPFexternal type 1,E2-OSPFexternal type 2 i-is-is,l1-is-is,l2-is-is level-2,ia-is-is inter area *-candidate default,u-per-user static route,o-odr P-periodic downloaded static route Gateway of last resort is not set /24 is sudetted,1 sudnets C is directly connected,serial0/0/ /24 is sudetted,1 sudnets D [90/ ]via ,02;17;48,Serial0/0/ /24 is sudetted,1 sudnets D [90/ ]via ,02;51;36,Serial0/0/ /24 is sudetted,1 sudnets B /24[20/0] via ,02;45;33 B /22[20/0] via ,00;51;20 B /24[20/0] via ,02;45;33 B /24[20/0] via ,02;45;33 B /24[20/0] via ,02;45; /24 is sudetted,1 sudnets C is directly connected,serial0/0/ /24 is sudetted,1 sudnets D [90/ ]via ,02;17;53,Serial0/0/1 以上输出表明 IBGP 的管理距离是 200,EBGP 的管理距离是 20. (6)ping 在路由器 R1 上 ping , 结果是不通的, 原因很简单, 就是路由器 R1 和 R2 路由表中没有 的路由, 此时如果执行扩展 ping, 就是通的 : R1#ping Protocol[ip]; Target IP address; Repeat count[5];2 Datagram size[100]; Timeout in seconds[2]; Extended commands[n];y Source address or interface; Type of service[0]; Set DF bit in IP header?[on]; Validate reply data?[on];

367 Data pattern [0xABCD]; Looes,Strict,Record,Timestamp,Verbose[none]; Sweep range of sizes [n]; Type escape sequence to abort. Sending 2,100-byte ICMP Echos to ,timeout is 2 seconds; Pasket sent with a source address of !! 如果一定要标准 ping, 无非就是让路由器 R1 和 R2 学到 的路由, 方法很多, 比如在路由器 R3 上重分布直连 (7 在 )R1 上打开 BGP 同步, 然后查看 BGP 表 R1(config)#routere bgp 100 R1(config-router)#synchronization // 打开同步 R1#clear ip bgp* // 重置 BGP 连接 R1#show ip bgp BGP table version is 1,locl routerid is Status cods;s suppressed,d damped,h history,*valid,.best,i-internal, r RIB-failure, S Stale Origin codes;i-igp,e-egp,?-incomplete Network Next Hop Metric LocPrf Weight Path *i / i *i / i *i / i *i / i *i / i 以上输出表明 BGP 路由不是被优化的, 因为 IGP 的路由表中并没有这些路由条目 (8)R1,R2,R3 之间的邻居关系删除路由器 R1 和 R3 之间的邻居关系, 保持路由器 R1 和 R2 建立邻居关系, 建立路由 器 R2 和 R3 建立邻居关系, 操作如下 : R1(config)#routere bgp 100 R1(config-router)#no synchronization R1(config-router)#no neighbor R3(config)#routere bgp 100 R3(config-router)#no neighbor 在路由器 R1 和 R2 上查看 BGP 表 R1#show ip bgp BGP table version is 2,locl routerid is Status cods;s suppressed,d damped,h history,*valid,.best,i-internal,

368 r RIB-failure, S Stale Origin codes;i-igp,e-egp,?-incomplete Network Next Hop Metric LocPrf Weight Path *> / i R2#show ip bgp BGP table version is 8,locl routerid is Status cods;s suppressed,d damped,h history,*valid,.best,i-internal, r RIB-failure, S Stale Origin codes;i-igp,e-egp,?-incomplete Network Next Hop Metric LocPrf Weight Path r> / i *i / i *i / i *i / i *i / i *i / i 以上输出表明路由器 R2 并没有将路由器 R3 通告的路由通告给路由器 R1, 这进一步验证了 IBGP 水平分割的基本原理 ; 通过 IBGP 学到的路由不能通告给相同 AS 内的其他的 IBGP 邻居 通常的解决办法由两个 :IBGP 形成全互连邻居关系或 使用路由反射器 24.3 实验 2;BGP 地址聚合 1. 实验目的通过本实验可以掌握 : 1 启动 BGP 路由进程 2BGP 中通告网络 3EBGP 邻居配置 4BGP 地址聚合配置和调试 5 地址聚合参数 as-set 含义 6 地址聚合参数 summary-only 含义 7 地址聚合参数 suppress-map 含义 2. 拓扑结构实验拓扑图如图 24-2 所示

369 图 实验拓扑本实验在路由器 R2 上将路由器 R1 和路由器 R3 通告的环回接口的路由进行地址聚合, 并通告给路由器 R4 在路由器 R1 R3 R4 配置静态路由实现网络互通 (1) 步骤 1: 配置路由器 R1 R1(config)#routere bgp 100 R1(config-router)#no synchronization R1(config-router)#no auto-summary R1(config-router)#bgp routere-id R1(config-router)#neighbor remote-as 200 R1(config-router)#network mask R1(config-router)#network mask R1(config-router)#network mask R1(config)#ip route R1(config)#ip route (2) 步骤 2: 配置路由器 R2 R2(config)#routere bgp 200 R2(config-router)#no synchronization R2(config-router)#no auto-summary R2(config-router)#bgp routere-id R2(config-router)#neighbor remote-as 100 R2(config-router)#neighbor remote-as 300 R2(config-router)#neighbor remote-as 400 R2(config-router)#aggregate-address // 配置地址聚合

Microsoft Word - chp3静态路由.doc

Microsoft Word - chp3静态路由.doc 第 3 章静态路由 转发数据包是路由器的最主要功能 路由器转发数据包时需要查找路由表, 管理员可以通过手工的方法在路由器中直接配置路由表, 这就是静态路由 虽然静态路由不适合于在大的网络中使用, 但是由于静态路由简单 路由器负载小 可控性强等原因, 在许多场合中还经常被使用 本章将介绍静态路由的配置, 同时为以后配置动态路由奠定基础 3.1.1 静态路由介绍 3.1 静态路由与默认路由 路由器在转发数据时,

More information

幻灯片 1

幻灯片 1 Lab 2 路由器的基本管理 1 实验目的 1. 理解 TFTP 服务的特点与作用与配置 2. 掌握 TFTP 服务的配置 3. 掌握使用 TFTP 上传进行 IOS 备份的方法 4. 掌握使用 TFTP 下载进行 IOS 恢复 / 更新的方法 5. 掌握使用 TFTP 进行配置文件的备份与恢复的方法 6. 掌握路由器密码恢复的基本方法 R&S 1-2 实验内容 1 通过 TFTP 进行 IOS 备份

More information

第2章 路由器基本配置

第2章 路由器基本配置 路由器基本配置 本章首先将简要介绍路由器的硬件组成, 重点介绍路由器中最重要的部分 IOS 对路由器的配置, 实际上就是对 IOS 软件进行配置 IOS 提供了大量的命令, 只有熟悉这些命令才能很好地发挥路由器的功能, 本章介绍了路由器的一些基本配置命令 2.1 路由器及 IOS 简介 2.1.1 路由器简介 路由器能起到隔离广播域的作用, 还能在不同网络间转发数据包 路由器实际上是一台特殊用途的计算机,

More information

通过动态路由协议实现链路备份

通过动态路由协议实现链路备份 通过动态路由协议实现链路备份 实验名称 通过动态路由协议实现链路备份 实验目的 掌握通过在不同链路上配置不同的路由协议实现链路备份 背景描述 你是公司高级网络管理员, 公司内部有一个很重要的服务器所在网段为 192.168.12.0/24, 平常访问通过 R1,R3 的 OSPF 路由协议, 为了保证该网段随时能够访问, 不能因为链路故障出问题, 要求你实现一个备份冗余的功能, 请给予支持 实现功能

More information

D. 192.168.5.32 E. 192.168.5.14 答 案 :C 3. 工 作 站 A 配 置 的 IP 地 址 为 192.0.2.24/28. 工 作 站 B 配 置 的 IP 地 址 为 192.0.2.100/28. 两 个 工 作 站 之 间 有 直 通 线 连 接, 两 台

D. 192.168.5.32 E. 192.168.5.14 答 案 :C 3. 工 作 站 A 配 置 的 IP 地 址 为 192.0.2.24/28. 工 作 站 B 配 置 的 IP 地 址 为 192.0.2.100/28. 两 个 工 作 站 之 间 有 直 通 线 连 接, 两 台 CCNP 学 前 测 试 题 都 选 自 官 方 的 全 真 考 试 题, 共 100 道 题 实 际 测 试 选 60 道 题, 同 官 方 正 式 考 题 数 目 基 本 一 致, 因 此 等 于 是 模 拟 考 试, 采 用 网 上 形 式 进 行 测 评 学 前 测 评 目 的 是 为 了 检 验 大 家 对 CCNA 阶 段 知 识 掌 握 的 程 度, 同 时 对 CCNA 最 核 心

More information

路由器基本配置

路由器基本配置 路由器基本配置 本章内容 路由器的基本操作 实验练习 常用的路由器配置方法 TFTP Console MODEM AUX telnet web 任何 Interface AUX 备份接口, 一般用于路由器的管理备份接口 路由器的操作模式 : 配置模式 1. 线路配置模式 Router(config-line)# 配置路由器的线路参数 2. 路由协议配置模式 Router(config-router)#

More information

ch08.PDF

ch08.PDF 8-1 CCNA 8.1 CLI 8.1.1 8-2 8-3 8.1.21600 2500 1600 2500 / IOS 8-4 8.2 8.2.1 A 5 IP CLI 1600 2500 8-5 8.1.2-15 Windows 9598NT 2000 HyperTerminal Hilgraeve Microsoft Cisco HyperTerminal Private Edition (PE)

More information

<4D F736F F D C2B7D3C9C6F7BBF9B1BEC5E4D6C32E646F63>

<4D F736F F D C2B7D3C9C6F7BBF9B1BEC5E4D6C32E646F63> 第 2 章路由器基本配置 本章将先简要介绍路由器的硬件组成, 而重点介绍路由器中最重要的部分 IOS, 对路由器的配置实际上就是对 IOS 软件进行配置 IOS 提供了大量的命令, 熟悉这些命令才能很好地发挥路由器的功能, 本章介绍的是路由器的一些基础性命令 2.1.1 路由器简介 2.1 路由器简介和 IOS 简介 路由器能起到隔离广播域的作用, 还能在不同网络间转发数据包 路由器实际上是一台特殊用途的计算机,

More information

Cisco Cisco Cisco (ROM) (FLASH) (RAM) RAM(NVRAM) Cisco

Cisco Cisco Cisco (ROM) (FLASH) (RAM) RAM(NVRAM) Cisco Ch2 Cisco IOS Cisco Cisco Cisco (ROM) (FLASH) (RAM) RAM(NVRAM) Cisco Cisco ROM ROM Cisco ROM(BIOS) ROM 1. POST Cisco 2. BootStrap Cisco IOS 3. IOS IOS IOS Cisco ROM ROM Cisco Flash Flash Flash IOS Cisco

More information

epub

epub 3 Cisco 3.1 S e t u p C i s c o C i s c o Cisco IOS C i s c o 3.2 Te l n e t T F T P 3-1 3-1 configure terminal configure memory Configure network t e l n e t < C t r l - Z > conf t N V R A M T F T P I

More information

F5270

F5270 Cisco 路 由 器 設 定 主 講 : 陳 建 民 本 章 提 要 4-1 Cisco 路 由 器 使 用 者 界 面 4-2 命 令 列 界 面 4-3 路 由 器 與 交 換 器 的 管 理 功 能 4-4 路 由 器 界 面 4-5 檢 視 儲 存 與 清 除 組 態 設 定 2 Cisco 路 由 器 3 4 5 6 Router physical characteristics 7 4-1

More information

12.pdf

12.pdf 对 帧 中 继 配 置 与 故 障 排 除 的 全 面 的 指 南 交 互 : 本 文 档 对 您 的 Cisco 设 备 进 行 自 定 义 分 析 目 录 简 介 开 始 使 用 前 规 则 先 决 条 件 使 用 的 组 件 背 景 理 论 配 置 基 本 的 帧 中 继 网 络 图 配 置 debug 和 show 命 令 配 置 星 形 帧 中 继 网 络 图 配 置 显 示 命 令 分

More information

Microsoft Word - chp21路由优化.doc

Microsoft Word - chp21路由优化.doc 第 21 章路由优化 在当今高性能的网络中, 为了保证网络的伸缩性 稳定性 安全性和快速收敛, 必须对网络进行优化 路由过滤和策略路由是路由优化的常用方法 21.1 路由优化概述 路由过滤是指在路由更新中抑制某些路由不被发送和接收, 被动接口 分布控制列表 重分布结合路由策略等都可以实现路由过滤 策略路由提供了根据网络管理者制定的标准来进行数据包转发的一种机制 基于策略的路由比传统路由能力更强, 使用更灵活,

More information

Packet Tracer实验集

Packet  Tracer实验集 Packet Tracer 1 实验集 Packet Tracer 实验集 姚俊编著 目 录 目 录 第一部分路由器实验... 1 实验 1-1. 路由器的 console 口访问配置... 1 实验 1-2. 路由器的 telnet 访问配置... 5 实验 1-3. CLI 的使用与 IOS 基本命令...8 实验 1-4. 配置文件的管理和 IOS 的管理... 15 实验 1-5. 密码恢复和

More information

active phisical rp address: backup phisical rp address: 截取部分 TOPO 图说明到 不通的问题 : internet internet tengige 0/0/0/0 tengige

active phisical rp address: backup phisical rp address: 截取部分 TOPO 图说明到 不通的问题 : internet internet tengige 0/0/0/0 tengige ASR9000 ping 丢包 troubleshooting 目录 硬件平台软件版本案例介绍问题分析思路问题总结经验总结相关命令 硬件平台 ASR9000 软件版本 4.2.0 案例介绍 拓扑示例 : 问题, 客户从外网 internet ping 3 个 vrrp subnet 的地址时候始终只能通一个 IP 地址 : vrrp virtual IP :2.2.2.129 其他不能 ping 通的

More information

Chapter #

Chapter # 第三章 TCP/IP 协议栈 本章目标 通过本章的学习, 您应该掌握以下内容 : 掌握 TCP/IP 分层模型 掌握 IP 协议原理 理解 OSI 和 TCP/IP 模型的区别和联系 TCP/IP 介绍 主机 主机 Internet TCP/IP 早期的协议族 全球范围 TCP/IP 协议栈 7 6 5 4 3 应用层表示层会话层传输层网络层 应用层 主机到主机层 Internet 层 2 1 数据链路层

More information

mppp-ddr.pdf

mppp-ddr.pdf DDR 多 链 路 PPP - 基 本 配 置 和 验 证 目 录 简 介 开 始 使 用 前 规 则 先 决 条 件 使 用 的 组 件 多 链 路 PPP 干 什 么 配 置 多 链 路 PPP 命 令 传 统 DDR 拨 号 原 型 (Dialer Profile) 验 证 MPPP 操 作 相 关 信 息 简 介 多 链 路 PPP ( 也 指 MP MPPP MLP 或 多 链 路 ) 提

More information

CCNA 講義

CCNA 講義 CCNA 筆 記 王 振 民 目 錄 第 1 章 Packet Tracer 的 使 用... 2 第 1 節 安 裝... 2 第 2 節 建 置 網 路 環 境 _01( 二 台 PC+ 一 台 HUB)... 8 第 3 節 Pc 的 設 定 :IP, cmd...... 10 第 4 節 傳 送 封 包 (ICMP 封 包 檢 視...)... 13 第 2 章 基 礎 知 識... 14

More information

IP-Routing-05.pdf

IP-Routing-05.pdf RI P R I P - 2 RIP -1 R I P - 2 DV RIP -1 RIP-2 16... RIP-2 RIP-2 RIP -1 R I P - 2 RIP-2 RIP-2 RIP-2 V L S M disc ontiguous addr ess sp ace C I D R Cla ssless In ter -Dom ain Routing 121 1 2 2 IP RIP-2

More information

IP505SM_manual_cn.doc

IP505SM_manual_cn.doc IP505SM 1 Introduction 1...4...4...4...5 LAN...5...5...6...6...7 LED...7...7 2...9...9...9 3...11...11...12...12...12...14...18 LAN...19 DHCP...20...21 4 PC...22...22 Windows...22 TCP/IP -...22 TCP/IP

More information

<4D F736F F D CAB5D1E9CDD8C6CBA1A2D6D5B6CBB7FECEF1C6F7C5E4D6C32E646F63>

<4D F736F F D CAB5D1E9CDD8C6CBA1A2D6D5B6CBB7FECEF1C6F7C5E4D6C32E646F63> 第 1 章实验拓扑 终端服务器配置 本章将首先简要介绍如何从计算机上访问路由器以对它们进行配置, 通常可以通过 console 口或者 telnet 来连接路由器 随后还要介绍本书中一直要用到的网络拓扑, 并将详细介绍如何配置终端服务器以达到方便控制各个路由器和交换机的目的 1.1 访问 CISCO 路由器的方法 路由器没有键盘和鼠标, 要初始化路由器需要把计算机的串口和路由器的 console 口进行连接

More information

动态路由选择协议、RIP

动态路由选择协议、RIP 学习沉淀成长分享 动态路由协议 RIP 红茶三杯 ( 朱 SIR) 微博 : t.sina.com/vinsoney Latest update: 2012-06-01 课程目标 动态路由协议概述 RIP RIP 基础实验 动态路由协议概述 什么是路由 什么是动态路由协议 动态路由协议的分类 什么是路由 192.168.10.0/24 172.16.1.0/24 e0 s0 Protocol Connected

More information

ebook20-7

ebook20-7 7 Catalyst 5000 Catalyst 5000 Cisco Works for Switched Internetworks (CWSI) C L I C L I G U I C L C W S I C i s c o C W S I C L I I P Te l n e t C L I 9600 8 6 7.1 Catalyst C a t a l y s t Cisco IOS C

More information

动态路由选择协议、RIP

动态路由选择协议、RIP 学习沉淀成长分享 动态路由协议 RIP 红茶三杯 ( 朱 SIR) 微博 :http://t.sina.com/vinsoney Latest update: 2012-06-01 Content 动态路由协议概述 RIP RIP 基础实验 动态路由协议概述 什么是路由 什么是动态路由协议 动态路由协议的分类 什么是路由 IP header Data FE1/0 PC1 192.168.1.1/24

More information

IS-IS路由协议中文教程v1

IS-IS路由协议中文教程v1 IS-IS v1.0 Chapter 0 Preface Statement BSCI Building Scalable Cisco Internetworks Configuring IS-IS Protocol IS-IS IS-IS OSI TCP/IP IS-IS OSPF Cisco System BSCI Student Guide Outline 1 OSI IS-IS 2 IS-IS

More information

Microsoft Word - chp20路由重分布.doc

Microsoft Word - chp20路由重分布.doc 第 20 章路由重分布 当许多运行多路由的网络要集成到一起时, 必须在这些不同的路由选择协议之间共享路由信息 在路由选择协议之间交换路由信息的过程被称为路由重分布 (Route Redistribution) 20.1 路由重分布概述 路由重分布为在同一个互联网络中高效地支持多种路由协议提供了可能, 执行路由重分布的路由器被称为边界路由器, 因为它们位于两个或多个自治系统的边界上 路由重分布时计量单位和管理距离是必须要考虑的

More information

Microsoft Word - CCNA2_Exploration_instructor_40_CoverSheet.DOC

Microsoft Word - CCNA2_Exploration_instructor_40_CoverSheet.DOC 本 文 档 是 Cisco Systems, Inc. 的 专 有 财 产, 为 Cisco Networking Academy 讲 授 CCNA Exploration 路 由 协 议 和 概 念 课 程 的 教 师 专 用, 允 许 打 印 或 复 制 作 非 商 业 用 途 实 验 1.5.1: 网 络 布 线 和 基 本 路 由 器 配 置 ( 教 师 版 ) 拓 扑 图 地 址 分 配

More information

Simulator By SunLingxi 2003

Simulator By SunLingxi 2003 Simulator By SunLingxi sunlingxi@sina.com 2003 windows 2000 Tornado ping ping 1. Tornado Full Simulator...3 2....3 3. ping...6 4. Tornado Simulator BSP...6 5. VxWorks simpc...7 6. simulator...7 7. simulator

More information

TCP/IP TCP/IP OSI IP TCP IP IP TCP/IP TCP/IP

TCP/IP TCP/IP OSI IP TCP IP IP TCP/IP TCP/IP TCP/IP : TCP/IP TCP/IP OSI IP TCP IP IP TCP/IP TCP/IP 1. ASCII EBCDIC Extended Binary-Coded Decimal Interchange Code 2. / (1) (2) Single System Image SSI) (3) I/O (4) 3.OSI OSI Open System Interconnection

More information

计算机网络 实验指导书 / 实验四 : 动态路由协议 实验四 : 动态路由协议 一 实验目的 1 进一步理解路由器的工作原理; 2 掌握 RIP 的基本原理和实现 ; 3 掌握 OSPF 的基本原理和实现 二 实验学时 2 学时 三 实验类型 综合性 四 实验需求 1 硬件每人配备计算机 1 台 2

计算机网络 实验指导书 / 实验四 : 动态路由协议 实验四 : 动态路由协议 一 实验目的 1 进一步理解路由器的工作原理; 2 掌握 RIP 的基本原理和实现 ; 3 掌握 OSPF 的基本原理和实现 二 实验学时 2 学时 三 实验类型 综合性 四 实验需求 1 硬件每人配备计算机 1 台 2 实验四 : 动态路由协议 一 实验目的 1 进一步理解路由器的工作原理; 2 掌握 RIP 的基本原理和实现 ; 3 掌握 OSPF 的基本原理和实现 二 实验学时 2 学时 三 实验类型 综合性 四 实验需求 1 硬件每人配备计算机 1 台 2 软件 Windows 7 以上操作系统, 安装 GNS3 网络仿真与 VirtualBox 虚拟化软件, 安装 Putty 软件 3 网络实验室局域网支持,

More information

ARP ICMP

ARP ICMP ARP ICMP 2 9-1 ARP 9-2 ARP 9-3 ARP 9-4 ICMP 9-5 ICMP 9-6 ICMP 9-7 ICMP 3 ARP ICMP TCP / IP, IP ARP ICMP 3 IP, ARP ICMP IP ARP ICMP 2, 4 9-1 ARP, MAC, IP IP, MAC ARP Address Resolution Protocol, OSI ARP,,

More information

第3章

第3章 本 章 涵 盖 以 下 主 题 全 局 单 播 地 址 路 由 和 子 网 划 分 : 本 节 通 过 与 IPv4 相 比 较, 介 绍 了 IPv6 地 址 IPv4 路 由 的 概 念, 以 及 怎 样 进 行 IPv6 子 网 划 分 IPv6 全 局 单 播 地 址 的 分 配 : 本 节 探 讨 了 怎 样 将 全 局 单 播 地 址 分 配 到 主 机 或 其 他 设 备 上 IPv6

More information

工程师培训

工程师培训 .1 TCP/IP TCP/IP 1 .2.2.1 Host 1960 S 1970 S Host Low Speed Lines 1970 S 1980 S pc Server Local Interneting 1980 S 1990 S Branch. pc Branch. WAN Branch. pc pc IBM SNA IBM X.25 2 .2.2 OSI OSI Application

More information

Procedural Lab Template, Student Version, Required Components

Procedural Lab Template, Student Version, Required Components 拓 樸 圖 位 址 配 置 表 設 備 介 面 IP 位 址 子 網 路 遮 罩 預 設 閘 道 R1 Fa0/0 192.168.1.1 255.255.255.0 不 適 用 S0/0/0 192.168.2.1 255.255.255.0 不 適 用 R2 Fa0/0 192.168.3.1 255.255.255.0 不 適 用 S0/0/0 192.168.2.2 255.255.255.0

More information

09.实验九:内部网关协议RIP与OSPF

09.实验九:内部网关协议RIP与OSPF 计算机网络 实验指导 实验九 : 内部网关协议 RIP 与 OSPF 一 实验目的 1 进一步理解路由器的工作原理; 2 掌握 RIP 的基本原理和概念 ; 3 掌握 OSPF 的基本原理和概念 ; 4 掌握基于 GNS3 仿真平台进行网络实验的方法 二 实验学时 2 学时 三 实验类型 综合性 四 实验需求 1 硬件每人配备计算机 1 台, 计算机接入实验室局域网, 每小组配备交换机 2 台, 路由器

More information

R3105+ ADSL

R3105+ ADSL ... 1 1 1... 1 1 2... 1... 3 2 1... 3 2 2... 3 2 3... 5 2 4... 5 2 4 1... 5... 7 3 1... 7 3 2... 8 3 2 1... 8 3 2 2... 9 3 3... 12 3 3 1... 13 3 3 2 WAN... 16 3 3 3 LAN... 21 3 3 4 NAT... 22 3 3 5... 24

More information

ebook20-8

ebook20-8 8 Catalyst 5000 7 V L A N C a t a l y s t V L A N V L A N 8.1 VLAN VTP V L A N A VLAN VLAN 10 VLAN 20 VLAN 10 VLAN 20 B VLAN VLAN 10 VLAN 20 VLAN 10 C VLAN VLAN 10 VLAN 20 VLAN 10 VLAN 20 8-1 VLAN 8 Catalyst

More information

第 1 部 分 : 检 查 网 络 要 求 在 第 1 部 分 中, 您 将 研 究 使 用 172.16.128.0/17 网 络 地 址 为 拓 扑 图 中 显 示 的 网 络 开 发 VLSM 地 址 方 案 的 网 络 要 求 注 意 : 您 可 以 使 用 Windows 计 算 器 应

第 1 部 分 : 检 查 网 络 要 求 在 第 1 部 分 中, 您 将 研 究 使 用 172.16.128.0/17 网 络 地 址 为 拓 扑 图 中 显 示 的 网 络 开 发 VLSM 地 址 方 案 的 网 络 要 求 注 意 : 您 可 以 使 用 Windows 计 算 器 应 拓 扑 目 标 第 1 部 分 : 检 查 网 络 要 求 第 2 部 分 : 设 计 VLSM 地 址 方 案 第 3 部 分 : 布 线 和 配 置 IPv4 网 络 背 景 / 场 景 可 变 长 度 子 网 掩 码 (VLSM) 旨 在 避 免 浪 费 IP 地 址 使 用 VLSM, 会 对 网 络 多 次 进 行 子 网 划 分 此 过 程 可 重 复 多 次, 从 而 根 据 每 个

More information

untitled

untitled 7.1 7.1.1 IP R1 N N,R1,M IP 1 7.1.2 [Quidway]display ip routing Routing Tables: Destination/Mask proto pref Metric Nexthop Interface 0.0.0.0/0 Static 60 0 120.0.0.2 Serial0 8.0.0.0/8 RIP 100 3 120.0.0.2

More information

Session Dan Gill 2 IP WAN WAN? Networker NSC-114 RST-271 NSC-211 : MTBF: MTTR: MTBF MTTR : MTBF? MTTR? MTTR MTTR MTTR MTBF MTTR Mom-and-apple-pie MTBF MTBF (UPS, ) Mom-and-apple-pie Increase MTBF MTBF?

More information

ebook140-8

ebook140-8 8 Microsoft VPN Windows NT 4 V P N Windows 98 Client 7 Vintage Air V P N 7 Wi n d o w s NT V P N 7 VPN ( ) 7 Novell NetWare VPN 8.1 PPTP NT4 VPN Q 154091 M i c r o s o f t Windows NT RAS [ ] Windows NT4

More information

P4i45GL_GV-R50-CN.p65

P4i45GL_GV-R50-CN.p65 1 Main Advanced Security Power Boot Exit System Date System Time Floppy Drives IDE Devices BIOS Version Processor Type Processor Speed Cache Size Microcode Update Total Memory DDR1 DDR2 Dec 18 2003 Thu

More information

GPRS IP MODEM快速安装说明

GPRS IP MODEM快速安装说明 GF-3026D CDMA 无 线 路 由 器 用 户 手 册 北 京 嘉 复 欣 科 技 有 限 公 司 地 址 : 北 京 市 海 淀 区 阜 成 路 115 号 北 京 印 象 2 号 楼 213 室 电 话 :86-10-88122130 88153193 88153197 传 真 :86-10-88122129 网 站 :http://www.garefowl.com/ 目 录 一 产 品

More information

¶C¶L§§¬_™¨ A.PDF

¶C¶L§§¬_™¨ A.PDF 1 9 3 1 9 4 / 7.1 / 1 9 5 7.2 % netstat -rn Routing tables Destination Gateway Flags Refcnt Use Interface 127.0.0.1 127.0.0.1 UH 1 132 lo0 172.16.12.0 172.16.12.2 U 26 49041 le0 1 9 6 / % ping -s almond

More information

基于点到点链路的 OSPF 的初始配置

基于点到点链路的 OSPF 的初始配置 基于点到点链路的 OSPF 的初始配置 目录 简介先决条件要求使用的组件规则带有串行接口 IP 地址的点对点链路上的 OSPF 网络图配置带有未编号接口的点对点链路上的 OSPF 网络图配置验证验证带有串行接口 IP 地址的 OSPF 的配置验证带有未编号接口的 OSPF 的配置故障排除相关信息 简介 在高级数据链路控制 (HDLC) 和点对点协议 (PPP) 等点对点链路上, 开放最短路径优先 (OSPF)

More information

Microsoft Word - vlsm and ip unnumbered.doc

Microsoft Word - vlsm and ip unnumbered.doc Part1:VLSM VLSM AND IP unnumbered 实验讲义 实验目的 : 使用两种不同的路由选择协议,IPv1 和 IPv2 来配置 VLSM, 并测试其功能 实验拓扑 : HUB2 department2 192.168.1.128/26 1602 1601 192.168.1.192/26 192.168.1.64/26 1720 2514/1703 192.168.1.0/26

More information

財金資訊-80期.indd

財金資訊-80期.indd IPv6 / LINE YouTube TCP/IP TCP (Transmission Control Protocol) IP (Internet Protocol) (node) (address) IPv4 168.95.1.1 IPv4 1981 RFC 791 --IP IPv4 32 2 32 42 IP (Internet Service Provider ISP) IP IP IPv4

More information

飞鱼星多WAN防火墙路由器用户手册

飞鱼星多WAN防火墙路由器用户手册 WAN VER: 20110218 Copyright 2002-2011 VOLANS WAN VR4600 VR4900 VR7200 VR7500 VR7600 1.1 1.2 IP 1.3 2.1 2.2 2.2.1 2.2.2 3.1 3.2 3.2.1 3.2.2 3.2.3 4.1 4.2 4.2.1 4.2.2 4.2.3 4.2.4 4.2.5 4.2.6 4.3 4.3.1 4.3.2

More information

ebook140-9

ebook140-9 9 VPN VPN Novell BorderManager Windows NT PPTP V P N L A V P N V N P I n t e r n e t V P N 9.1 V P N Windows 98 Windows PPTP VPN Novell BorderManager T M I P s e c Wi n d o w s I n t e r n e t I S P I

More information

untitled

untitled CIU ( ) 2005 ( 9 00 11 30 150 ) 1 2B 2 75 1 75 3 A B C D 4 2B 2005 ( ) 88 89 (88)A 4 B 5 C 6 D 7 (89)A 27 B 28 C 29 D 30 5 29 (88) B (89) C 88 B 89 C ( ) 1 2 (1)A B C. D (2)A B C. D 16M (3) (3)A 16 B 20

More information

指定静态路由的下一跳IP地址

指定静态路由的下一跳IP地址 指定静态路由的下一跳 IP 地址 目录 简介背景信息对广播接口的静态路由浮动静态路由示例问题解决方案结论 简介 本文描述静态路由基本概念 问题场景用于为了展示指定接口下一跳 IP 地址可以被到达的情况变得理想, 当您配置静态路由时 失败可能导致不需要的行为和一个残破的网络状况 背景信息 由于各种各样的原因使用静态路由并且是常用的, 当没有动态路由对目的 IP 地址时, 或者, 当您要动态地改写获取的路由时

More information

版权声明

版权声明 SG3124 http://www.utt.com.cn 2000-2008 URL Internet Web EULA EULA UTT HiPER PN 0901-0003-001 DN PR-PMMU-1180.03-PPR-CN-1.0A ...1 1...2 1.1...2 1.2...2 1.3...3 1.4...3 2 1.4.1...3 1.4.2...4...5 2.1...5

More information

AL-M200 Series

AL-M200 Series NPD4754-00 TC ( ) Windows 7 1. [Start ( )] [Control Panel ()] [Network and Internet ( )] 2. [Network and Sharing Center ( )] 3. [Change adapter settings ( )] 4. 3 Windows XP 1. [Start ( )] [Control Panel

More information

FortiGate-v5.2-PPPOE 拨号协商时的 AC-name 和 Service-name 版本 1.0 时间 2015 年 3 月 支持的版本 FortiOS v5.2.x 作者 黄豪赫 状态 已审核 反馈

FortiGate-v5.2-PPPOE 拨号协商时的 AC-name 和 Service-name 版本 1.0 时间 2015 年 3 月 支持的版本 FortiOS v5.2.x 作者 黄豪赫 状态 已审核 反馈 FortiGate-v5.2-PPPOE 拨号协商时的 AC-name 和 Service-name 版本 1.0 时间 2015 年 3 月 支持的版本 FortiOS v5.2.x 作者 黄豪赫 状态 已审核 反馈 support_cn@fortinet.com 1 目 录 简介...3 PPPoE 发现阶段简介...3 相关组件...4 参考文档...4 FortiGate 相关命令介绍...

More information

计算机网络 实验指导书 / 实验三 : 使用路由器组网 实验三 : 使用路由器组网 一 实验目的 1 理解路由器的基本工作原理; 2 掌握路由器的基本管理和配置方法; 3 理解路由组网的方法和静态路由的具体使用; 4 理解基于路由器的园区网的结构, 并进一步体会园区网的设计思路 二 实验学时 2 学

计算机网络 实验指导书 / 实验三 : 使用路由器组网 实验三 : 使用路由器组网 一 实验目的 1 理解路由器的基本工作原理; 2 掌握路由器的基本管理和配置方法; 3 理解路由组网的方法和静态路由的具体使用; 4 理解基于路由器的园区网的结构, 并进一步体会园区网的设计思路 二 实验学时 2 学 实验三 : 使用路由器组网 一 实验目的 1 理解路由器的基本工作原理; 2 掌握路由器的基本管理和配置方法; 3 理解路由组网的方法和静态路由的具体使用; 4 理解基于路由器的园区网的结构, 并进一步体会园区网的设计思路 二 实验学时 2 学时 三 实验类型 综合性 四 实验需求 1 硬件每人配备计算机 1 台 2 软件 Windows 7 以上操作系统, 安装 GNS3 网络仿真与 VirtualBox

More information

一、选择题

一、选择题 计 算 机 网 络 基 础 第 7 章 练 习 思 考 与 认 识 活 动 一 选 择 题 1. 下 面 命 令 中, 用 于 检 查 WINDOWS2000 下 TCP/IP 配 置 信 息 的 是 ( ) A. cmd B. nslookup C. ipconfig D. ping 2. 内 部 网 关 协 议 RIP 是 一 种 广 泛 使 用 的 基 于 距 离 矢 量 算 法 的 协 议

More information

MASQUERADE # iptables -t nat -A POSTROUTING -s / o eth0 -j # sysctl net.ipv4.ip_forward=1 # iptables -P FORWARD DROP #

MASQUERADE # iptables -t nat -A POSTROUTING -s / o eth0 -j # sysctl net.ipv4.ip_forward=1 # iptables -P FORWARD DROP # iptables 默认安全规则脚本 一 #nat 路由器 ( 一 ) 允许路由 # iptables -A FORWARD -i eth0 -o eth1 -j ACCEPT ( 二 ) DNAT 与端口转发 1 启用 DNAT 转发 # iptables -t nat -A PREROUTING -p tcp -d 192.168.102.37 dprot 422 -j DNAT to-destination

More information

KillTest 质量更高 服务更好 学习资料 半年免费更新服务

KillTest 质量更高 服务更好 学习资料   半年免费更新服务 KillTest 质量更高 服务更好 学习资料 http://www.killtest.cn 半年免费更新服务 Exam : JN0-130 Title : Juniper Juniper Networks Certified Internet Specialist.e(JNCIS-E) Version : Demo 1 / 10 1. Which CLI command is used to set

More information

1 1 2 OSPF RIP 2

1 1 2 OSPF RIP 2 MPLS VPN 1. TCP/IP IP IP IP IP 1 1 2 OSPF RIP 2 2 RIP OSPF BGP DVMRP IS- IS IP 1. Unicast Routing Protocol Multicast Routing Protocol RIP OSPF BGP IS-IS DVMRP PIM-SM PIM-DM 2. IGP EGP IGPRIP OSPF IS-ISEGP

More information

目录 简介... 3 BGP 重发布进 OSPF 环境拓扑图... 3 BGP 重发布进 OSPF 路由过滤... 4 FGT200B 关键配置... 4 接口 IP 配置... 4 Route-Map... 4 BGP 的配置... 5 FGT100E 关键配置... 5 接口 IP 及 BGP

目录 简介... 3 BGP 重发布进 OSPF 环境拓扑图... 3 BGP 重发布进 OSPF 路由过滤... 4 FGT200B 关键配置... 4 接口 IP 配置... 4 Route-Map... 4 BGP 的配置... 5 FGT100E 关键配置... 5 接口 IP 及 BGP BGP 与 OSPF 之间重发布时使用 Route-Map 进行路由过滤 版本 1.0 时间 2017 年 9 月 5 日星期二 支持的版本 FortiGate v5.0 v5.2 v5.4 v5.6 作者 状态 反馈 刘康明 已审核 support_cn@fortinet.com 目录 简介... 3 BGP 重发布进 OSPF 环境拓扑图... 3 BGP 重发布进 OSPF 路由过滤... 4

More information

SL2511 SR Plus 操作手冊_單面.doc

SL2511 SR Plus 操作手冊_單面.doc IEEE 802.11b SL-2511 SR Plus SENAO INTERNATIONAL CO., LTD www.senao.com - 1 - - 2 - .5 1-1...5 1-2...6 1-3...6 1-4...7.9 2-1...9 2-2 IE...11 SL-2511 SR Plus....13 3-1...13 3-2...14 3-3...15 3-4...16-3

More information

管理CISCO IOS

管理CISCO IOS 学习沉淀成长分享 设备管理及 CISCO IOS 基础配置 红茶三杯 ( 朱 SIR) 微博 :http://t.sina.com/vinsoney Latest update: 2012-06-01 Content CISCO 路由器及启动过程 设备管理及 CISCO IOS 介绍 CISCO IOS 路由器基础实验 CISCO 路由器及启动过程 路由器组件 路由器启动过程 路由器组件 接口 内存

More information

QL1880new2.PDF

QL1880new2.PDF ADSL Modem 1 MODEM 56K MODEM 128K ISDN INTERNET ADSL Modem VOD ADSL ADSL 2 1.1 ADSL 1.2 1.3 KM300A 2.1 2.2 2.3 2.4 2.5 KM300A 2.6 web 2.7 1.1ADSL 1.2 1.3 2.1 ADSL 2.2 ADSL 3 ADSL KM300A ADSL KM300A DIY

More information

计算机网络概论

计算机网络概论 1 repeater bridge router gateway V.S OSI Repeater(Hub) 1 Repeater 2 3 ( Hub 4 Bridge 1 Bridge 2 N N DL1 DL1 DL2 DL2 Ph1 Ph1 Ph2 Ph2 1 2 Bridge 3 MAC Ethernet FDDI MAC MAC Bridge 4 5 6 7 50873EA6, 00123456

More information

局域网技术课程设计报告.doc

局域网技术课程设计报告.doc 湖 南 第 一 师 范 学 院 信 息 科 学 与 工 程 学 院 局 域 网 络 设 计 方 案 1 目 录 一 系 统 概 述...6 1 课 程 设 计 目 的 :...6 2 课 程 设 计 要 求 :...6 3 需 求 分 析 :...6 二 系 统 分 析 与 设 计...7 1 拓 扑 图 设 计...7 2 ip, 掩 码 及 vlan 规 划...7 3 物 理 布 线 设 计...8

More information

epub 30-12

epub 30-12 12 IP I P I P E s t a b l i s h e d I P I P l o c k - a n d - k e y V T Y 12.1 1) 2) D D R 3) 4) 5) 12.2 IP C i s c o 1) I P I P I P 402 CCIE 1 I P 0 0.0.0.0 1 3 150. 1. 1 1 ~ 255 150. 1. 1. 0 2) Inbound

More information

ebook140-11

ebook140-11 11 VPN Windows NT4 B o r d e r M a n a g e r VPN VPN V P N V P N V P V P N V P N TCP/IP 11.1 V P N V P N / ( ) 11.1.1 11 V P N 285 2 3 1. L A N LAN V P N 10MB 100MB L A N VPN V P N V P N Microsoft PPTP

More information

VIDEOJET connect 7000 VJC-7000-90 zh- CHS Operation Manual VIDEOJET connect 7000 zh-chs 3 目 录 1 浏 览 器 连 接 7 1.1 系 统 要 求 7 1.2 建 立 连 接 7 1.2.1 摄 像 机 中 的 密 码 保 护 7 1.3 受 保 护 的 网 络 7 2 系 统 概 述 8 2.1 实 况

More information

网工新答案

网工新答案 2005 年 5 月 29 日 软 考 2005 年 上 半 年 网 络 工 程 师 上 午 试 题 ( 参 考 答 案 ) ( 特 别 声 明, 此 答 案 只 作 参 考 ) 本 文 是 经 过 三 审 后 的 CIU 网 工 上 午 参 考 答 案 ( 正 确 率 在 92%-95% 之 间, 因 为 种 种 原 因, 不 能 与 标 准 答 案 完 全 相 同, 请 大 家 理 解 ) 如

More information

NSC-161

NSC-161 IP Session IP? IP Cisco IP IP IP IP IP? LAN Software Bluetooth,, 802.11 IP IP IP QoS IP Trust Domain (TD 1 ) TD 2 AR AR AP AP (MN) (MN) IP IP ( ) (MR) IP LAN MR (AP) IP 802.11 (AL) LAN/PAN 802.11, 802.15,

More information

管理CISCO IOS

管理CISCO IOS 学习沉淀成长分享 管理 CISCO IOS 红茶三杯 ( 朱 SIR) 红茶三杯 ( 朱 SIR) 微博 : t.sina.com/vinsoney Latest update: 2012-06-01 课程目标 CISCO 路由器及启动过程 CISCO IOS 介绍 CISCO IOS 路由器基础实验 CISCO 路由器及启动过程 路由器组件 路由器启动过程 路由器组件 路由器组件及功能 CPU 执行操作系统的指令

More information

一.NETGEAR VPN防火墙产品介绍

一.NETGEAR VPN防火墙产品介绍 NETGEAR VPN NETGEAR 6 http://www.netgear.com.cn - 1 - NETGEAR VPN... 4 1.1 VPN...4 1.2 Dynamic Domain Name Service...4 1.3 Netgear VPN...4 Netgear VPN... 6 2.1 FVS318 to FVS318 IKE Main...7 2.1.1 A VPN

More information

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南

Symantec™ Sygate Enterprise Protection 防护代理安装使用指南 Symantec Sygate Enterprise Protection 防 护 代 理 安 装 使 用 指 南 5.1 版 版 权 信 息 Copyright 2005 Symantec Corporation. 2005 年 Symantec Corporation 版 权 所 有 All rights reserved. 保 留 所 有 权 利 Symantec Symantec 徽 标 Sygate

More information

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco

Windows RTEMS 1 Danilliu MMI TCP/IP QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos eco Windows RTEMS 1 Danilliu MMI TCP/IP 80486 QEMU i386 QEMU ARM POWERPC i386 IPC PC104 uc/os-ii uc/os MMI TCP/IP i386 PORT Linux ecos Linux ecos ecos ecos Email www.rtems.com RTEMS ecos RTEMS RTEMS Windows

More information

路由器配置-3

路由器配置-3 动态路由的配置 距离向量路由协议 -RIP 动态路由的配置 动态路由协议能够动态地反映网络的状态, 当网络发生变化时, 网络中的路由器会把这个消息通告给其他的路由器, 最终所有的路由器将知道网络的变化, 及时调整路由表, 从而保证数据包的正常传输 动态路由协议包括距离向量路由协议和链路状态路由协议 RIP 协议 OSPF 协议 距离向量路由协议原理 距离向量算法的优点是算法的开销较小, 缺点是算法的收敛较慢

More information

bbs.vlan5.com

bbs.vlan5.com 了解和配置 ip unnumbered 命令 内容 前言前提条件需求使用的组件惯例什么是无编号接口? P 和未编号 P 配置示例同一主网, 不同子网不同的主网, 没有子网带有子网的主网, 没有子网的主网两个不同的主网和它们各自的子网相关信息 前言 本文档介绍无编号 P 的概念, 并提供几个配置示例以供参考 通过 ip unnumbered 配置命令, 您可以在串行接口上启用 P 处理, 而无需为该接口分配明确的

More information

RG-NBS5816XS交换机RGOS 10.4(3)版本WEB管理手册

RG-NBS5816XS交换机RGOS 10.4(3)版本WEB管理手册 Web 配 置 手 册 NBS 5816XS 交 换 机 RGOS 10.4(3) 文 档 版 本 号 :V1.0 技 术 支 持 4008-111-000 http://webchat.ruijie.com.cn 版 权 声 明 福 建 星 网 锐 捷 网 络 有 限 公 司 2015 锐 捷 网 络 有 限 公 司 版 权 所 有, 并 保 留 对 本 手 册 及 本 声 明 的 一 切 权 利

More information

IP Access Lists IP Access Lists IP Access Lists

IP Access Lists IP Access Lists IP Access Lists Chapter 10 Access Lists IP Access Lists IP Access Lists IP Access Lists Security) IP Access Lists Access Lists (Network router For example, RouterA can use an access list to deny access from Network 4

More information

Microsoft Word - 目錄.doc

Microsoft Word - 目錄.doc xxvii 簡 介 本 書 涵 蓋 相 當 廣 泛 的 網 路 主 題, 示 範 Cisco 路 由 器 的 設 定 方 式, 並 解 說 如 何 判 斷 設 定 的 功 能 是 否 生 效 因 此 本 書 很 適 合 作 為 IP 路 由 與 IP 路 由 協 定 的 參 考 用 書 不 過, 因 本 書 屬 於 Cisco Press 專 業 認 證 手 冊 系 列 叢 書 之 一, 故 協 助

More information

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10

Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10 Serial ATA ( Silicon Image SiI3114)...2 (1) SATA... 2 (2) B I O S S A T A... 3 (3) RAID BIOS RAID... 5 (4) S A T A... 8 (5) S A T A... 10 Ác Åé å Serial ATA ( Silicon Image SiI3114) S A T A (1) SATA (2)

More information

Microsoft Word - chp19IS-IS.doc

Microsoft Word - chp19IS-IS.doc 第 19 章 IS-IS 近几年来, 随着在 ISP 中的广泛应用,IS(Intermediate System, 中间系统 )-IS 路由协议已经变得很普及 IS-IS 最初是由国际标准化组织制定的一个 OSI( 开放系统互联 ) 路由协议, 被设计成工作在 OSI 无连接网络服务 (CLNS) 的环境中 19.1.1 IS-IS 特点 19.1 IS-IS 概述 IS-IS 是一个非常灵活的路由协议,

More information

ebook71-13

ebook71-13 13 I S P Internet 13. 2. 1 k p p p P P P 13. 2. 2 1 3. 2. 3 k p p p 1 3. 2. 4 l i n u x c o n f P P P 13. 2. 5 p p p s e t u p 13. 2. 6 p p p s e t u p P P P 13. 2. 7 1 3. 2. 8 C a l d e r a G U I 13.

More information

地址分配表 设备 接口 IP 地址 子网掩码 默认网关 WEST G0/ N/A S0/0/0 (DCE) N/A Tunnel N/A I

地址分配表 设备 接口 IP 地址 子网掩码 默认网关 WEST G0/ N/A S0/0/0 (DCE) N/A Tunnel N/A I 拓扑 2014 思科和 / 或其附属公司 保留所有权利 本文档所含内容为思科公开发布的信息 第 1 页, 共 7 页 地址分配表 设备 接口 IP 地址 子网掩码 默认网关 WEST G0/1 172.16.1.1 255.255.255.0 N/A S0/0/0 (DCE) 10.1.1.1 255.255.255.252 N/A Tunnel0 172.16.12.1 255.255.255.252

More information

H3C ISATAP 隧道和 6to4 隧道相结合使用的典型配置举例 Copyright 2017 新华三技术有限公司版权所有, 保留一切权利 非经本公司书面许可, 任何单位和个人不得擅自摘抄 复制本文档内容的部分或全部, 并不得以任何形式传播 本文档中的信息可能变动, 恕不另行通知

H3C ISATAP 隧道和 6to4 隧道相结合使用的典型配置举例 Copyright 2017 新华三技术有限公司版权所有, 保留一切权利 非经本公司书面许可, 任何单位和个人不得擅自摘抄 复制本文档内容的部分或全部, 并不得以任何形式传播 本文档中的信息可能变动, 恕不另行通知 H3C ISATAP 隧道和 6to4 隧道相结合使用的典型配置举例 Copyright 2017 新华三技术有限公司版权所有, 保留一切权利 非经本公司书面许可, 任何单位和个人不得擅自摘抄 复制本文档内容的部分或全部, 并不得以任何形式传播 本文档中的信息可能变动, 恕不另行通知 目录 1 简介 1 2 配置前提 1 3 ISATAP 隧道和 6to4 隧道相结合使用的典型配置举例 1 3.1

More information

目录 目录... I BOSON NETSIM 入门进阶 实战 BOSON NETSIM 基本实验 路由器基本实验 - 静态路由 缺省路由配置 交换机基本实验 -VLAN VTP TRUNK 远程访问基本实验 -PPP CHAP...11

目录 目录... I BOSON NETSIM 入门进阶 实战 BOSON NETSIM 基本实验 路由器基本实验 - 静态路由 缺省路由配置 交换机基本实验 -VLAN VTP TRUNK 远程访问基本实验 -PPP CHAP...11 目录 目录... I BOSON NETSIM 入门进阶 实战...1 1 BOSON NETSIM 基本实验...1 1.1 路由器基本实验 - 静态路由 缺省路由配置...1 1.2 交换机基本实验 -VLAN VTP TRUNK...7 1.3 远程访问基本实验 -PPP CHAP...11 2 BOSON NETSIM 进阶实验...15 2.1 ISDN 传统 DDR 配置 (Legacy

More information

升 级 过 程 概 述 Cisco 集 中 无 线 网 络 架 构 中,AP 工 作 在 瘦 AP(LAP) 模 式 LAP 关 联 到 无 线 控 制 器 (WLC), 控 制 器 管 理 着 配 置 软 件 升 级 以 及 802.1X 认 证 等 控 制 处 理 ; 此 外, 控 制 器 还

升 级 过 程 概 述 Cisco 集 中 无 线 网 络 架 构 中,AP 工 作 在 瘦 AP(LAP) 模 式 LAP 关 联 到 无 线 控 制 器 (WLC), 控 制 器 管 理 着 配 置 软 件 升 级 以 及 802.1X 认 证 等 控 制 处 理 ; 此 外, 控 制 器 还 本 文 档 将 通 过 以 下 章 节 描 述 如 何 将 胖 AP 升 级 为 瘦 AP, 并 与 WLC 进 行 通 信 : 升 级 过 程 概 述... 3 比 要 条 件... 3 重 要 事 项... 5 升 级 准 备 工 作... 5 基 础 环 境 准 备... 6 使 用 DHCP Option 43 参 数... 7 控 制 器 的 准 备 工 作... 9 升 级 步 骤...

More information

《计算机网络》实验指导书

《计算机网络》实验指导书 1 实 验 一 网 络 组 建 与 管 理 一. 实 验 目 的 1. 掌 握 平 行 双 绞 线 和 交 叉 双 绞 线 的 制 作 方 法 ( 初 级 ) 2. 掌 握 对 等 网 和 代 理 服 务 器 网 络 的 组 建 ( 初 级 ) 3. 会 用 ipconfig 和 ping 命 令 ( 初 级 ) 4. 掌 握 网 络 中 文 件 夹 共 享 和 打 印 机 共 享 ( 初 级 )

More information

实验二、路由器的基本配置

实验二、路由器的基本配置 实验十 静态路由和直连路由引入配置 一 实验目的 1. 掌握路由引入的配置 2. 理解路由引入的原理 二 应用环境 1. 在某些应用环境中需要将静态路由引入到某些动态路由协议里 三 实验设备 DCR-1751 两台 四 实验拓扑 五 实验要求 配置表 : Router-A Router-B F0/0 192.168.0.1/24 F0/0 192.168.2.1/24 S1/1 (DCE) 192.168.1.1/24

More information

ch09.PDF

ch09.PDF 9-1 / (TCP/IP) TCP/IP TCP/IP ( ) ICMP ARP RARP 9.1 TCP/IP 9.1.1 TCP/IP OSI TCP/IP (DARPA) DARPA TCP/IP UNIX Berkeley Software DistributionTCP/IP TCP/IP TCP/IP TCP/IP TCP/IP TCP/IP OSI - TCP/IP ( ) ( )

More information

Bus Hound 5

Bus Hound 5 Bus Hound 5.0 ( 1.0) 21IC 2007 7 BusHound perisoft PC hound Bus Hound 6.0 5.0 5.0 Bus Hound, IDE SCSI USB 1394 DVD Windows9X,WindowsMe,NT4.0,2000,2003,XP XP IRP Html ZIP SCSI sense USB Bus Hound 1 Bus

More information

DOS下常用的网络命令.PDF

DOS下常用的网络命令.PDF DOS .... 1.1... 1.2... DOS... 2.1 ARP... 2.2 Finger... 2.3 Ftp... 2.4 Nbtstat... 2.5 Netstat... 2.6 Ping... 2.7 Rcp... 2.8 Rexec... 2.9 Route... 2.10 Rsh... 2.11 Tftp... 2.12 Tracert... 1 1 1 1 1 2 3 4

More information

Microsoft Word - frame-relay.doc

Microsoft Word - frame-relay.doc 实验目的 1. 掌握全网格型帧中继的配置 ; 2. 掌握帧中继子端口的配置 ; 3. 掌握帧中继的流量整形 Frame-relay 实验 实验原理 一 帧中继技术概述 1. 帧中继网简述 帧中继封装方式 :cisco 和 ietf 注意 : 帧中继只工作在 OSI 的物理层和数据链路层 2. DLCI LMI 的意义和类型 DLCI 用来标识 VC( 通常是 PVC) 的数字, 在 0~1023 之间

More information

P4V88+_BIOS_CN.p65

P4V88+_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 17:00:09] [Wed 12/22/2004] BIOS Version : P4V88+ BIOS P1.00 Processor Type : Intel (R) Pentium (R) 4 CPU 2.40 GHz Processor

More information

P4Dual-915GL_BIOS_CN.p65

P4Dual-915GL_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date Total Memory DIMM 1 DIMM 2 [ 14:00:09] [Wed 01/05/2005] BIOS Version : P4Dual-915GL BIOS P1.00 Processor Type : Intel (R) Pentium

More information

775i65PE_BIOS_CN.p65

775i65PE_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 14:00:09] [Wed 10/20/2004] BIOS Version : 775i65PE BIOS P1.00 Processor Type : Intel (R) CPU 3.20 GHz Processor Speed : 3200

More information

P4VM800_BIOS_CN.p65

P4VM800_BIOS_CN.p65 1 Main H/W Monitor Boot Security Exit System Overview System Time System Date [ 17:00:09] [Fri 02/25/2005] BIOS Version : P4VM800 BIOS P1.00 Processor Type : Intel (R) Pentium (R) 4 CPU 2.40 GHz Processor

More information

Cisco 职 业 认 证 培 训 系 列 CISCO CAREER CERTIFICATIONS CCNA ICND2(200-101) 认 证 考 试 指 南 ( 第 4 版 ) 美 Wendell Odom 著 纪 小 玲 马 东 芳 译 人 民 邮 电 出 版 社 北 京

Cisco 职 业 认 证 培 训 系 列 CISCO CAREER CERTIFICATIONS CCNA ICND2(200-101) 认 证 考 试 指 南 ( 第 4 版 ) 美 Wendell Odom 著 纪 小 玲 马 东 芳 译 人 民 邮 电 出 版 社 北 京 CCNA ICND2 (200-101) Cisco职业认证培训系列 CISCO CAREER CERTIFICATIONS 认证考试指南 第4版 超值赠送 CCENT CCNA 生成树协议 LAN交换的故障排查 IPv4路由 VPN 本书内容全面 条理清晰 包含如下内容 得到验证的常规考前准备计划 可帮助你通过考试 我已经知道了吗 中的小测验可以帮助你确定本章所花的学习时间 广域网和帧中继 IPv6的实施和故障排查

More information

机密等级:受控

机密等级:受控 V.0 版 [ 高 职 方 案 B] 锐 捷 网 络 大 学 - - 目 录 一 文 档 说 明... 错 误! 未 定 义 书 签 二 职 业 能 力 分 析... 3 三 教 学 指 导 方 案... 3. 课 程 规 划... 3.2 课 程 实 训 设 备... 3.3 教 材 简 介... 3. 规 划... 7 四 推 荐 认 证... 5 五 相 关 服 务... 5 - - 2 一

More information

9 Internet 10 Internet

9 Internet 10 Internet 1 2 3 4 5 6 Internet 7 8 9 Internet 10 Internet 11 12 1 1.1 1.2 1.3 1.4 1.5 1.6 1.1 1.1.1 20 50 20 60 ARPANET ARPANET Internet 20 70 ISO International Organization for Standardization TCP/IP 20 90 Internet

More information