RIP

第 4 章 RIP

動態路由協議包括距離向量路由協議和鏈路狀態路由協議。RIP(Routing Information

Protocols,路由信息協議)是使用最廣泛的距離向量路由協議。RIP 是爲小型網絡環境設

計的,因爲這類協議的路由學習及路由更新將產生較大的流量,佔用過多的帶寬。

4.1 RIP 概述

RIP 是由 Xerox 在 70 年代開發的,最初定義在 RFC1058 中。RIP 用兩種數據包傳輸更新:

更新和請求,每個有 RIP 功能的路由器默認情況下每隔 30 秒利用 UDP 520 端口向與它直連

的網絡鄰居廣播(RIP v1)或組播(RIP v2)路由更新。因此路由器不知道網絡的全局情況,

如果路由更新在網絡上傳播慢,將會導致網絡收斂較慢,造成路由環路。爲了避免路由環路,

RIP 採用水平分割、毒性逆轉、定義最大跳數、閃式更新、抑制計時 5 個機制來避免路由環

路。

RIP 協議分爲版本 1 和版本 2。不論是版本 1 或版本 2,都具備下面的特徵:

1. 是距離向量路由協議;

2. 使用跳數(Hop Count)作爲度量值;

3.默認路由更新週期爲 30 秒;

4. 管理距離(AD)爲 120;

5. 支持觸發更新;

6. 最大跳數爲 15 跳;

7. 支持等價路徑,默認 4 條,最大 6 條;

8. 使用 UDP520 端口進行路由更新。

而 RIPv1 和 RIPv2 的區別如表 4-1。

表 4-1 RIPv1 和 RIPv2 的區別

RIPv1  RIPv2

表 4-1 RIPv1 和 RIPv2 的區別

RIPv1  RIPv2

在路由更新的過程中不攜帶子網信息  在路由更新的過程中攜帶子網信息

不提供認證  提供明文和 MD5 認證

不支持 VLSM 和 CIDR  支持 VLSM 和 CIDR

採用廣播更新  採用組播(224.0.0.9)更新

有類別(Classful)路由協議  無類別(Classless)路由協議

4.2 RIPv1

4.2.1 實驗 1:RIPv1 基本配置

1.實驗目的

通過本實驗可以掌握:

(1)在路由器上啓動 RIPv1 路由進程

(2)啓用參與路由協議的接口,並且通告網絡

(3)理解路由表的含義

(4)查看和調試 RIPv1 路由協議相關信息

2.拓撲結構

實驗拓撲如圖 4-1 所示。

圖 4-1 RIPv1 的基本配置

3.實驗步驟

(1)步驟 1:配置路由器 R1

R1(config)# router rip //啓動 RIP 進程

R1(config-router)# version 1 //配置 RIP 版本 1

R1(config-router)# network 1.0.0.0 //通告網絡

R1(config-router)# network 192.168.12.0

(2)步驟 2:配置路由器 R2

R2(config)# router rip

R2(config-router)# version 1

R2(config-router)# network 192.168.12.0

R2(config-router)# network 192.168.23.0

(3)步驟 3:配置路由器 R3

R3(config)# router rip

R3(config-router)# version 1

R3(config-router)# network 192.168.23.0

R3(config-router)# network 192.168.34.0

(4)步驟 4:配置路由器 R4

R4(config)# router rip

R4(config-router)# version 1

R4(config-router)# network 192.168.34.0

R4(config-router)# network 4.0.0.0

4.實驗調試

(1)  show ip route

該命令用來查看路由表。

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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

R 4.0.0.0/8 [120/3] via 192.168.12.2, 00:00:03, Serial0/0/0

R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:03, Serial0/0/0

R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:03, Serial0/0/0

R 4.0.0.0/8 [120/3] via 192.168.12.2, 00:00:03, Serial0/0/0

R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:03, Serial0/0/0

R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:03, Serial0/0/0

以上輸出表明路由器 R1 學到了 3 條 RIP 路由,其中路由條目“R 4.0.0.0/8 [120/3]

via 192.168.12.2, 00:00:03, Serial0/0/0

R 4.0.0.0/8 [120/3]

via 192.168.12.2, 00:00:03, Serial0/0/0”的含義如下:

① R:路由條目是通過 RIP 路由協議學習來的;

② 4.0.0.0/8 :目的網絡;

③ 120:RIP 路由協議的默認管理距離;

④ 3: 度量值,從路由器 R1 到達網絡 4.0.0.0/8 的度量值爲 3 跳;

⑤ 192.168.12.2:下一跳地址;

⑥ 00:00:03:距離下一次更新還有 27(30-3)秒;

⑦ Serial0/0/0:接收該路由條目的本路由器的接口。

同時通過該路由條目的掩碼長度可以看到,RIPv1 確實不傳遞子網信息。

(2)show ip protocols

該命令查看 IP 路由協議配置和統計信息。

R1# show ip protocols

【注意 】

“//”後的信息表示註釋,不是輸出內容。

Routing Protocol is "rip"

//路由器上運行的路由協議是 RIP

Outgoing update filter list for all interfaces is not set

//在出方向上沒有設置過濾列表

Incoming update filter list for all interfaces is not set

//在入方向上沒有設置過濾列表

Sending updates every 30 seconds, next due in 23 seconds

//更新週期是 30 秒,距離下次更新還有 23 秒

【注意 】

爲了防止更新同步,RIP 會以 15%的誤差發送更新,即實際發送更新的週期的範圍是

25.5-30 秒。

Invalid after 180 seconds, hold down 180, flushed after 240

// invalid after:路由條目如果在 180 秒還沒有收到更新,則被標記爲無效

