【网络】RIP路由协议

1.RIP路由协议 

RIP:route information Protocol 路由信息协议。
1). AS 号: IGP :Intra Gateway Protocol ,一个范围内使用的。
2).距离矢量路由协议。 
距离:度量值:metric 
矢量:就是下一跳。
3).有类路由协议和无类路由协议。
RIP v1(有类路由协议),RIP v2(无类路由协议); 

4).RIP是动态路由协议。

动态路由协议:在两台直连的路由器之间,建立一种类似于"邻居"的关系。
目的就是用来让邻居传送它所知道的路由条目。

静态路由永远指向非直连的路由。
动态路由运行在直连路由器之间,传递非直连路由。

2.RIP配置network的作用

使用交叉线连接:
R1------>R2--------R3 

R1:f0/0:10.1.1.1/30
R2:f0/0:10.1.1.2/30
R2:f0/1:10.1.2.1/30
R3:f0/1:10.1.2.2/30

--R1# 
Router>en 
Router#confi t 
Router(config)#hostname R1 
R1(config)#

--R2# 
Router>en 
Router#confi t 
Router(config)#hostname R2 
R2(config)#

--R3# 
Router>en 
Router#confi t 
Router(config)#hostname R3 
R3(config)#int f0/1
R3(config-if)#ip address 10.1.2.2 255.255.255.252 
R3(config-if)#no shutdown 

R2(config)#int f0/1 
R2(config-if)#ip address 10.1.2.1 255.255.255.252 
R2(config-if)#no shutdown 

R2(config-if)#exit 
R2(config)#int f0/0 
R2(config-if)#ip address 10.1.1.2 255.255.255.252 
R2(config-if)#no shutdown 



R1(config)#int f0/0 
R1(config-if)#ip address 10.1.1.1 255.255.255.252 
R1(config-if)#no shutdown 

R1# ping 10.1.2.1 不同。 
R1#confi t 
R1(config)#ip route 10.1.2.0 255.255.255.252 10.1.1.2 
R1(config)#end 
R1#sh ip route 
S 10.1.2.0 [1/0] via 10.1.1.2 
R1#ping 10.1.2.1 --可以通了。

--删除路由。
R1(config)#no ip route 10.1.2.0 255.255.255.252 10.1.1.2 
--启用RIP 路由协议。
R1(config)#router rip 
R1(config-router)#network 10.1.1.1 或者:network 10.1.1.0 或者: network 10.0.0.0


R2(config)#router rip 
R2(config-router)#network 10.1.1.2 
R2(config-router)#exit
R2(config)#


R1(config)#router rip 
R1(config-router)#network 10.1.1.1
R1#sh ip route 
C 10.1.1.0 is directly connnected,FastEthernet0/0
R 10.1.2.0 [120/1] via 10.1.1.2,00:00:05,FastEthernet0/0


router rip :进入rip 路由协议的配置模式。
network: 
	1:激活接口。 
	2:宣告网段。 
	
路由类型:
S :static 
I :IGRP 
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 
E :EGP 
i :IS-IS 
L1:IS-IS level-1 
L2:IS-IS level-2 
ia: IS-IS inter area 
* :默认的。
U :每个用户静态路由。 
o :ODR
P: 阶段性下载静态路由。

敲的是:network 10.1.1.1 之后转换成:network 10.0.0.0 
RIP Network 宣告网段时,是以主类的网络号宣告的。

主类指的是:
A B  C   D E 
8 16 24    --掩码位数。

指定:10.1.1.0/30 时将宣告:10.0.0.0/8 

3.路由表解析与更新时间 
R1#sh ip route 
C 10.1.1.0 is directly connnected,FastEthernet0/0
R 10.1.2.0 [120/1] via 10.1.1.2,00:00:05,FastEthernet0/0


R1:f0/0:10.1.1.1/30
R2:f0/0:10.1.1.2/30
R2:f0/1:10.1.2.1/30
R3:f0/1:10.1.2.2/30

R:代表RIP路由协议。
10.1.2.0:非直连网段 
[120/1]:默认RIP的管理距离=120,直连的管理距离=0,静态路由管理距离=1;
RIP metric 以跳数作为度量。
跳数就是路由器的个数。

当一个路由条目从一台路由器或者三层设备的出接口发送出去的时候跳数就会加1;
跳数最大为16,16跳就不可达。
最大只能传递15台路由器。

RIP在传递路由条目的时候会携带下一跳属性。

谁把路由条目传给我,我的下一跳就是谁。
FastEthernet0/0:有出接口,不需要递归查询了。
00:00:05 :RIP使用定时器,正常情况下 update时间=30s;
RIP的默认时间是30s;
每隔30s就发送一次路由表。不会超过30s;

hold down 时间=180s; 3分钟还没有返回,说明有问题了。

--通过这个命令查看 hold down时间。
R1# sh ip protocols  

3.自动汇总 


R1--->R2--->R3 
R1:f0/0:10.1.1.1/30 
R2:f0/0:10.1.1.2/30 
R2:f0/1:172.16.1.1/24
R3:f0/1:172.16.1.2/24

R2>
R2>en 
R2#confi t 
R2(config)#int f0/1
R2(config-if)#ip address 172.16.1.1 255.255.255.0 --会覆盖掉之前的。
R2(config-if)#no shutdown 

R3>
R3>en 
R3#confi t 
R3(config)#int f0/1
R3(config-if)#ip address 172.16.1.2 255.255.255.0 --会覆盖掉之前的。
R3(config-if)#no shutdown 

R1#sh ip route 
C 10.1.1.0 is directly connnected,FastEthernet0/0
R 10.1.2.0 [120/1] via 10.1.1.2,00:01:39,FastEthernet0/0

