温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

动态路由之RIP协议

发布时间:2020-04-10 22:31:37 来源:网络 阅读:643 作者:23trl 栏目:云计算

动态路由之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协议敬请期待
向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI