動態路由之RIP協議

動態路由之RIP協議

一.動態路由之RIP協議概述

RIP協議最初是爲Xerox網絡系統的Xerox parc通用協議而設計的,是Internet中常用的路由協議。RIP採用距離向量算法,即路由器根據距離選擇路由,所以也稱爲距離向量協議。路由器收集所有可到達目的地的不同路徑,並且保存有關到達每個目的地的最少站點數的路徑信息,除到達目的地的最佳路徑外,任何其它信息均予以丟棄。同時路由器也把所收集的路由信息用RIP協議通知相鄰的其它路由器。這樣,正確的路由信息逐漸擴散到了全網。```

RIP使用非常廣泛,它簡單、可靠,便於配置。但是RIP只適用於小型的同構網絡,因爲它允許的最大站點數爲15,任何超過15個站點的目的地均被標記爲不可達。而且RIP每隔30s一次的路由信息廣播也是造成網絡的廣播風暴的重要原因之一。

        二.什麼叫距離矢量路由協議
基於距離矢量算法:又稱爲Bellman-ford或 Ford-Fulkerson算法。 
距離矢量名稱的由來是因爲路由是以矢量(距離,方向)的方式被通告出去的,這裏的距離是根據度量來決定的。通俗點就是:往某個方向上的距離。 
週期性更新:每個路由器週期性地向直接相連的其他路由器發送自己   的路由表。 
原理:距離矢量協議直接傳送各自的路由表信息。網絡中的路由器從自己的鄰居路由器得到路由信息,並將這些路由信息連同自己的本地路由信息發送給其他鄰居,這樣一級級的傳遞下去以達到全網同步。每個路由器都不瞭解整個網絡拓撲,它們只知道與自己直接相連的網絡情況,並根據從鄰居得到的路由信息更新自己的路由。
    三.RIP路由協議特點

RIP:Routing Information Protocol (路由信息協議)
一種距離矢量路由協議,屬於IGP協議。
RIP協議適用於中小型網絡,有RIPv1和RIPv2兩個版本。

其中:
RIPv1爲有類別路由協議,不支持VLSM和CIDR
以廣播的形式發送報文
不支持驗證

RIPv2爲無類別路由協議,支持VLSM,支持路由聚合與CIDR
支持以廣播或者組播(224.0.0.9)的形式發送報文
支持明文驗證和 MD5 密文驗證

使用UDP進行路由信息的交互,目標端口號520。
RIP支持:水平分割(避免路由環路的出現和加快路由匯聚的技術)、毒性逆轉(一種改進的水平分割)

## 四.路由環路
路由環路:更新週期30s 
r1 r2 r3
r3有一條鏈路壞了,它的條目
跳數就是16不可達
30s後r2就會去學習R3的條目
週期30s,r3的條目跳數就變成2
數據包在這兩個路由器就會迴環

五.根據實驗來配置RIP協議
動態路由之RIP協議

實驗環境:R1,R2, R3,三個路由器,PC1,PC2,兩臺主機,GNS3中模擬。
實驗目的:主機互聯互通,三個路由器互相學習路由表,路由環路。

### 1.在GNS3當中配好路由器的接口的地址和主機的IP地址
PC1: 192.168.10.2/24
R1F0/0: 192.168.10.1/24
R1F0/1: 192.168.20.1/30   子網掩碼:255.255.255.252
R2F0/0: 192.168.20.2/30    子網掩碼:255.255.255.252
R2F0/1: 192.168.30.1/30   子網掩碼:255.255.255.252
R3F0/0: 192.168.30.2/30  子網掩碼:255.255.255.252
R3F0/1: 192.168.40.1/24
PC2: 192.168.40.2/24

### 2.配置R1兩個接口的地址,並查看地址有沒有生效
R1(config)#int f0/0   
R1(config-if)#ip add 192.168.10.1 255.255.255.0  //配置地址
R1(config-if)#no shut   //開啓
R1(config-if)#ex
R1(config)#int 
*Mar  1 00:01:36.027: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:01:37.027: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R1(config)#int f0/1
R1(config-if)#ip add 192.168.20.1 255.255.255.252
R1(config-if)#no shut
R1(config-if)#ex 
R1(config)#
*Mar  1 00:01:58.459: %LINK-3-UPDOWN: Interface FastEthern
*Mar  1 00:01:59.459: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R1(config)#do 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.10.0/24 is directly connected, FastEthernet0/0
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/1
配置R2兩個接口的地址,並查看地址有沒有生效
R2(config)#int f0/0
R2(config-if)#ip add 192.168.20.2 255.255.255.252
R2(config-if)#no shut
R2(config-if)#ex
R2(config)#int f
Mar  1 00:02:55.115: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
Mar  1 00:02:56.115: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R2(config)#int f0/1
R2(config-if)#ip add 192.168.30.1 255.255.255.252
R2(config-if)#no shut
R2(config-if)#ex
R2(config)#
Mar  1 00:03:18.619: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
Mar  1 00:03:19.619: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R2(config)#do 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

0/30 is subnetted, 1 subnets
C       192.168.30.0 is directly connected, FastEthernet0/1
0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/0**
3.配置R3的兩個接口地址和查看路由表地址有沒有生效
R3(config)#int f0/0
R3(config-if)#ip add 192.168.30.2 255.255.255.252
R3(config-if)#no shut
R3(config-if)#ex
R3(config)#int f
*Mar  1 00:03:56.759: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
*Mar  1 00:03:57.759: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
R3(config)#int f0/1
R3(config-if)#ip add 192.168.40.1 255.255.255.0
R3(config-if)#no shut
R3(config-if)#ex
R3(config)#
*Mar  1 00:04:15.899: %LINK-3-UPDOWN: Interface FastEthernet0/1, changed state to up
*Mar  1 00:04:16.899: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/1, changed state to up
R3(config)#do 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
 192.168.30.0/30 is subnetted, 1 subnets

C 192.168.30.0 is directly connected, FastEthernet0/0
C 192.168.40.0/24 is directly connected, FastEthernet0/1

4.給R1配RIP2協議,並且查看路由表
R1(config)#router rip   //進入RIP協議進程

R1(config-router)#network 192.168.10.0  //宣告網段
R1(config-router)#network 192.168.20.0   //宣告網段
R1(config-router)#version 2   //選擇2協議
R1(config-router)#no auto-summary  //關閉路由彙總
R1(config-router)#ex
R1(config)#do 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

     192.168.30.0/30 is subnetted, 1 subnets
R       192.168.30.0 [120/1] via 192.168.20.2, 00:00:18, FastEthernet0/1
C    192.168.10.0/24 is directly connected, FastEthernet0/0
R    192.168.40.0/24 [120/2] via 192.168.20.2, 00:00:00, FastEthernet0/1
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/1
5.給R2配RIP2協議,並且查看路由表
R2(config)#router rip
R2(config-router)#network 192.168.20.0
R2(config-router)#network 192.168.30.0
R2(config-router)#version 2
R2(config-router)#no auto-summary
R2(config-router)#ex
R2(config)#do 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

     192.168.30.0/30 is subnetted, 1 subnets
C       192.168.30.0 is directly connected, FastEthernet0/1
R    192.168.10.0/24 [120/1] via 192.168.20.1, 00:00:13, FastEthernet0/0
R    192.168.40.0/24 [120/1] via 192.168.30.2, 00:00:12, FastEthernet0/1
     192.168.20.0/30 is subnetted, 1 subnets
C       192.168.20.0 is directly connected, FastEthernet0/0

6..給R3配RIP2協議,並且查看路由表```


