有類路由協議

在學習RIP的時候,對有類路由不是很瞭解,看了網上的一篇文章,再加上自己的一點理解


動態路由協議包括 有類路由協議(常見的就是RIP v1等)和無類路由協議(常見的RIP v2OSPF等)兩種

 

有類路由協議的特點:
1、  路由更新時不攜帶子網掩碼
2、  自動彙總默認開啓,即使關閉也不起作用
有類路由協議的原理:
1、  當路由協議收到路由後,如果該路由與路由器接受端口的IP地址,在同一主網(比如:172.16.1.0/24172.16.2.0/24在同一主網嗎?當然是,因爲我們知道這兩段地方屬於B類,掩碼就是16位,所以都是172.16.0.0/16段的地址;再比如172.16.1.0/24172.18.2.0/24在同一主網嗎?當然不是,爲什麼呢?原因很簡單,因爲一個屬於172.16.0.0/16,另一個屬於172.18.0.0/16),使用該端口的掩碼作爲路由掩碼。
2、  當路由協議收到路由後,如果該路由與路由器接受端口的IP地址,不在同一主網,按照“類”的連接作路由彙總。
下面以一個實例來說明這些
實驗一拓撲:
說明:R1R2R3都運行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位)爲這條路由信息的掩碼

 

 

實驗二拓撲:
說明:R1R2R3都運行RIPv1,注意和上面不同的地方是R2R3的互連地址變了
配置(接口配置就不寫了)
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位)的掩碼

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章