【技術要點 】

被標記爲無效的路由條目類似如下所示:

R 4.0.0.0/8 is possibly down, routing via 192.168.12.2, Serial0/0/0

可以通過很多方式使路由條目進入無效週期,例如在接口上加拒絕接收 UDP520 端口的

ACL,還比如將接口設置爲被動接口等。

// hold down:抑制計時器的時間爲 180 秒

// flushed after:路由條目如果在 240 秒還沒有收到更新,則從路由表中刪除此路由條目

【提示 】

可以通過下面的命令來調整以上三個時間參數:

R1(config-router)# timers basic  update invalid holddown flushed

Redistributing: rip

//只運行 RIP協議,沒有其它的協議重分佈進來

Default version control: send version 1, receive version 1

//默認發送版本 1 的路由更新,接收本版 1 的路由更新

Interface Send Recv Triggered RIP Key-chain

Serial0/0/0 1 1

Loopback0 1 1

//以上三行顯示了運行 RIP協議的接口,以及可以接收和發送的 RIP路由更新的版本

Automatic network summarization is in effect

//RIP 路由協議默認開啓自動彙總功能

Maximum path: 4

//RIP 路由協議可以支持 4 條等價路徑,最大爲 6 條

【提示 】

可以通過下面的命令來修改 RIP 路由協議支持等價路徑的條數:

R1(config-router)# maximum-paths number-paths

Routing for Networks:

1.0.0.0

192.168.12.0

//以上三行表明 RIP 通告的網絡

Routing Information Sources:

Gateway Distance Last Update

192.168.12.2 120 00:00:03

//以上三行表明路由信息源,其中:

// gateway:學習路由信息的路由器的接口地址,也就是下一跳地址

// distance:管理距離

// last update:更新發生在多長時間以前

Distance: (default is 120)

//默認管理距離是 120

(3)debug ip rip

該命令可以查看 RIP 路由協議的動態更新過程。

R1#clear ip route *

R1#debug ip rip

clear ip route *

R1#debug ip rip

Feb 9 12:43:13.311: RIP: sending request on Serial0/0/0 to 255.255.255.255

Feb 9 12:43:13.315: RIP: sending request on Loopback0 to 255.255.255.255

Feb 9 12:43:13.323: RIP:  received v1 update from 192.168.12.2 on  Serial0/0/0

Feb 9 12:43:13.323: 4.0.0.0 in 3 hops

Feb 9 12:43:13.323: 192.168.23.0 in 1 hops

Feb 9 12:43:13.323: 192.168.34.0 in 2 hops

Feb 9 12:43:15.311: RIP:  sending v1 flash update to  255.255.255.255 via  Loopback0 (1.1.1.1)

Feb 9 12:43:15.311: RIP: build flash update entries

Feb 9 12:43:15.311: network 4.0.0.0 metric 4

Feb 9 12:43:15.311: network 192.168.12.0 metric 1

Feb 9 12:43:15.311: network 192.168.23.0 metric 2

Feb 9 12:43:15.311: network 192.168.34.0 metric 3

Feb 9 12:43:15.311: RIP:  sending v1 flash update to  255.255.255.255 via  Serial0/0/0

(192.168.12.1)

Feb 9 12:43:15.311: RIP: build flash update entries

Feb 9 12:43:15.311: network 1.0.0.0 metric 1

通過以上輸出,可以看到 RIPv1 採用廣播更新(255.255.255.255),分別向 Loopback0

和 s0/0/0 發送路由更新,同時從 s0/0/0 接收三條路由更新,分別是 4.0.0.0,度量值是 3

跳;192.168.34.0, 度量值是 2 跳;192.168.23.0,度量值是 1 跳。

【技術要點】

flash update

flash update(閃式更新)指的是當網絡上某個路徑的度量值發生變化,路由器立即

發出更新信息,而不管是否到達常規路由信息更新的週期。

4.2.2 實驗 2:被動接口與單播更新

1.實驗目的

通過本實驗可以掌握:

(1)被動接口的含義、配置和應用場合

(2)單播更新的應用場合和配置

2.拓撲結構

實驗拓撲如圖 4-2 所示。

圖 4-2 配置被動接口

由於以太口 g0/0 和 g0/1 連接主機,不需要向這些接口發送路由更新,所以可以考慮將

路由器的該接口設置爲被動接口。

3.實驗步驟

(1)步驟 1:配置路由器 R1

R1(config)# router rip

R1(config-router)# version 1

R1(config-router)# network 10.0.0.0

R1(config-router)# network 172.16.0.0

R1(config-router)# network 192.168.12.0

R1(config-router)# passive-interface GigabitEthernet0/0

R1(config-router)# passive-interface GigabitEthernet0/1

(2)步驟 2:配置路由器 R2

R2(config)# router rip

R2(config-router)# version 1

R2(config-router)# network 192.168.12.0

R2(config-router)# network 2.0.0.0

4.實驗調試

R1# debug ip rip

R1# clear ip route *

Feb 9 13:24:41.275: RIP: sending request on Serial0/0/0 to 255.255.255.255

Feb 9 13:24:41.283: RIP: received v1 update from 192.168.12.2 on Serial0/0/0

Feb 9 13:24:41.283: 2.0.0.0 in 1 hops

Feb 9 13:24:43.275: RIP: sending v1 flash update to 255.255.255.255 via  Serial0/0/0

(192.168.12.1)

Feb 9 13:24:43.275: RIP: build flash update entries

Feb 9 13:24:43.275: network 10.0.0.0 metric 1

Feb 9 13:24:43.275: network 172.16.0.0 metric 1