R3(config)#router rip
R3(config-router)#network 192.168.30.0
R3(config-router)#network 192.168.40.0
R3(config-router)#version 2
R3(config-router)#no auto-summary
R3(config-router)#ex
R3(config)#do 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

192.168.30.0/30 is subnetted, 1 subnets
C       192.168.30.0 is directly connected, FastEthernet0/0
R    192.168.10.0/24 [120/2] via 192.168.30.1, 00:00:14, FastEthernet0/0
C    192.168.40.0/24 is directly connected, FastEthernet0/1
192.168.20.0/30 is subnetted, 1 subnets
R       192.168.20.0 [120/1] via 192.168.30.1, 00:00:14, FastEthernet0/0


###  7.給兩臺PC機配IP地址並測試能不能互聯互通
> PC1> ip 192.168.10.2 192.168.10.1
> Checking for duplicate address...
> PC1 : 192.168.10.2 255.255.255.0 gateway 192.168.10.1
> 
> 
> PC1> ping 192.168.40.2
> 84 bytes from 192.168.40.2 icmp_seq=1 ttl=61 time=93.730 ms
> 84 bytes from 192.168.40.2 icmp_seq=2 ttl=61 time=93.728 ms
> 84 bytes from 192.168.40.2 icmp_seq=3 ttl=61 time=93.729 ms
> 84 bytes from 192.168.40.2 icmp_seq=4 ttl=61 time=93.697 ms

> PC2> ip 192.168.40.2 192.168.40.1
> Checking for duplicate address...
> PC1 : 192.168.40.2 255.255.255.0 gateway 192.168.40.1
> 
> PC2> ping 192.168.10.2
> 84 bytes from 192.168.10.2 icmp_seq=1 ttl=61 time=93.762 ms
> 84 bytes from 192.168.10.2 icmp_seq=2 ttl=61 time=93.729 ms
> 84 bytes from 192.168.10.2 icmp_seq=3 ttl=61 time=93.729 ms
> 84 bytes from 192.168.10.2 icmp_seq=4 ttl=61 time=93.695 ms
> 84 bytes from 192.168.10.2 icmp_seq=5 ttl=61 time=93.696 ms

## 以上就是我們的動態路由的RIP協議
## 後面博客OSPF協議敬請期待
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章