R1:上路由条目R 还在。就是ping不通,因为我们已经修改了IP地址。
但是时间是:00:01:39,理论上不超过30s;所以该条目到达180s hold down 
路由条目会变为:
R1#sh ip route 
C 10.1.1.0 is directly connnected,FastEthernet0/0
R 10.1.2.0 is possibly down,routing via 10.1.1.2,FastEthernet0/0
--不可用,然后再经过一段时间会被自动删除。经过240s的时间,被自动删除。

R1# ping 172.16.1.1 --不能Ping通。

R2# confi t 
R2(config)#router rip 
R2(config-router)#network 172.16.1.0 

--自动出现再R1上。学习到了该路由。
R1# sh ip route 
R 172.16.0.0/16 [120/1] via 10.1.1.2,00:00:14,FastEthernet0/0


R 172.16.0.0/16 [120/1] via 10.1.1.2,00:00:14,FastEthernet0/0
R:表示通过rip学习到的。
172.16.0.0/16:学习到的地址。


R2:f0/1:172.16.1.1/24 :网络号是:172.16.1.0,但是这里学习到的是:
172.16.0.0/16

这个就是自动汇总。
自动汇总:
将所有子网络号汇总到主网络号。
172.16.1.1/24 =172.16.1.0 子网络号,这个B类地址,默认掩码是:16位。
所以主网络号:172.16.1.0 && 16 =172.16.0.0/16 

RIPv1 and RIPv2 都有自动汇总功能,但是RIPv1 不能关闭, 
RIPv2 的自动汇总功能可以关闭。

汇总路由表,主要是为了缩小路由表。

自动汇总:不支持不连续子网。

4.不连续子网

R1--->R2--->R3 
 |     |     |
 ↓     ↓     ↓
PC1    PC2   PC3 

R1:f0/1:172.16.1.254/24
R1:f0/0:10.1.1.1/30 
R2:f0/0:10.1.1.2/30 
R2:f0/1:10.1.2.1/30
R3:f0/1:10.1.2.2/30
R3:f0/1:172.16.2.254/24 

R2 没有接口了,需要增加模块。
R2# wr memory  --保存配置。
R2# --设备断电。

拖入:NM-1FE-TX 模块。
R2# --设备开店。FX 代表光口。TX 代表以太网,双绞线。
--我们插入TX;

--PC1:
IP:172.16.1.1 
Subnet Mask:255.255.255.0
gateway:172.16.1.254


--PC3:
IP:172.16.2.2
gateway:172.16.2.254


--PC2:
--IP:172.16.1.1 
--gateway:172.16.2.254

--R1#
R1#confi t 
R1(config)#int f0/0
R1(config-if)#ip address 172.16.1.254 255.255.255.0 
R1(config-if)#no shutdown 

--R3#
R3#confi t 
R3(config)#int f0/1
R3(config-if)#ip address 10.1.2.2 255.255.255.252
R3(config-if)#no shutdown 
R3(config-if)#exit 
R3(config)#int f0/0 
R3(config-if)#ip address 172.16.2.254  255.255.255.0
R3(config-if)#no shutdown 

--R2#
R2#confi t 
R2(config)#int f0/1
R2(config-if)#ip address 10.1.2.1 255.255.255.252 
R2(config-if)#no shutdown 
R2(config-if)#int f1/0 
R2(config-if)#ip address 10.1.10.254 255.255.255.0 
R2(config-if)#no shutdown 


PC1:
ping 172.16.2.2  --不能Ping通 
ping 10.1.10.1  --不能Ping通 

--清空IP路由。
R1# clear ip route * 
R1#confi t 
R1(config)#router rip 
R1(config-router)#network 172.16.1.0  --加入到RIP路由中

R3#confi t 
R3(config)#router rip 
R3(config-router)#network 172.16.2.0 
R3(config-router)#end 

R2#sh ip route 
R 172.16.0.0/16 [120/1] via 10.1.1.1,00:00:21,FastEthernet0/0

R3#confi t 
R3(config)#router rip 
R3(config-router)#network 10.0.0.0
R3(config-router)#end 

R2#sh ip route 
R 172.16.0.0/16 [120/1] via 10.1.1.1,00:00:21,FastEthernet0/0
				[120/1] via 10.1.2.2,00:00:21,FastEthernet0/1

这个就是不连续子网,到PC1是通的,到PC2是不通的。并且走两条路。

不连续子网:
同一个主网的不同子网被另一个子网分割开来,导致子网不连续。

--关闭路由的自动汇总。
R2(config-router)#no auto-summary  
R1(config-router)#no auto-summary  
R3(config-router)#no auto-summary  

--RIPv1 无法关闭自动汇总功能。
--要关闭自动汇总路由,必须使用:version 2,RIPv2
R2(config-router)#version 2  
R2(config-router)#no auto-summary  


R2#sh ip rou 
R 172.16.0.0/16 [120/1] via 10.1.2.2,00:00:06,FastEthernet0/1
R 172.16.1.0/24 [120/1] via 10.1.1.1,00:00:17,FastEthernet0/0
R2#sh ip rou
--R 172.16.0.0/16 [120/1] via 10.1.2.2,00:00:41,FastEthernet0/1 --超时2无效
R 172.16.1.0/24 [120/1] via 10.1.1.1,00:00:17,FastEthernet0/0
R 172.16.2.0/24 [120/1] via 10.1.2.2,00:00:15,FastEthernet0/1

PC2:
ping 172.16.1.1 
ping 172.16.2.2

router rip  --开启RIP 路由。
version 2 --开启RIP V2 
network 10.0.0.0 
network 172.16.0.0  --将路由加入到路由表中。
no auto-summary  --关闭RIP路由的自动汇总。

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值