RIP:Routing Information Protocol。RFC1058.
距离矢量协议:有间隔的多少和方向。传递的是路由条目。每个路由器不知道网络的完整拓扑结构,OSPF知道。
度量值:每种协议都有会计算出发点到目的地之间的度量也就是单位。rip的度量值(单位)是跳数。跳数超过15就不往后传播了,也就是无法到达目的地。
每30秒收敛一次。
收敛:前面的路由会定期把自己的整个路由表发送给后面的路由器。rip是每30秒发送一次。
rip有2个版本:
管理距离(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.
添加后,接口立即生效,不需要开启(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
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的路由条目:
注意: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协议
原文:https://www.cnblogs.com/xiaoshiwang/p/12195415.html