实验一拓扑:
说明:
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
位)的掩码