動態路由器如何配置(動態路由協議RIP配置,帶你一分鐘學會)
一、動態路由RIP產生背景
1、動態路由協議包括距離向量路由協議和鏈路狀態路由協議。RIP(Routing Information
Protocols,路由信息協議)是使用最廣泛的距離向量路由協議。RIP 是為小型網絡環境設
計的,因為這類協議的路由學習及路由更新將產生較大的流量,占用過多的帶寬。
2、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 的區別
RIPv1 RIPv2
在路由更新的過程中不攜帶子網信息 在路由更新的過程中攜帶子網信息
不提供認證 提供明文和 MD5 認證
不支持 VLSM 和 CIDR 支持 VLSM 和 CIDR
采用廣播更新 采用組播(224.0.0.9)更新
有類別(Classful)路由協議 無類別(Classless)路由協議
三、RIPv1 基本配置
實驗步驟:
(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"http://路由器上運行的路由協議是 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 跳。