從以上輸出可以看出,路由器 R1 確實不向被動接口 g0/0 和 g0/1 發送路由更新。

【技術要點 】

被動接口只能接收路由更新,不能以廣播或組播方式發送更新,但是可以以單播的方式

發送更新,配置單播更新的命令如下:

R1(config-router)# neighbor  A.B.C.D

【實例 】

如圖 4-3 所示,路由器 R1 只想把路由更新送到路由器 R3 上,由於 RIPv1 路由協議採用

廣播更新,默認情況下,路由更新將發送給以太網上任何一個設備,爲了防止這種情況發生,

把路由器 R1 的 g0/0 配置成被動接口,然而路由器 R1 還想把路由更新發送給 R3,這時候必

須採用單播更新,爲指定的相鄰路由器 R3 發送路由更新。路由器 R1 具體的配置如下:

R1(config)# router rip

R1(config-router)# passive-interface GigabitEthernet0/0

R1(config-router)# neighbor 172.16.1.3

圖 4-3 配置單播更新

4.2.3 實驗 3:使用子網地址

1.實驗目的

通過本實驗可以掌握:

(1)RIPv1 使用子網地址的條件

(2)RIPv1 接收子網路由的原則

2.拓撲結構

實驗拓撲如圖 4-4 所示。

圖 4-4 RIPv1 使用子網地址

3.實驗步驟

(1)步驟 1:配置路由器 R1

R1(config)# router rip

R1(config-router)# version 1

R1(config-router)# network 172.16.0.0

(2)步驟 2:配置路由器 R2

R2(config)# router rip

R2(config-router)# version 1

R2(config-router)# network 172.16.0.0

4.實驗調試

分別查看 R1、R2 的路有表:

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, 3 subnets

C 172.16.1.0 is directly connected, Loopback0

C 172.16.2.0 is directly connected, Serial0/0/0

R 172.16.3.0 [120/1] via 172.16.2.2, 00:00:03, Serial0/0/0

R2# 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, 3 subnets

R 172.16.1.0 [120/1] via 172.16.2.1, 00:00:21, Serial0/0/0

C 172.16.2.0 is directly connected, Serial0/0/0

C 172.16.3.0 is directly connected, Loopback0

從路由器 R1 和 R2 的路由表輸出可以看出,它們互相學習到了 24 位的路由條目,從而

可以說明,某些情況下 RIPv1 更新確實可以攜帶子網信息。

【技術要點 】

RIPv1 路由更新可以攜帶子網信息必須同時滿足兩個條件:

(1)整個網絡所有地址在同一個主類網絡;

(2)子網掩碼長度必須相同。

【思考 】

假如在圖 4-4 中,路由器 R2 的 s0/0/0 接口的 IP 地址的掩碼長度爲 25 位,那麼,R2

的路由表是怎樣的呢?結果如下:

R2# 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/ 16 is variably subnetted,  3 subnets, 2 masks

R 172.16.1.0/25 [120/1] via 172.16.2.1, 00:00:17, Serial0/0/0

C 172.16.2.0/25 is directly connected, Serial0/0/0

C 172.16.3.0/24 is directly connected, Loopback0

由此得出 RIP v1 接收子網路由的原則:如果路由器收到的是子網路由條目,那麼就以接

收該路由條目的接口的掩碼長度作爲該子網路由條目的掩碼長度。

4.3 RIPv2

4.3.1 實驗 4:RIPv2 基本配置

1.實驗目的

通過本實驗可以掌握:

(1)在路由器上啓動 RIPv2 路由進程

(2)啓用參與路由協議的接口,並且通告網絡

(3)auto-summary 的開啓和關閉

(4)查看和調試 RIPv2 路由協議相關信息

2.拓撲結構

實驗拓撲如圖 4-1 所示。

3.實驗步驟

(1)步驟 1:配置路由器 R1

R1(config)# router rip

R1(config-router)# version 2

R1(config-router)# no auto-summary

R1(config-router)# network 1.0.0.0

R1(config-router)# network 192.168.12.0

(2)步驟 2:配置路由器 R2

R2(config)# router rip

R2(config-router)# version 2

R2(config-router)# no auto-summary

R2(config-router)# network 192.168.12.0

R2(config-router)# network 192.168.23.0

(3)步驟 3:配置路由器 R3

R3(config)# router rip

R3(config-router)# version 2

R3(config-router)# no auto-summary

R3(config-router)# network 192.168.23.0

R3(config-router)# network 192.168.34.0

(4)步驟 4:配置路由器 R4

R4(config)# router rip

R4(config-router)# version 2

R4(config-router)# no auto-summary

R4(config-router)# network 192.168.34.0

R4(config-router)# network 4.0.0.0

4.實驗調試

(1)  show ip route

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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

4.0.0.0/8 is variably subnetted, 2 subnets, 2 masks

R 4.4.4.0/24 [120/3] via 192.168.12.2, 00:00:22, Serial0/0/0

R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:22, Serial0/0/0

R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:22, Serial0/0/0

從上面輸出的路由條目“ 4.4.4.0/24”,可以看到 RIPv2 路由更新是攜帶子網信息的。

(2)show ip protocols

R1#show ip protocols

Routing Protocol is "rip"

Outgoing update filter list for all interfaces is not set

Incoming update filter list for all interfaces is not set

Sending updates every 30 seconds, next due in 19 seconds

Invalid after 180 seconds, hold down 180, flushed after 240

Redistributing: rip

Default version control: send version 2, receive version 2

Interface Send Recv Triggered RIP Key-chain

Serial0/0/0 2 2

