1、实验三 路由协议实验三 路由协议3.1 实验目的:1熟悉主机的路由配置;2熟悉路由器的路由配置;3掌握RIP协议的基本配置;4掌握IGRP协议的基本配置;5区别以上两种路由协议的特点。3.2 实验环境实际组网中路由器是用来连接两个物理网络的,为了模拟实际环境,我们在实验中采用背靠背直接相连来模拟广域网连接。由于时间限制,让我们先完成几个简单的背靠背实验,每个对应一个相对独立的内容。如果时间充足,可以完成后面的综合性实验,进一步提高动手能力,深层理解路由协议。下面是简单实验的模拟实验环境,共两台路由器,一台交换机,两台PC。按照上图的实验组网建立实验环境。为了不受路由器原来的配置影响,在实验之前
2、请先将所有路由器的配置数据擦除后重新启动。交换机在此只用作连接主机和路由器用,以便全采用标准网线连接,不需配置。3.3实验步骤:3.3.1静态路由清空路由器的原有配置QuidwayenableQuidway#eraseQuidway#reboot重新启动路由器后,查看初始配置并显示路由表如下:Quidway#show running-config Now create configuration. Current configuration ! version 1.5.6 ! interface Aux0 async mode interactive encapsulation ppp ! i
3、nterface Ethernet0 speed auto duplex auto no loopback ! interface Serial0 encapsulation ppp ! interface Serial1 encapsulation ppp ! endQuidway#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0 127.0.0.1/32 Direct 0 0 127.0.0.
4、1 LoopBack0配置路由器接口和PC的IP地址路由器各接口的IP地址如下:RTARTBE0202.0.0.1/24202.0.1.1/24S0192.0.0.1/24192.0.0.2/24PC的IP地址和缺省网关Gateway如下:PCAPCBIP202.0.0.2/24202.0.1.2/24Gateway202.0.0.1202.0.1.1为了标识路由器,我们修改路由器名称分别为RTA、RTB并按照上述表格完成IP地址的配置之后,再次查看配置信息和路由表信息如下:RTA#show running-config Now create configuration. Current co
5、nfiguration ! version 1.5.6 hostname RTA ! interface Aux0 async mode interactive encapsulation ppp ! interface Ethernet0 speed auto duplex auto no loopback ip address 202.0.0.1 255.255.255.0 ! interface Serial0 encapsulation ppp ip address 192.0.0.1 255.255.255.0 ! interface Serial1 encapsulation pp
6、p ! endRTA(config-if-Serial0)#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.2 Serial0 192.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.2/32 Di
7、rect 0 0 192.0.0.2 Serial0 202.0.0.0/24 Direct 0 0 202.0.0.1 Ethernet0202.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0RTB的相关信息类似RTA,可以自己在实验中显示比较。注意:串口的配置需要在接口配置模式下完成shutdown和no shutdown命令之后才生效。完成上述配置之后,用ping命令测试网络互通性,会发现两个以太网段不能互通。你知道为什么吗?仔细看看路由表就可以明白,路由器还没有相关的路由项。在这里我们采用配置静态路由的办法来添加路由。分别在RTA,RTB上配置到对端以太
8、网段的静态路由,RTA的配置信息和路由表信息如下:RTA(config)#show running-config Now create configuration. Current configuration ! version 1.5.6 hostname RTA ! interface Aux0 async mode interactive encapsulation ppp ! interface Ethernet0 speed auto duplex auto no loopback ip address 202.0.0.1 255.255.255.0 ! interface Seri
9、al0 encapsulation ppp ip address 192.0.0.1 255.255.255.0 ! interface Serial1 encapsulation ppp ! exit ip route 202.0.1.0 255.255.255.0 192.0.0.2 preference 60 ! endRTA(config)#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0
10、 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.2 Serial0 192.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.2/32 Direct 0 0 192.0.0.2 Serial0 202.0.0.0/24 Direct 0 0 202.0.0.1 Ethernet0 202.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0202.0.1.0/24 Static 60 0 192.0.0.2 Seria
11、l0RTB的相关信息类似RTA。比较前后路由表发现现在新增了一项静态路由,此时再测试网络互通性,可以ping通了吗?3.3.2 RIP协议在上面的实验基础上,删除静态路由的配置之后再启动RIP协议,显示配置信息和路由表信息如下:RTA的配置和路由表:RTA#show running-config Now create configuration. Current configuration ! version 1.5.6 hostname RTA ! interface Aux0 async mode interactive encapsulation ppp ! interface Ethe
12、rnet0 speed auto duplex auto no loopback ip address 202.0.0.1 255.255.255.0 ! interface Serial0 encapsulation ppp ip address 192.0.0.1 255.255.255.0 ! interface Serial1 encapsulation ppp ! exit router rip network all ! endRTA#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop In
13、terface 127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.2 Serial0 192.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.2/32 Direct 0 0 192.0.0.2 Serial0 202.0.0.0/24 Direct 0 0 202.0.0.1 Ethernet0 202.0.0.1/32 Direct 0 0 127.0.0.1
14、 LoopBack0202.0.1.0/24 RIP 100 1 192.0.0.2 Serial0RTB的配置和路由表:RTB#show running-config Now create configuration. Current configuration ! version 1.5.6 hostname RTB ! interface Aux0 async mode interactive encapsulation ppp ! interface Ethernet0 speed auto duplex auto no loopback ip address 202.0.1.1 25
15、5.255.255.0 ! interface Serial0 clock-select DTECLK1 encapsulation ppp ip address 192.0.0.2 255.255.255.0 ! interface Serial1 encapsulation ppp ! exit router rip network all ! endRTB#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 127.0.0.0/8 Direct 0 0 127.0.0.1 Lo
16、opBack0 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.1 Serial0 192.0.0.1/32 Direct 0 0 192.0.0.1 Serial0 192.0.0.2/32 Direct 0 0 127.0.0.1 LoopBack0 202.0.0.0/24 RIP 100 1 192.0.0.1 Serial0 202.0.1.0/24 Direct 0 0 202.0.1.1 Ethernet0 202.0.1.1/32 Direct 0 0 127.0.0.1 L
17、oopBack0测试网络互通性,应该是全网互通的。如果不是,请检查您的配置是否与上面的一致。现在我们可以看看RIP是怎样发现路由的,再特权模式下打开RIP协议调试开关,有如下信息在路由器之间传递,它们完成了路由的交换,并形成新的路由。RTA#debug ip rip packet /打开RIP协议调试开关; Rip packet debugging is onRTA#configure Enter configuration commands, one per line. End with command exit!RTA(config)#logging console /使调试信息从cons
18、ole口输出;RTA(config)# RIP: send from 192.0.0.1 to 255.255.255.255(Serial0)Packet:vers 1, cmd Response, length 24 dest 202.0.0.0 ,Metric 1 RIP:receive Response from 192.0.0.2(Serial0)Packet:vers 1, cmd Response, length 24 dest 202.0.1.0 ,Metric 1从上面的信息可以看到RIP协议版本为version 1,这是华为路由器的默认版本。可以用ip rip versio
19、n 2 mcast命令改变协议版本,再查看debug信息如下: RTA#debug ip rip packet Rip packet debugging is onRTA# RIP:receive Response from 192.0.0.2(Serial0)Packet:vers 2, cmd Response, length 24 dest 202.0.1.0 mask 255.255.255.0,router 0.0.0.0 ,metric 1 RIP: send from 192.0.0.1 to 224.0.0.9(Serial0)Packet:vers 2, cmd Respon
20、se, length 24 dest 202.0.0.0 mask 255.255.255.0,router 0.0.0.0 ,metric 1然后使用ip rip version 2 bcast命令改变协议报文的发送方式为广播方式,查看debug信息如下:RTA#debug ip rip packet Rip packet debugging is onRTA# RIP:receive Response from 192.0.0.2(Serial0)Packet:vers 2, cmd Response, length 24 dest 202.0.1.0 mask 255.255.255.0
21、,router 0.0.0.0 ,metric 1 RIP: send from 192.0.0.1 to 255.255.255.255(Serial0)Packet:vers 2, cmd Response, length 24 dest 202.0.0.0 mask 255.255.255.0,router 0.0.0.0 ,metric 1比较以上三种情况的debug信息,能够发现它们的异同吗?广播地址是什么,组播地址又是什么?华为路由器的默认状态启动了水平分割功能,在以上配置基础上,关闭水平分割(RTA(config-if-Serial0)#no ip rip split)再看看de
22、bug信息有什么变化吗?RTA#debug ip rip packet Rip packet debugging is onRTA# RIP:receive Response from 192.0.0.2(Serial0)Packet:vers 2, cmd Response, length 44 dest 202.0.0.0 mask 255.255.255.0,router 0.0.0.0 ,metric 2 dest 202.0.1.0 mask 255.255.255.0,router 0.0.0.0 ,metric 1 RIP: send from 192.0.0.1 to 255.
23、255.255.255(Serial0)Packet:vers 2, cmd Response, length 44 dest 202.0.1.0 mask 255.255.255.0,router 0.0.0.0 ,metric 2 dest 202.0.0.0 mask 255.255.255.0,router 0.0.0.0 ,metric 1我们比较发现关闭水平分割时,交换的路由信息增加了,这就是水平分割的作用。水平分割规定不能将从某一网关送来的路由信息再送回此网关,这就是为什么关闭水平分割时交换的路由信息增加了。下面我们再来理解验证路由器的自动聚合功能。先修改各路由器的E0口的IP地
24、址如下:RTARTBE010.0.1.1/2410.0.2.1/24显示路由器配置信息和路由表信息如下:RTA#show running-config Now create configuration. Current configuration ! version 1.5.6 logging console hostname RTA ! interface Aux0 async mode interactive encapsulation ppp ! interface Ethernet0 speed auto duplex auto no loopback ip address 10.0.
25、1.1 255.255.255.0 ! interface Serial0 encapsulation ppp ip address 192.0.0.1 255.255.255.0 ip rip version 2 bcast ! interface Serial1 encapsulation ppp ! exit router rip network all ! endRTA#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 10.0.1.0/24 Direct 0 0 10.0
26、.1.1 Ethernet0 10.0.1.1/32 Direct 0 0 127.0.0.1 LoopBack0 127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBack0 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.2 Serial0 192.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0192.0.0.2/32 Direct 0 0 192.0.0.2 Serial0然后在协议配置模式下关闭自动聚合功能,显示路由表信息如下:
27、RTA(config-router-rip)#no auto-summaryRTA(config-router-rip)#show ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 10.0.1.0/24 Direct 0 0 10.0.1.1 Ethernet0 10.0.1.1/32 Direct 0 0 127.0.0.1 LoopBack0 10.0.2.0/24 RIP 100 1 192.0.0.2 Serial0 127.0.0.0/8 Direct 0 0 127.0.0.1
28、 LoopBack0 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.2 Serial0 192.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.2/32 Direct 0 0 192.0.0.2 Serial0比较前后两次的路由表信息,会发现关闭自动聚合功能时增加了一条动态路由,知道为什么吗?然后改变协议版本(ip rip version 1)并使之生效,并在关闭和启动自动聚合功能下显示路由表信息会发现都没有动态路由项产生,知道为什么吗?因为
29、version 1不支持可变长子网掩码,而10.0.1.1与10.0.2.1属于A类地址,自然掩码为8位,属于同一网段的地址。路由表信息如下:RTA(config-if-Serial0)#sho ip routeRouting Tables: Destination/Mask Proto Pref Metric Nexthop Interface 10.0.1.0/24 Direct 0 0 10.0.1.1 Ethernet0 10.0.1.1/32 Direct 0 0 127.0.0.1 LoopBack0 127.0.0.0/8 Direct 0 0 127.0.0.1 LoopBac
30、k0 127.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0 192.0.0.0/24 Direct 0 0 192.0.0.2 Serial0 192.0.0.1/32 Direct 0 0 127.0.0.1 LoopBack0192.0.0.2/32 Direct 0 0 192.0.0.2 Serial0你还可以在接口配置模式下配置命令ip rip version 2 mcast后,显示路由表信息看看又是什么情况。比较上述几种情况下的路由信息,总结version 1和version 2的异同,mcast和bcast的异同以及水平分割和自动聚合的功能。3.3.3 IGRP协议IGRP协议是RIP协议的改进型距离矢量路由协议,但它有更加准确的综合路有权,适用于更大的网络。下面我们就来研究一下IGRP协议,实验环境同上,将路由器和PC的配置恢复到做RIP协议实验之前的配置。然后启动IGRP协议,显示路由器的配置信息和路由表信息如下:RTA的相关信息:RTA#show running-config Now create configuration. Current configuration ! version 1.5.6 loggin
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1