動態路由協議 RIP

RIP:Routing Information Protocol。RFC1058.c++

  • 距離矢量協議:有間隔的多少和方向。傳遞的是路由條目。每一個路由器不知道網絡的完整拓撲結構,OSPF知道。shell

  • 度量值:每種協議都有會計算出發點到目的地之間的度量也就是單位。rip的度量值(單位)是跳數。跳數超過15就不日後傳播了,也就是沒法到達目的地。微信

  • 每30秒收斂一次。網絡

    收斂:前面的路由會按期把本身的整個路由表發送給後面的路由器。rip是每30秒發送一次。負載均衡

  • rip有2個版本:oop

    • V1(版本1:有類路由)使用廣播把路由表發送給下一個路由器。只傳遞ip地址,不傳遞子網掩碼。
    • V2(版本2:無類路由)使用組播,組播地址:224.0.0.9。既傳遞ip地址,又傳遞子網掩碼。
  • 管理距離(AD):120。學習

    路由表裏中括號裏的值就是管理距離。當用不一樣的協議,得到了相同的路由時,看哪一個協議得到的路由的管理距離小,路由表裏只能留下一個路由,留管理距離小的路由。code

    例如:若是有下面2條路由,則只能留下[1/0]的路由,由於管理距離小。orm

    S    192.168.1.0/24 [1/0] via 192.168.0.2    192.168.1.0/24 [1/0] via 192.168.0.2
    R    192.168.1.0/24 [100/0] via 192.168.0.2  192.168.1.0/24 [1/0] via 192.168.0.2
  • 使用UDP協議傳輸router

  • 源和目的端口號都是520

  • 報文形式:請求和響應報文,使用的格式相同。

  • 默認支持等價負載均衡:4,最大可調到6.

RIP計時器

  • 更新計時器(update):每30秒接收一次相鄰路由器的更新請求(收斂)
  • 無效計時器(invalid):180秒後相鄰的路由器不給我路由表,把到這些路由的度量值更新爲16,也就是不可達。
  • 刷新計時器(flush):默認240秒後,相鄰的路由器不給我路由表,則把這些路由所有刪除。
  • 抑制計時器(hold-down):180秒。

RIPv1:

  • 有類路由協議
  • 不支持變長子網掩碼(VLSM)
  • 廣播方式發包
  • 不支持認證
  • 每一個更新包最大支持25條路由條目
  • 路由表查詢方式爲主類網段
  • 不支持不連續子網

RIPv2:

  • 無類路由協議
  • 支持變長子網掩碼
  • 組播方式發包,目的地址:224.0.0.9
  • 支持明文及密文認證(cisco才支持)
  • 路由表查詢機制是由小類->大類(按位查詢,最長匹配,精準匹配,先檢查32位掩碼的)
  • 支持不連續子網

添加路由器的loopback(換回接口,相似pc裏的127.0.0.1)

添加後,接口當即生效,不須要開啓(no sh)。

#interface loopback ?
  <0-2147483647>  Loopback interface number
R1(config)#interface loopback 0
R1(config-if)#
*Mar  1 00:08:43.587: %LINEPROTO-5-UPDOWN: Line protocol on Interface Loopback0, changed state to up

添加後,在路由器上就多了一個虛擬接口

R1#show ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            12.1.1.1        YES manual up                    up  
Loopback0                  1.1.1.1         YES manual up                    up

給換回接口添加ip,注意子網掩碼必須是255.255.255.255.表明主機的意思。

R1(config-if)#ip addr 1.1.1.1 255.255.255.255

啓動路由器的RIP協議:

1,進入全局模式,啓動rip

R1(config)#router rip
R1(config-router)#

2,指定使用哪一個版本的rip。若是不指定版本的話,使用的既不是版本1,也不是版本2,而是1和2中間的版本,具體來講是:以廣播方式發送,既能接收廣播的也能接收組播的。

R1(config-router)#version 2
R1(config-router)#

3,關閉自動彙總:no auto-summary

R1(config-router)#no auto-summary
R1(config-router)#

什麼是自動彙總?接口上的ip假如是12.1.1.1/24 ,自動彙總後,就變成了12.0.0.0/8,就至關於變成了版本1的有類路由協議了,不能精確到子網,因此,纔要關閉自動彙總。

4,告訴路由器,我要把本地的哪一個直連(C)的接口上的網段,用於rip協議,發送和接收rip包

R1:

R1(config-router)#do show ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            12.1.1.1        YES manual up                    up  
FastEthernet1/0            unassigned      YES unset  administratively down down
Loopback0                  1.1.1.1         YES manual up                    up
R1(config-router)#do show ip route
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0
R1(config-router)#network 1.1.1.1
R1(config-router)#net 12.1.1.0
R1(config-router)#

R2:

R2#show ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            12.1.1.2        YES manual up                    up  
FastEthernet1/0            23.1.1.2        YES manual up                    up  
Loopback0                  2.2.2.2         YES manual up                    up  
R2#show ip route
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, FastEthernet1/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0
R2#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R2(config)#router rip
R2(config-router)#net 2.2.2.2
R2(config-router)#net 23.1.1.0
R2(config-router)#net 12.1.1.0

R3:

R3#show ip int b
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            23.1.1.3        YES manual up                    up  
FastEthernet1/0            unassigned      YES unset  administratively down down
Loopback0                  3.3.3.3         YES manual up                    up  
R3#show ip route
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, FastEthernet0/0
R3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R3(config)#router rip
R3(config-router)#ver 2
R3(config-router)#no au
R3(config-router)#net 3.3.3.3
R3(config-router)#net 23.1.1.0

R1,2,3配置完RIP的路由條目結果:

R1的路由條目:

注意:R 3.3.3.3 [120/2]裏面的【2】,含義:到目標網絡須要2跳

R1#show ip route
     1.0.0.0/32 is subnetted, 1 subnets
C       1.1.1.1 is directly connected, Loopback0
     2.0.0.0/32 is subnetted, 1 subnets
R       2.2.2.2 [120/1] via 12.1.1.2, 00:00:22, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
R       3.3.3.3 [120/2] via 12.1.1.2, 00:00:22, FastEthernet0/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:22, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0

R2的路由條目:

R2#show ip route
     1.0.0.0/32 is subnetted, 1 subnets
R       1.1.1.1 [120/1] via 12.1.1.1, 00:00:21, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
C       2.2.2.2 is directly connected, Loopback0
     3.0.0.0/32 is subnetted, 1 subnets
R       3.3.3.3 [120/1] via 23.1.1.3, 00:00:07, FastEthernet1/0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, FastEthernet1/0
     12.0.0.0/24 is subnetted, 1 subnets
C       12.1.1.0 is directly connected, FastEthernet0/0

R3的路由條目:

R3#show ip route
     1.0.0.0/32 is subnetted, 1 subnets
R       1.1.1.1 [120/2] via 23.1.1.2, 00:00:15, FastEthernet0/0
     2.0.0.0/32 is subnetted, 1 subnets
R       2.2.2.2 [120/1] via 23.1.1.2, 00:00:15, FastEthernet0/0
     3.0.0.0/32 is subnetted, 1 subnets
C       3.3.3.3 is directly connected, Loopback0
     23.0.0.0/24 is subnetted, 1 subnets
C       23.1.1.0 is directly connected, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
R       12.1.1.0 [120/1] via 23.1.1.2, 00:00:15, FastEthernet0/0

33-35集講RIP協議

c/c++ 學習互助QQ羣:877684253

本人微信:xiaoshitou5854

相關文章
相關標籤/搜索