Loopback0 2 2

// RIPv2 默認情況下只接收和發送版本 2 的路由更新

【提示 】

可以通過命令“ ip rip send version”和“ ip rip receive version”來控制在路由

器接口上接收和發送的版本,例如在 s0/0/0 接口上接收版本 1 和 2 的路由更新,但是隻發

送版本 2 的路由更新,配置如下:

R1(config-if)# ip rip send version 2

R1(config-if)# ip rip receive version 1 2

【注意 】

接口特性是優於進程特性的,對於本實驗,雖然在 RIP 進程中配置了“ version 2” ,

但是如果在接口上配置了“ ip rip receive version 1 2” ,則該接口可以接收版本 1 和

2 的路由更新。

Automatic network summarization is not in effect

Maximum path: 4

Routing for Networks:

1.0.0.0

192.168.12.0

Routing Information Sources:

Gateway Distance Last Update

192.168.12.2 120 00:00:26

Distance: (default is 120)

4.3.2 實驗 5:RIPv2 手工彙總

1.實驗目的

通過本實驗可以掌握:

(1)RIPv2 路由的手工彙總

(2)RIPv2 不支持 CIDR 彙總

(3)RIPv2 可以傳遞 CIDR 彙總

2.拓撲結構

實驗拓撲如圖 4-5 所示。

圖 4-5 RIPv2 路由手工彙總

3.實驗步驟

路由器 R1、R2 和 R3 的配置和 4 4.3.1 實驗 4 相同,R4 的配置如下:

R4(config)# router rip

R4(config-router)# version 2

R4(config-router)# no auto-summary

R4(config-router)# network 192.168.34.0

R4(config-router)# network 4.0.0.0

R4(config)# interface s0/0/0

R4(config-if)# ip summary-address rip 4.4.0.0 255.255.252.0//RIP 手工路由彙總

4.實驗調試

(1)在沒有執行彙總之前路由器 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

4.0.0.0/24 is subnetted, 4 subnets

R 4.4.0.0 [120/3] via 192.168.12.2, 00:00:21, Serial0/0/0

R 4.4.1.0 [120/3] via 192.168.12.2, 00:00:21, Serial0/0/0

R 4.4.2.0 [120/3] via 192.168.12.2, 00:00:12, Serial0/0/0

R 4.4.3.0 [120/3] via 192.168.12.2, 00:00:05, Serial0/0/0

R 4.4.0.0 [120/3] via 192.168.12.2, 00:00:21, Serial0/0/0

R 4.4.1.0 [120/3] via 192.168.12.2, 00:00:21, Serial0/0/0

R 4.4.2.0 [120/3] via 192.168.12.2, 00:00:12, Serial0/0/0

R 4.4.3.0 [120/3] via 192.168.12.2, 00:00:05, Serial0/0/0

R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:21, Serial0/0/0

R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:22, Serial0/0/0

從上面的輸出看到路由器 R1 的路由表中有 R4 的 4 條環回接口的明細路由。

(2)在執行彙總以後路由器 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

4.0.0.0/22 is subnetted, 1 subnets

R 4.4.0.0 [120/3] via 192.168.12.2, 00:00:21, Serial0/0/0

R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:21, Serial0/0/0

R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:22, Serial0/0/0

上面的輸出表明在路由器 R1 的路由表中接收到彙總路由,當然 R2,R3 上也能收到彙總

路由。

【思考】

現在將路由器 R4 上四個環回接口 lo0-lo4 的地址分別修改爲 192.168.96.4/24,

192.168.97.4/24, 192.168.98.4/24, 192.168.99.4/24,在 s0/0/0 接口下還能夠實現路由

彙總嗎?R4 上做如下的配置:

R4(config-if)# router rip

R4(config-router)# network 192.168.96.0

R4(config-router)# network 192.168.97.0

R4(config-router)# network 192.168.98.0

R4(config-router)# network 192.168.99.0

R4(config-if)# ip summary-address rip 192.168.96.0 255.255.252.0

路由器會提示如下信息:

“ Summary mask must be greater or equal to major net”

顯示的提示信息表明彙總後的掩碼長度必須要大於或等於主類網絡的掩碼程度,因爲

“22<24”,所以不能彙總。

所以  RIPv2 不支持 CIDR 彙總,但是可以傳遞 CIDR 彙總。

解決方案如下:

(1)用靜態路由發佈被彙總的路由

R4(config)# ip route 192.168.96.0 255.255.252.0 null0

(2)將靜態路由重分佈到 RIP 網絡中

R4(config)# router rip

R4(config-router)# redistribute static //將靜態路由重分佈到 RIP 路由協議中

R4(config-router)# no network 192.168.96.0

R4(config-router)# no network 192.168.97.0

R4(config-router)# no network 192.168.98.0

R4(config-router)# no network 192.168.99.0

(3)在路由器 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, 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

R 192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:18, Serial0/0/0

R 192.168.34.0/24 [120/2] via 192.168.12.2, 00:00:18, Serial0/0/0

R 192.168.96.0/22 [120/3] via 192.168.12.2, 00:00:18, Serial0/0/0

通過輸出不難看出 RIPv2 是可以傳遞 CIDR 彙總信息的。

4.3.3 實驗 6:RIPv2 認證和觸發更新

1.實驗目的

通過本實驗可以掌握:

(1)RIPv2 明文認證的配置和匹配原則

(2)RIPv2 MD5 認證的配置和匹配原則

(3)RIPv2 觸發更新

2.拓撲結構

實驗拓撲如圖 4-1 所示。

3.實驗步驟

(1)步驟 1:配置路由器 R1

