RIP:Routing Information Protocol,RFC1058.
-
距離矢量協議:有間隔的多少和方向,傳遞的是路由條目,每個路由器不知道網路的完整拓撲結構,OSPF知道,
-
度量值:每種協議都有會計算出發點到目的地之間的度量也就是單位,rip的度量值(單位)是跳數,跳數超過15就不往后傳播了,也就是無法到達目的地,
-
每30秒收斂一次,
收斂:前面的路由會定期把自己的整個路由表發送給后面的路由器,rip是每30秒發送一次,
-
rip有2個版本:
- V1(版本1:有類路由)使用廣播把路由表發送給下一個路由器,只傳遞ip地址,不傳遞子網掩碼,
- V2(版本2:無類路由)使用組播,組播地址:224.0.0.9,既傳遞ip地址,又傳遞子網掩碼,
-
管理距離(AD):120,
路由表里中括號里的值就是管理距離,當用不同的協議,獲得了相同的路由時,看哪個協議獲得的路由的管理距離小,路由表里只能留下一個路由,留管理距離小的路由,
例如:如果有下面2條路由,則只能留下[1/0]的路由,因為管理距離小,
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協議傳輸
-
源和目的埠號都是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轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/47395.html
標籤:其他
上一篇:SQL注入總結
下一篇:FPGA與PC機的通信問題
