實驗一拓撲:
說明:R1、R2、R3都運行RIPv1
配置(接口配置就不寫了)
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config-router)#network 172.16.2.0
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(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config)#router rip
r1(config-router)#network 172.16.1.0
r1(config-router)#network 172.18.2.0
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位)的掩碼