R1(config)# key chain test //配置鑰匙鏈

R1(config-keychain)# key 1 //配置 KEY ID

R1(config-keychain-key)# key-string cisco //配置 KEY ID 的密匙

R1(config)# interface s0/0/0

R1(config-if)# ip rip authentication mode text

//啓用認證,認證模式爲明文,默認認證模式就是明文,所以也可以不用指定

R1(config-if)# ip rip authentication key-chain test //在接口上調用鑰匙鏈

R1(config-if)# ip rip triggered //在接口上啓用觸發更新

(2)步驟 2:配置路由器 R2

R2(config)# key chain test

R2(config-keychain)# key 1

R2(config-keychain-key)# key-string cisco

R2(config)# interface s0/0/0

R2(config-if)# ip rip triggered

R2(config-if)# ip rip authentication key-chain test

R2(config-if)# interface s0/0/1

R2(config-if)# ip rip authentication key-chain test

R2(config-if)# ip rip triggered

(3)步驟 3:配置路由器 R3

R3(config)# key chain test

R3(config-keychain)# key 1

R3(config-keychain-key)# key-string cisco

R3(config)# interface s0/0/0

R3(config-if)# ip rip authentication key-chain test

R3(config-if)# ip rip triggered

R3(config-if)# interface s0/0/1

R3(config-if)# ip rip authentication key-chain test

R3(config-if)# ip rip triggered

(4)步驟 4:配置路由器 R4

R4(config)# key chain test

R4(config-keychain)# key 1

R4(config-keychain-key)# key-string cisco

R4(config)# interface s0/0/0

R4(config-if)# ip rip authentication key-chain test

R4(config-if)# ip rip triggered

4.實驗調試

(1) show ip protocols

R2# show ip protocols

Routing Protocol is "rip"

Outgoing update filter list for all interfaces is not set

Incoming update filter list for all interfaces is not set

Sending updates every 30 seconds, next due in 4 seconds

Invalid after 180 seconds,  hold down 0, flushed after 240

// 由於觸發更新,hold down 計時器自動爲 0

Redistributing: rip

Default version control: send version 2, receive version 2

Interface Send Recv Triggered RIP Key-chain

Serial0/0/0 2 2 Yes test

Serial0/0/1 2 2 Yes test

//以上兩行表明 s0/0/0 和 s0/0/1 接口啓用了認證和觸發更新

Automatic network summarization is not in effect

Maximum path: 4

Routing for Networks:

192.168.12.0

192.168.23.0

Routing Information Sources:

Gateway Distance Last Update

192.168.12.1 120 00:26:10

192.168.23.3 120 00:26:01

Distance: (default is 120)

(2) debug ip rip

R2# debug ip rip

RIP protocol debugging is on

R2# clear ip route *

*Feb 11 13:51:31.827: RIP: sending  triggered request on Serial0/0/0 to 224.0.0.9

*Feb 11 13:51:31.831: RIP: sending  triggered request on Serial0/0/1 to 224.0.0.9

*Feb 11 13:51:31.843: RIP: sending triggered request on Serial0/0/0 to 224.0.0.9

*Feb 11 13:51:31.847: RIP: sending triggered request on Serial0/0/1 to 224.0.0.9

*Feb 11 13:51:31.847: RIP: send v2  triggered flush update to 192.168.12.1 on Serial0/0/0 with

no route

*Feb 11 13:51:31.851: RIP: start retransmit timer of 192.168.12.1

*Feb 11 13:51:31.855: RIP: send v2 triggered flush update to 192.168.23.3 on Serial0/0/1 with

no route

*Feb 11 13:51:31.855: RIP: start retransmit timer of 192.168.23.3

*Feb 11 13:51:32.019: RIP: received packet with  text authentication cisco

*Feb 11 13:51:32.019: RIP: received v2 triggered update from 192.168.12.1 on Serial0/0/0

*Feb 11 13:51:32.023: RIP: sending v2 ack to 192.168.12.1 via Serial0/0/0 (192.168.12.2),

flush, seq# 1

*Feb 11 13:51:32.027: 1.1.1.0/24 via 0.0.0.0 in 1 hops

*Feb 11 13:51:32.031: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.035: RIP: received v2 triggered update from 192.168.23.3 on Serial0/0/1

*Feb 11 13:51:32.035: RIP: sending v2  ack to 192.168.23.3 via Serial0/0/1(192.168.23.2),

flush, seq# 2

*Feb 11 13:51:32.039: 192.168.34.0/24 via 0.0.0.0 in 1 hops

*Feb 11 13:51:32.043: 4.4.4.0/24 via 0.0.0.0 in 2 hops

*Feb 11 13:51:32.071: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.071: RIP: received v2 triggered update from 192.168.23.3 on Serial0/0/1

*Feb 11 13:51:32.071: RIP: sending v2 ack to 192.168.23.3 via Serial0/0/1(192.168.23.2),

flush, seq# 3

*Feb 11 13:51:32.075: 192.168.34.0/24 via 0.0.0.0 in 1 hops

*Feb 11 13:51:32.079: 4.4.4.0/24 via 0.0.0.0 in 2 hops

*Feb 11 13:51:32.083: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.083: RIP: received v2 triggered ack from 192.168.23.3 on Serial0/0/1

flush seq# 2

*Feb 11 13:51:32.087: RIP: send v2 triggered update to 192.168.23.3 on Serial0/0/1

*Feb 11 13:51:32.087: RIP: build update entries

*Feb 11 13:51:32.091: route 176: 192.168.12.0/24 metric 1, tag 0

*Feb 11 13:51:32.091: route 181: 1.1.1.0/24 metric 2, tag 0

