实验一拓扑:
说明:R1、R2、R3都运行RIPv1
配置(接口配置就不写了)
R1
r1(config)#router rip
r1(config-router)#network 172.16.1.0
R2
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config-router)#network 172.16.2.0
R3
r1(config)#router rip
r1(config-router)#network 172.16.2.0
验证:
查看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
172.16.0.0/24 is subnetted, 2 subnets
C 172.16.1.0 is directly connected, Serial1/1
R 172.16.2.0 [120/1] via 172.16.1.2, 00:00:00, Serial1/1
10.0.0.0/16 is subnetted, 1 subnets
C 10.1.0.0 is directly connected, Loopback0
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 not set
172.16.0.0/24 is subnetted, 2 subnets
R 172.16.1.0 [120/1] via 172.16.2.1, 00:00:21, Serial1/0
C 172.16.2.0 is directly connected, Serial1/0
10.0.0.0/16 is subnetted, 1 subnets
C 10.3.0.0 is directly connected, Loopback0
结论:验证了上面的“有类路由协议原理的第1条”,我们来分析一下,R1接收到R2发给自己的路由172.16.0.0(为什么是这个,而不是172.16.2.0呢?这是因为在有类路由协议RIPv1不支持VLSM,而且为自己汇集,就成了172.16.0.0),发现和自己收到此信息的接口在同一主网,所以采用此接口的掩码(24位)为这条路由信息的掩码
实验二拓扑:
说明:R1、R2、R3都运行RIPv1,注意和上面不同的地方是R2与R3的互连地址变了
配置(接口配置就不写了)
R1
r1(config)#router rip
r1(config-router)#network 172.16.1.0
R2
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config-router)#network 172.18.2.0
R3
r1(config)#router rip
r1(config-router)#network 172.18.2.0
验证:
查看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
172.16.0.0/24 is subnetted, 1 subnets
C 172.16.1.0 is directly connected, Serial1/1
R 172.18.0.0/16 [120/1] via 172.16.1.2, 00:00:13, Serial1/1
10.0.0.0/16 is subnetted, 1 subnets
C 10.1.0.0 is directly connected, Loopback0
查看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, 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
R 172.16.0.0/16 [120/1] via 172.18.2.1, 00:00:07, Serial1/0
172.18.0.0/24 is subnetted, 1 subnets
C 172.18.2.0 is directly connected, Serial1/0
10.0.0.0/16 is subnetted, 1 subnets
C 10.3.0.0 is directly connected, Loopback0
总结:注意到实验二R1上学到的172.18.0.0/16的路由,R2上学到的172.16.0.0/16的路由了吗?为什么现在学到的掩码是16位的,而实验一学到的是掩码都是24位的?这正验证了上面的“有类路由协议原理的第2条”,我们来分析一下,R1接收到R2发给自己的路由172.18.0.0(为什么是这个,而不是172.18.2.0呢?这是因为在有类路由协议RIPv1不支持VLSM,而且为自己汇集,就成了172.18.0.0),发现和自己收到此信息的接口不在同一主网,所以采用这个网段所在“类”(172.18.0.0属于B类地址,默认的掩码是16位)的掩码