八、RIP-连续网络中的无类路由环境
       实验拓扑:
1、ip地址表:
R1              LO/0                 192.168.10.17/28
R1              S2/0                  192.168.10.5/30
R2              S2/0                  192.168.10.6/30
R2              S3/0                  192.168.10.9/30
R3              S2/0                  192.168.10.10/30
R3              LO/0                 192.168.10.33/27
 
2、
R1的配置:
R1(config)#interface loopback 0
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to upR1(config-if)#ip address 192.168.10.17 255.255.255.240// 此为28位的掩码
R1(config-if)#exit
R1(config)#interface serial 2/0
R1(config-if)#ip address 192.168.10.5 255.255.255.252// 此为30位的掩码
R1(config-if)#no shutdown
R1(config-if)#exit
R1(config)#router rip// 启动rip协议
R1(config-router)#network 192.168.10.0//通告直连网络
 
R2的配置:
R2(config)#interface serial 2/0
R2(config-if)#ip address 192.168.10.6 255.255.255.252
R2(config-if)#clock rate 64000
R2(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial2/0, changed state to up
R2(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface Serial2/0, changed state to up
R2(config-if)#exit
R2(config)#interface serial 3/0
R2(config-if)#ip address 192.168.10.9 255.255.255.252
R2(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial3/0, changed state to up
R2(config-if)#exit
R2(config)#router rip// 启动rip协议,此时是由的是ripv1,v1表示版本1
R2(config-router)#network 192.168.10.0//通告直连网络
 
R3的配置:
R3(config)#interface loopback 0
%LINK-5-CHANGED: Interface Loopback0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to upR3(config-if)#ip address 192.168.10.33 255.255.255.224
R3(config-if)#exit
R3(config)#interface serial 2/0
R3(config-if)#ip address 192.168.10.10 255.255.255.252
R3(config-if)#no shutdown
%LINK-5-CHANGED: Interface Serial2/0, changed state to down
R3(config-if)#exit
R3(config)#router rip// 启动rip协议,此时是由的是ripv1,v1表示版本1
R3(config-router)#network 192.168.10.0 //通告直连网络
 
根据上个实验的结论,可见此网络结构属于连续网络!
 
在R1和R2查看路由信息结果如下:
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
     192.168.10.0/24 is variably subnetted, 3 subnets, 2 masks
C       192.168.10.4/30 is directly connected, Serial2/0
R       192.168.10.8/30 [120/1] via 192.168.10.6, 00:00:20, Serial2/0
C       192.168.10.16/28 is directly connected, Loopback0
R1#
 
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
     192.168.10.0/30 is subnetted, 2 subnets
C       192.168.10.4 is directly connected, Serial2/0
C       192.168.10.8 is directly connected, Serial3/0
R2#
 
结论:
可见R1学习到了与R2直连的/30的子网192.168.10.8/30,R2没有学习到与R1直连的/28的子网 192.168.10.16/28; RIPv1在连续网络的无类路由中只能学习到与自身直连网络的子网掩码相匹配的路由信息!
---------------------------------------------------------------------------------------------------------
上面R1、R2、R3的配置中将RIPv1改为RIPv2;
改前:(以R1为例)
R1(config)#router rip// 启动rip协议
R1(config-router)#network 192.168.10.0//通告直连网络
改后:
R1(config)#router rip// 启动rip协议
R1(config-router)#version 2// 启动ripv2协议
R1(config-router)#network 192.168.10.0//通告直连网络
 
在R1和R2查看路由信息结果如下:
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
     192.168.10.0/24 is variably subnetted, 4 subnets, 3 masks
C       192.168.10.4/30 is directly connected, Serial2/0
R       192.168.10.8/30 [120/1] via 192.168.10.6, 00:00:21, Serial2/0
C       192.168.10.16/28 is directly connected, Loopback0
R       192.168.10.32/27 [120/2] via 192.168.10.6, 00:00:21, Serial2/0
R1#
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
     192.168.10.0/24 is variably subnetted, 4 subnets, 3 masks
C       192.168.10.4/30 is directly connected, Serial2/0
C       192.168.10.8/30 is directly connected, Serial3/0
R       192.168.10.16/28 [120/1] via 192.168.10.5, 00:00:01, Serial2/0
R       192.168.10.32/27 [120/1] via 192.168.10.10, 00:00:26, Serial3/0
R2#
结论:可见R1和R2学习到了这个网络中所有的路由信息;RIPv2在连续网络的无类路由中可以学习到所有的路由信息!