*Feb 11 13:51:32.095: RIP: Update contains 2 routes, start 176, end 188

*Feb 11 13:51:32.095: RIP: start retransmit timer of 192.168.23.3

*Feb 11 13:51:32.099: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.099: RIP: received v2 triggered update from 192.168.12.1 on Serial0/0/0

*Feb 11 13:51:32.103: RIP: sending v2 ack to 192.168.12.1 via Serial0/0/0 (192.168.12.2),

flush, seq# 2

*Feb 11 13:51:32.107: 1.1.1.0/24 via 0.0.0.0 in 1 hops

*Feb 11 13:51:32.107: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.111: RIP: received v2 triggered ack from 192.168.12.1 on Serial0/0/0

flush seq# 3

*Feb 11 13:51:32.111: RIP: send v2 triggered update to 192.168.12.1 on Serial0/0/0

*Feb 11 13:51:32.115: RIP: build update entries

*Feb 11 13:51:32.115: route 178: 192.168.23.0/24 metric 1, tag 0

*Feb 11 13:51:32.119: route 184: 192.168.34.0/24 metric 2, tag 0

*Feb 11 13:51:32.123: route 187: 4.4.4.0/24 metric 3, tag 0

*Feb 11 13:51:32.123: RIP: Update contains 3 routes, start 178, end 188

*Feb 11 13:51:32.123: RIP: start retransmit timer of 192.168.12.1

*Feb 11 13:51:32.263: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.263: RIP: received v2 triggered ack from 192.168.23.3 on Serial0/0/1

seq# 3

*Feb 11 13:51:32.267: RIP: received packet with text authentication cisco

*Feb 11 13:51:32.271: RIP: received v2 triggered ack from 192.168.12.1 on Serial0/0/0

seq# 4

從上面的輸出可以看出,在路由器 R2 上,雖然我們打開了  debug ip rip,但是由於採

用觸發更新,所以並沒有看到每 30 秒更新一次的信息,而是清除了路由表這件事件觸發了

路由更新。而且所有的更新中都有“ triggered”的字樣,同時在接收的更新中帶有“ text

authentication

authentication”的字樣,證明接口 s0/0/0 和 s0/0/1 啓用了觸發更新和明文認證。

(3) show ip rip database

該命令可以查看 RIP 數據庫。

R2# show ip rip database

1.0.0.0/8 auto-summary

1.1.1.0/24

[1] via 192.168.12.1, 00:12:22 (permanent), Serial0/0/0

*  Triggered Routes:

- [1] via 192.168.12.1, Serial0/0/0

4.0.0.0/8 auto-summary

4.4.4.0/24

[2] via 192.168.23.3, 00:12:22 (permanent), Serial0/0/1

*  Triggered Routes:

- [2] via 192.168.23.3, Serial0/0/1

192.168.12.0/24 auto-summary

192.168.12.0/24 directly connected, Serial0/0/0

192.168.23.0/24 auto-summary

192.168.23.0/24 directly connected, Serial0/0/1

192.168.34.0/24 auto-summary

192.168.34.0/24

[1] via 192.168.23.3, 00:12:22 (permanent), Serial0/0/1

*  Triggered Routes:

- [1] via 192.168.23.3, Serial0/0/1

以上輸出進一步說明了在 s0/0/0 和 s0/0/1 啓用了觸發更新。

(4) show run

R2# show run | begin router rip

router rip

version 2

timers basic 30 180  0 240

//由於觸發更新,在配置中自動加入上面一行,且 hold down 計時器被設置爲 0 0

network 192.168.12.0

network 192.168.23.0

no auto-summary

關於 MD5 認證,只需要在接口下聲明認證模式爲 MD5 即可,例如在 R1 上的配置如下:

R1(config)# key chain test //定義鑰匙鏈

R1(config-keychain)# key 1

R1(config-keychain-key)# key-string cisco

R1(config)# interface s0/0/0

R1(config-if)# ip rip authentication mode md5 //認證模式爲 MD5

R1(config-if)# ip rip authentication key-chain test

其他的配置和明文認證相同,這裏不再贅述。當在 R2 上執行“ debug ip rip”時顯示

類似如下的信息:

*Feb 11 14:04:36.851: RIP: sending  triggered request on Serial0/0/0 to 224.0.0.9

*Feb 11 14:04:36.855: RIP: sending  triggered request on Serial0/0/1 to 224.0.0.9

*Feb 11 14:04:36.867: RIP: sending triggered request on Serial0/0/0 to 224.0.0.9

*Feb 11 14:04:36.871: RIP: sending triggered request on Serial0/0/1 to 224.0.0.9

*Feb 11 14:04:36.871: RIP: send v2  triggered flush update to 192.168.12.1 on Serial0/0/0 with

no route

*Feb 11 14:04:36.875: RIP: start retransmit timer of 192.168.12.1

*Feb 11 14:04:36.875: RIP: send v2 triggered flush update to 192.168.23.3 on Serial0/0/1 with

no route

*Feb 11 14:04:36.879: RIP: start retransmit timer of 192.168.23.3

*Feb 11 14:04:36.927: RIP: received packet with  MD5 authentication

*Feb 11 14:04:36.931: RIP: received v2 triggered update from 192.168.23.3 on Serial0/0/1

*Feb 11 14:04:36.931: RIP: sending v2  ack to 192.168.23.3 via Serial0/0/1 (192.168.23.2),

flush, seq# 4

*Feb 11 14:04:36.935: 192.168.34.0/24 via 0.0.0.0 in 1 hops

*Feb 11 14:04:36.943: 4.4.4.0/24 via 0.0.0.0 in 2 hops

*Feb 11 14:04:36.947: RIP: received packet with MD5 authentication

*Feb 11 14:04:36.947: RIP: received v2 triggered update from 192.168.12.1 on Serial0/0/0

*Feb 11 14:04:36.951: RIP: sending v2 ack to 192.168.12.1 via Serial0/0/0 (192.168.12.2),

flush, seq# 3

*Feb 11 14:04:36.955: 1.1.1.0/24 via 0.0.0.0 in 1 hops

*Feb 11 14:04:36.959: RIP: received packet with MD5 authentication

*Feb 11 14:04:36.959: RIP: received v2 triggered update from 192.168.12.1 on Serial0/0/0

*Feb 11 14:04:36.963: RIP: sending v2 ack to 192.168.12.1 via Serial0/0/0 (192.168.12.2),

flush, seq# 4

*Feb 11 14:04:36.967: 1.1.1.0/24 via 0.0.0.0 in 1 hops

*Feb 11 14:04:36.967: RIP: received packet with MD5 authentication

*Feb 11 14:04:36.971: RIP: received v2 triggered ack from 192.168.12.1 on Serial0/0/0

flush seq# 5

*Feb 11 14:04:36.971: RIP: send v2 triggered update to 192.168.12.1 on Serial0/0/0

*Feb 11 14:04:36.975: RIP: build update entries

*Feb 11 14:04:36.975: route 191: 192.168.23.0/24 metric 1, tag 0

*Feb 11 14:04:36.979: route 194: 192.168.34.0/24 metric 2, tag 0

*Feb 11 14:04:36.979: route 197: 4.4.4.0/24 metric 3, tag 0

*Feb 11 14:04:36.983: RIP: Update contains 3 routes, start 191, end 201

*Feb 11 14:04:36.983: RIP: start retransmit timer of 192.168.12.1

*Feb 11 14:04:36.991: RIP: received packet with MD5 authentication

*Feb 11 14:04:36.991: RIP: received v2 triggered update from 192.168.23.3 on Serial0/0/1

*Feb 11 14:04:36.991: RIP: sending v2 ack to 192.168.23.3 via Serial0/0/1 (192.168.23.2),

flush, seq# 5

*Feb 11 14:04:36.999: 192.168.34.0/24 via 0.0.0.0 in 1 hops

*Feb 11 14:04:36.999: 4.4.4.0/24 via 0.0.0.0 in 2 hops

*Feb 11 14:04:37.003: RIP: received packet with MD5 authentication

*Feb 11 14:04:37.003: RIP: received v2 triggered ack from 192.168.23.3 on Serial0/0/1

flush seq# 4

*Feb 11 14:04:37.007: RIP: send v2 triggered update to 192.168.23.3 on Serial0/0/1

*Feb 11 14:04:37.007: RIP: build update entries

*Feb 11 14:04:37.011: route 189: 192.168.12.0/24 metric 1, tag 0

*Feb 11 14:04:37.015: route 200: 1.1.1.0/24 metric 2, tag 0

*Feb 11 14:04:37.015: RIP: Update contains 2 routes, start 189, end 201

*Feb 11 14:04:37.019: RIP: start retransmit timer of 192.168.23.3

*Feb 11 14:04:37.059: RIP: received packet with MD5 authentication

*Feb 11 14:04:37.059: RIP: received v2 triggered ack from 192.168.12.1 on Serial0/0/0

seq# 6

*Feb 11 14:04:37.067: RIP: received packet with MD5 authentication

*Feb 11 14:04:37.071: RIP: received v2 triggered ack from 192.168.23.3 on Serial0/0/1

seq# 5

以上輸出信息表明採用了 MD5 認證和觸發更新。

【技術要點 】

(1)在以太網接口下,不支持觸發更新;

(2)觸發更新需要協商,鏈路的兩端都需要配置;

(3)在認證的過程中,如果定義多個 key ID,明文認證和 MD5 認證的匹配原則是不一

樣的:

① 明文認證的匹配原則是:

A. 發送方發送最小Key ID的密鑰

B. 不攜帶Key ID號碼

C. 接收方會和所有 Key Chain 中的密鑰匹配,如果匹配成功,則通過認證。

【實例 1 】

路由器 R1 有一個 Key ID,key1=cisco;

路由器 R2 有兩個 Key ID,key1=ccie,key2=cisco

根據上面的原則,R1 認證失敗,R2 認證成功,所以在 RIP 中,出現單邊路由並不

稀奇。

② MD5 認證的匹配原則是:

A. 發送方發送最小Key ID的密鑰

B. 攜帶Key ID號碼

C. 接收方首先會查找是否有相同的Key ID,如果有,只匹配一次,決定認證是否

成功。如果沒有該Key ID,只向下查找下一跳,匹配,認證成功;不匹配,認證失敗。

【實例 2 】

路由器 R1 有三個 Key ID,key1=cisco,key3=ccie,key5=cisco ;

路由器 R2 有一個 Key ID,key2=cisco

根據上面的原則,R1 認證失敗,R2 認證成功。

4.3.4 實驗 7:浮動靜態路由

1.實驗目的

通過本實驗可以掌握浮動靜態路由原理、配置以及備份應用。

2.拓撲結構

實驗拓撲如圖 4-6 所示。

圖 4-6 浮動靜態路由

3.實驗步驟

本實驗通過修改靜態路由的管理距離爲 130,使得路由器選路的時候優先選擇 RIP,而

靜態路由作爲備份。

(1)步驟 1:配置路由器 R1

R1(config)# ip route 2.2.2.0 255.255.255.0 192.168.12.2 130

//將靜態路由的管理距離設置爲 130

R1(config)# router rip

R1(config-router)# version 2

R1(config-router)# no auto-summary

R1(config-router)# network 1.0.0.0

R1(config-router)# network 192.168.21.0

(2)步驟 2:配置路由器 R2

R2(config)# ip route 1.1.1.0 255.255.255.0 192.168.12.1 130

R2(config)# router rip

R2(config-router)# version 2

R2(config-router)# no auto-summary

R2(config-router)# network 192.168.21.0

R2(config-router)# network 2.0.0.0

4.實驗調試

(1)在 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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

R 2.2.2.0 [120/1] via 192.168.21.2, 00:00:25, GigabitEthernet0/0

C 192.168.21.0/24 is directly connected, GigabitEthernet0/0

從以上輸出可以看出,路由器將 RIP 的路由放入路由表中,因爲 RIP 的管理距離爲 120,

小於在靜態路由中設定的 130,而靜態路由處於備份的地位。

(2)在 R1 上將 g0/0 接口 shutdown,然後查看路由表:

R1(config)# interface gigabitEthernet 0/0

R1(config-if)# shutdown

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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

S 2.2.2.0 [130/0] via 192.168.12.2

以上輸出說明,當主路由中斷後,備份的靜態路由被放入到路由表中,也很好地解釋了

浮動靜態路由作爲備份的工作原理。

(3)在 R1 上將 g0/0 接口啓動,然後查看路由表:

R1(config)# interface gigabitEthernet 0/0

R1(config-if)# no shutdown

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

C 192.168.12.0/24 is directly connected, Serial0/0/0

1.0.0.0/24 is subnetted, 1 subnets

C 1.1.1.0 is directly connected, Loopback0

2.0.0.0/24 is subnetted, 1 subnets

R 2.2.2.0 [120/1] via 192.168.21.2, 00:00:09, GigabitEthernet0/0

C 192.168.21.0/24 is directly connected, GigabitEthernet0/0

以上輸出表明當主路由恢復後,浮動靜態路由又恢復到備份的地位。

4.3.4 實驗 8:ip default-network

1.實驗目的

通過本實驗可以掌握如何通過 ip default-network 向網絡中注入一條默認路由。

2.拓撲結構

實驗拓撲如圖 4-7 所示。

圖 4-7 ip default-network 向 RIP 網絡中注入默認路由

3.實驗步驟

(1)步驟 1:配置路由器 R1

R1(config)# router rip

R1(config-router)# version 2

R1(config-router)# no auto-summary

R1(config-router)# network 192.168.12.0

R1(config)# ip default-network 1.0.0.0

(2)步驟 2:配置路由器 R2

R2(config)# router rip

R2(config-router)# version 2

R2(config-router)# no auto-summary

R2(config-router)# network 192.168.12.0

R2(config-router)# network 2.0.0.0

4.實驗調試

(1)在 R2 上查看路由表:

R2# 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 192.168.12.1 to network 0.0.0.0

//表明默認路由的網關爲 192.168.12.1

C 192.168.12.0/24 is directly connected, Serial0/0/0

2.0.0.0/24 is subnetted, 1 subnets

C 2.2.2.0 is directly connected, Loopback0

R* 0.0.0.0/0 [120/1] via 192.168.12.1, 00:00:22, Serial0/0/0

從以上輸出可以看出 R1 上的“ ip default-network”命令確實向 RIP 網絡中注入一條

“ R* ”的默認路由。

(2)在 R2 上 ping 1.1.1.1;

R2# ping 1.1.1.1

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 1.1.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/14/16 ms

以上輸出表明在路由器 R2 上可以 ping 通地址 1.1.1.1,雖然在 R1 的 RIP 進程中沒有

通告該網絡,也恰恰說明是默認路由起了作用。否則,因爲在 R2 的路由表中沒有 1.1.1.0

的路由條目,是不可能 ping 通的。

【技術要點 】

(1)ip default-network 後面的網絡一定要是主類網絡;

(2)ip default-network 後面的網絡可以是直連的或者通過其它協議學到的網絡。

4.4 RIP 命令彙總

表 4-2 列出了本章涉及到的主要的命令。

表 4-2 本章命令彙總

命令  作用

show ip route  查看路由表

show ip protocols  查看 IP 路由協議配置和統計信息

show ip rip database  查看 RIP 數據庫

debug ip rip  動態查看 RIP 的更新過程

clear ip route *  清除路由表

router rip  啓動 RIP 進程

network 通告網絡

version  定義 RIP 的版本

no auto-summary  關閉自動彙總

ip rip send version  配置 RIP 發送的版本

ip rip receive version  配置 RIP 接收的版本

passive-interface  配置被動接口

neighbor  配置單播更新的目標

ip summary-address rip  配置 RIP 手工彙總

key chain 定義鑰匙鏈

key  key-id 配置 Key ID

key-string 配置 Key ID 的密匙

ip rip triggered  配置觸發更新

ip rip authentication mode  配置認證模式

ip rip authentication key-chain  配置認證使用的鑰匙鏈

timers basic  配置更新的計時器

maximum-paths  配置等價路徑的最大值

ip default-network  向網絡中注入默認路由

wKioL1ghRFuR6vzfAAAqcMBn8qo751.png-wh_50

wKiom1ghRFyQTpZYAAAREoqQ31s097.png-wh_50

wKioL1ghRFyBOWnlAAANL8xO5Qs073.png-wh_50

wKiom1ghRFyzr6w1AAAauVskxWI345.png-wh_50


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