CCNP2-RIP动态路由

基本概念

RIP(Routing Information Protocol,路由信息协议)
动态路由协议:RIP OSPF EIGRP BGP ISIS

  1. 按照使用范围进行分类:
  • IGP 协议 (RIP OSPF EIGRP ISIS) 一个AS之间
  • BGP 协议(BGP)
  1. 按照是否携带网络掩码:
  • 有类别(RIPV1):不携带网络掩码,即只能识别A类/8,B类/16,C类/24
    比如宣告10.0.1.0/24 172.16.1.0/22 192.168.1.64/28 路由表中只会识别A类10.0.0.0/8,B类172.16.0.0/16 C类192.168.1.0/24
  • 无类别 其他路由协议均为无类别
  1. 按照算法特点进行分类:
  • 距离矢量型:只传递路由信息,RIP
  • 链路状态型:传递路由信息和拓扑信息 ,OSPF,ISIS
    :EIGRP:增强的距离矢量型路由协议,具有距离矢量和链路状态两种特点
  1. RIP分为 RIPV1 RIPV2 RIPNG(IPV6)
  • 使用范围:IGP 小型网络中
  • 是否携带网络掩码 : RIPV1不携带 RIPV2携带
  • 算法: DV 贝尔曼-福特
  • 封装: 基于UDP封装,使用UDP端口号520,源端口和目的端口都是520。不可靠,要实现使用UDP达到可靠的目的,RIP中使用周期更新,OSPF使用IP封装,也不可靠,但OSPF本省使用确认,重传机制。
  • RIPV1:更新地址255.255.255.255(广播),交换机洪泛,与本地网络相连的和路由协议无关的主机解析到第四层看到端口520才丢弃
  • RIPV2:更新地址224.0.0.9(组播),组播MAC地址固定01-00-5e开头,交换机洪泛,主机解析到二层,直接丢弃。减少对不相关设备的消耗
  • 注:未知单播(交换机没有记录的未知MAC地址)交换机也会洪泛。
  1. 水平分割
    通过一个接口接收到的路由信息,不能再从这个接口转发出去,即从此口进不从此口出,用来防环。

RIP中的四个计时器

  1. 更新计时器(Update timer)30秒
    rip启动后,每隔25.5-30秒之间,刷新一次路由信息。
  2. 无效计时器(invalid timer)180秒
    每收到一条路由,无效计时器被初始化为180,当此条路由超过180秒没有被更新,将此条路由标记为不可达(跳数改为16),该路由条目进入possibly down状态,并向所有接口发送16跳的毒化路由,收到该毒化路由的路由器会立即删除该路由并返回该毒化路由(毒性逆转)点击查看详解
  3. 抑制计时器(holddown timer)180秒
    当一条路由被标记为不可达,立即开始抑制计时器,若此时间内收到Metric值更大的该路由条目,阻止该路由条目加表,为了防环。若超过180s仍然能收到该Metric值较大的路有条目,则加表。但实际上,只要再过60s,旧的不可达的路由条目就被删除,删除之后可以接受任何Metric值(小于16)的路由条目,因此这里的180s无意义。
  4. 刷新计时器(flush timer)240秒
    当路由条目被标记为不可达后,但还没有从路由表中被删除,但到达240s后(即被标记为不可达再过60s),该路由条目将被删除
    注:只要路由条目在路由表中,不管为什么状态,都可以转发数据。
    在这里插入图片描述

RIP防环机制

  1. 触发更新
    网络稳定时,通过使用更新计时器周期更新,但网络一但出现波动,比如某个接口down掉,则立即触发更新。
  2. 水平分割
    通过一个接口接收到的路由信息,不能再从这个接口转发出去,即从此口进不从此口出。
  3. 毒性逆转
    由于水平分割机制,一个接口正常收到一条路由信息后将不会再从此接口转发出去,但如果收到的是一条毒化路由(比如无效计时器超时,即发送16跳不可达的路由),那么收到该毒化路由的路由器会立即删除该路由,并且将会再从收到毒化路由的这个接口转发回去,用于确认发送毒化路由的路由器。
  4. 抑制计时器
    无效计时器超时后,抑制计时器立即工作,路由器从一个网段上得知一条路径失效,然后,立即在另一个网段上得知这个路由有效(Metric值较大)。这个有效的信息往往是不正确的,抑制计时避免了这个问题,而且,当一条链路频繁起停时,抑制计时减少了路由的浮动,增加了网络的稳定性。

汇总

自动汇总:将路由条目直接汇总为主类;
手工汇总:RIPV2支持手工汇总,仅仅支持VLSM(可变长子网掩码) 不支持CIDR(无类别域间路由。也称为超网)
Network:通告
比如:network 1.0.0.0
1.将本路由器上接口地址第一个八位组为1的接口激活,激活接口可以发送并接收RIP报文
2.将激活接口对应的接口路由通告进入RIP

RIP的收发原则

RIPV1:收版本1,发版本1
RIPV2:收版本2,发版本2
默认版本:收版本1,2,发版本1
以下实验将验证以上原则
由于RIP收敛较慢,以下所有实验结果均为clear ip route *之后的结果
在这里插入图片描述
R1使用RIPV1,R2使用默认版本,R3使用RIPV2

R1(config)#router rip 
R1(config-router)#version 1
R1(config-router)#network 12.0.0.0
R1(config-router)#network 1.0.0.0
R2(config)#router rip 
R2(config-router)#network 2.0.0.0
R2(config-router)#network 12.0.0.0
R2(config-router)#network 23.0.0.0
R3(config)#router rip 
R3(config-router)#version 2
R3(config-router)#no au
R3(config-router)#network 3.0.0.0
R3(config-router)#network 23.0.0.0

查看路由表,R1和R2路由齐全,R3什么也没学到
R1的路由齐全是因为:R3发送版本2,R2接收R3的版本2,R2发送版本1,因此R2将自己路由表中所有路由发给R1

R1#sho ip route rip 
R    2.0.0.0/8 [120/1] via 12.1.1.2, 00:00:04, Serial1/0
R    3.0.0.0/8 [120/2] via 12.1.1.2, 00:00:04, Serial1/0
R    23.0.0.0/8 [120/1] via 12.1.1.2, 00:00:04, Serial1/0

R2的路由齐全是因为:R2可以接收版本1和2

R2#sho ip route rip 
R    1.0.0.0/8 [120/1] via 12.1.1.1, 00:00:00, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/1] via 23.1.1.2, 00:00:16, FastEthernet0/0

R3没有路由的原因是:R2路由齐全,但R2发送的是版本1,R3并不接受版本1

R3#sho ip route rip 

查看当前正在运行的路由协议的详细信息

R1#sho ip protocols 
Routing Protocol is "rip"
  Default version control: send version 1, receive version 1
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial1/0             1     1                                    
    Loopback0             1     1             
R2#sho ip protocols 
Routing Protocol is "rip"
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       1     1 2                                  
    Serial1/0             1     1 2                                  
    Loopback0             1     1 2          
R3#sho ip protocols 
Routing Protocol is "rip"
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       2     2                                    
    Loopback0             2     2       

若想让R3路由齐全,只需在R3的F0/0接口修改可接受版本1即可,或在R2的F0/0修改可发送版本2即可。
这里修改R3的F0/0接口修改可接收版本1和2

R3(config)#int f0/0
R3(config-if)#ip rip receive version 1 2

再次查看R3路由

R3#sho ip route rip 
R    1.0.0.0/8 [120/2] via 23.1.1.1, 00:00:24, FastEthernet0/0
R    2.0.0.0/8 [120/1] via 23.1.1.1, 00:00:24, FastEthernet0/0
R    12.0.0.0/8 [120/1] via 23.1.1.1, 00:00:24, FastEthernet0/0
R3#sho ip protocols 
Routing Protocol is "rip"
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       2     1 2                                  
    Loopback0             2     2                               

也可使R2的F0/0修改可发送版本1和2

R2(config)#int f0/0
R2(config-if)#ip rip send version 1 2
R2(config-if)#en
R2#sho ip pro
Routing Protocol is "rip"
  Default version control: send version 1, receive any version
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       1 2   1 2                                  
    Serial1/0             1     1 2                                  
    Loopback0             1     1 2                              

RIP手工汇总

意义:
1.减少路由条目
2.增加路由表的稳定性,不会因为其中某一条路由的翻滚而改变路由表
实验:
三个路由器都使用RIPV2并宣告自己的路由
R1单独创建几个环回地址并宣告

R1(config)#int lo1 
R1(config-if)#ip address 10.1.1.1 255.255.255.0
R1(config-if)#int lo2                          
R1(config-if)#ip address 10.1.2.1 255.255.255.0
R1(config-if)#int lo3                          
R1(config-if)#ip address 10.1.3.1 255.255.255.0
R1(config)#router rip 
R1(config-router)#network 10.0.0.0

汇总在明细路由所在路由的出接口上做,这里在R1的S1/0出接口上做

R1(config)#int s1/0
R1(config-if)#ip summary-address rip 10.1.0.0 255.255.252.0

查看R2路由,IGP协议发送汇总路由时,明细路由会被抑制

R2#sho ip route rip 
     1.0.0.0/24 is subnetted, 1 subnets
R       1.1.1.0 [120/1] via 12.1.1.1, 00:00:07, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/1] via 23.1.1.2, 00:00:07, FastEthernet0/0
     10.0.0.0/22 is subnetted, 1 subnets
R       10.1.0.0 [120/1] via 12.1.1.1, 00:00:07, Serial1/0

注意:这里的10.1.1.0-3.0都是在R1上的,如果不是在R1上,而是分散在R1前边的路由器上,只是在R1上做汇总的话,三条路由器的metric会不一致,这里汇总后则会使用metric最小的那一个。
汇总路由会在所有的明细路由消失后才会消息。这里shutdown掉R1的lo1,2,3后汇总路由则会消失,这里不做验证。
RIPV2不支持CIDR

R1(config-if)#ip summary-address rip 200.1.0.0 255.255.252.0
 Summary mask must be greater or equal to major net

RIP的被动接口

如果R1底下一个接口接了一台交换机,交换机底下接了若干台不相关设备(电脑等),而这个接口的网段必须宣告到路由中,宣告意味着此接口会向下发送周期更新,而底下的不相干设备时不需要接受这些信息的,甚至有可能带来安全隐患(此接口下非法抓包分析,既获得了路由信息),这时候需要将此接口设置为被动接口,则此接口(即一般为路由器连接用户的接口)不能向外发送路由信息,但不影响接受。
R2的环回没有做被动接口之前

R2#debug ip rip events 
RIP event debugging is on
*Nov 10 20:15:05.167: RIP: sending v2 update to 224.0.0.9 via FastEthernet0/0 (23.1.1.1)
*Nov 10 20:15:08.091: RIP: sending v2 update to 224.0.0.9 via Loopback0 (2.2.2.2)
*Nov 10 20:15:14.023: RIP: sending v2 update to 224.0.0.9 via Serial1/0 (12.1.1.2)
R2#un all

R2的lo0口做被动接口

R2(config)#router rip 
R2(config-router)#passive-interface loopback 0

再次打开debug

R2#debug ip rip events 
RIP event debugging is on
*Nov 10 20:18:20.687: RIP: sending v2 update to 224.0.0.9 via FastEthernet0/0 (23.1.1.1)
*Nov 10 20:18:22.427: RIP: sending v2 update to 224.0.0.9 via Serial1/0 (12.1.1.2)
R2#un all

这里已经看不到lo0口向外发送周期更新了。

RIP的单播邻居

RIPv2默认使用组播更新,在点对点链路中(R1和R2)可以使用单播邻居更新

R1(config)#router rip 
R1(config-router)#neighbor 12.1.1.2
R2(config)#router rip 
R2(config-router)#neighbor 12.1.1.1

查看debug信息

R1#debug ip rip events 
RIP event debugging is on

*Nov 10 20:23:49.451: RIP: sending v2 update to 224.0.0.9 via Serial1/0 (12.1.1.1)
*Nov 10 20:23:49.455: RIP: sending v2 update to 12.1.1.2 via Serial1/0 (12.1.1.1)
*Nov 10 20:23:53.331: RIP: received v2 update from 12.1.1.2 on Serial1/0
*Nov 10 20:23:53.335: RIP: received v2 update from 12.1.1.2 on Serial1/0
R1#un all

可以看到已经有对R2的单播更新,但同时对R2的组播更新依然存在
这时将R1和R2连接的接口做成被动接口,则不能向外发送组播更新。

R1(config)#router rip 
R1(config-router)#passive-interface s1/0
R2(config)#router rip 
R2(config-router)#passive-interface s1/0

再次查看debug信息

R1#debug ip rip events 
RIP event debugging is on
*Nov 10 20:47:33.163: RIP: sending v2 update to 12.1.1.2 via Serial1/0 (12.1.1.1)
*Nov 10 20:47:43.907: RIP: received v2 update from 12.1.1.2 on Serial1/0
R1#un all 

RIP的触发更新

只能在低速链路(串行链路)开启
在R1和R2的S1/0接口上开启触发更新,两端都需要开启

R1(config)#int s1/0
R1(config-if)#ip rip triggered 
R2(config)#int s1/0
R2(config-if)#ip rip triggered

开启RIP的debug同时shutdown接口lo0

R1#debug ip rip events 
RIP event debugging is on
R1#debug ip rip trigger 
RIP trigger debugging is on
R1#configure t
R1(config)#int lo0
R1(config-if)#shu
*Nov 10 21:01:08.035: RIP: send v2 triggered update to 12.1.1.2 on Serial1/0
*Nov 10 21:01:08.075: RIP: received v2 triggered ack from 12.1.1.2 on Serial1/0

可以看到已经没有了周期更新,而是触发更新,同时开启触发更新后抑制计时器会失效,因为触发更新的路由要立即加表。

RIP的计时器

会增加链路和设备资源,但网络收敛速度加快,一般不建议更改
更改时建议按1:6:6:8的比例进行更改,10 60 60 80更加权衡

R3(config)#router rip 
R3(config-router)#timers basic 10 60 60 80

只在一端更改计时器并不影响路由的学习。

RIP的路由认证

前面说到,做被动接口后,该接口不在向下发送路由信息,但依然能接收路由信息,若此时有非法人员模拟路由器向该接口的路由器发送RIP报文,扰乱网络,甚至导致网络瘫痪,因此,还有必要向此接口做路由认证。这里在R2和R3之间做路由认证
1.在R2做钥匙链

R2(config)#key chain ccnp
R2(config-keychain)#key 1
R2(config-keychain-key)#key-string cisco

2.在接口调用,使用md5方式

R2(config)#int f0/0
R2(config-if)#ip rip authentication mode md5
R2(config-if)#ip rip authentication key-chain ccnp

此时在R3上查看路由,已经没有了

R3#sho ip route rip 

3.在R3上也做,双方的key编号和密码以及认证方式(md5)必须一致,钥匙链名称无所谓

R3(config)#key chain ccie
R3(config-keychain)#key 1
R3(config-keychain-key)#key-string cisco
R3(config)#int f0/0
R3(config-if)#ip rip authentication mode md5 
R3(config-if)#ip rip authentication key-chain ccie

此时查看R3路由表

R3#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 23.1.1.1, 00:00:07, FastEthernet0/0
     10.0.0.0/22 is subnetted, 1 subnets
R       10.1.0.0 [120/2] via 23.1.1.1, 00:00:07, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
R       12.1.1.0 [120/1] via 23.1.1.1, 00:00:07, FastEthernet0/0

RIP的更新源检测

255.255.255.255 受限广播地址,只能在一个局域网内传输
224.0.0.x 受限组播地址,只能在一个局域网内传输
RIP:224.0.0.9 特殊:允许穿越一次路由器
OSPF:224.0.0.5 224.0.0.6
EIGRP:224.0.0.10 特殊:允许穿越一次路由器
RIP中两个路由器在发送路由更新时,两个路由器的两个接口必须在同一网段,在发送路由更新之前,会先进行更新源检测,检测两个接口的IP是否在同一网段,若不在同一网段,更新源检测失败,路由不学习。
现将R1连接R2的接口S1/0地址改为21.1.1.1并通告

R1#sho ip route rip 

此时R1已经没有路由
在R1和R2上关闭更新源检测

R1(config-router)#no validate-update-source 
R2(config-router)#no validate-update-source 

此时重新查看R1路由,这种双方地址不在同一网段,关闭更新源检测可以学习到路由的情况仅限于串行链路

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:01
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:01
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:01

注意:此时虽然路由是可以学习到的,但是数据层面是不通的,ping 2.2.2.2时,下一跳为12.1.1.2,但此时路由器并没有到达12.1.1.0的路由,递归失败。解决办法将此段链路封装改为ppp封装,因为在ppp的ncp协商阶段,双方会学习对方的主机路由。
未更改之前

R1#sho ip route 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:23
     21.0.0.0/24 is subnetted, 1 subnets
C       21.1.1.0 is directly connected, Serial1/0

链路更改为ppp封装

R1(config)#int s1/0
R1(config-if)#encapsulation ppp
R2(config)#int s1/1
R2(config-if)#encapsulation ppp

更改之后

R1#sho ip route 
     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:01
     21.0.0.0/24 is subnetted, 1 subnets
C       21.1.1.0 is directly connected, Serial1/0
     12.0.0.0/32 is subnetted, 1 subnets
C       12.1.1.2 is directly connected, Serial1/0

可以看到更改之后直连路由多了一条到达12.1.1.0的路由

R1#ping 2.2.2.2
Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 2.2.2.2, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/23/28 ms

RIP的缺省

RIP的缺省共有5种产生方式

1.边界路由器使用default-information下发缺省

在R3上创建lo1模拟公网ip

R3(config-if)#int lo1
R3(config-if)#ip address 200.1.1.1 255.255.255.0

未下发缺省时R1的路由表

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:01, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:01, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:01, Serial1/0

在R3边界路由下上下发缺省

R3(config)#router rip 
R3(config-router)#default-information originate

下发缺省后R1的路由表,此时路由表中已经有了一条缺省路由。

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:07, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:07, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:07, Serial1/0
R*   0.0.0.0/0 [120/2] via 12.1.1.2, 00:00:01, Serial1/0

测试ping

R1#ping 200.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 200.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/39/68 ms

2.使用手工汇总产生缺省路由

在R3上把所有路由汇总成0.0.0.0/0

R3(config)#int f0/0
R3(config-if)#ip summary-address rip 0.0.0.0 0.0.0.0

再次查看R1路由表,已经有一条缺省路由,但是注意:3.3.3.0/24这条R3的路由已经没有了,因为汇总所在路由器的明细路由将被抑制。

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:04, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:04, Serial1/0
R*   0.0.0.0/0 [120/2] via 12.1.1.2, 00:00:04, Serial1/0

测试

R1#ping 200.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 200.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 20/37/72 ms
R1#ping 3.3.3.3

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 3.3.3.3, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/40/68 ms

3.network通告产生缺省

Network:通告
1.激活接口
2.将激活接口对应的接口路由通告进入RIP
在IGP协议中,network必须是,先激活接口,然后通告接口对应的路由,不能把一条路由直接network
但在RIP和EIGRP中,可以把一条出接口写法的静态路由network
所以我们可以写一条出接口写法的静态路由,然后network到RIP

R3(config)#ip route 0.0.0.0 0.0.0.0 loopback 0
R3(config)#router rip 
R3(config-router)#network 0.0.0.0

此时R1的路由表中已经有一条缺省路由,但注意:R3上的200.1.1.0/24和200.1.2.0/24也都被R1学习,因为network 0.0.0.0还有一个作用就是激活所有接口。这里的200.1.1.0/24和200.1.2.0/24为R3上模拟运营商的,实际在R3上并不存在。

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:04, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:04, Serial1/0
R    200.1.1.0/24 [120/2] via 12.1.1.2, 00:00:02, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:04, Serial1/0
R    200.1.2.0/24 [120/2] via 12.1.1.2, 00:00:02, Serial1/0
R*   0.0.0.0/0 [120/2] via 12.1.1.2, 00:00:02, Serial1/0
R1#ping 200.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 200.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/45/72 ms

4.重发布产生缺省

我们可以写一条静态路由,然后重发布进RIP当中

R3(config)#ip route 0.0.0.0 0.0.0.0 loopback 0
R3(config)#router rip 
R3(config-router)#redistribute static

测试

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:06, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:06, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:06, Serial1/0
R*   0.0.0.0/0 [120/2] via 12.1.1.2, 00:00:05, Serial1/0
R1#ping 200.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 200.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/68 ms

5.default network 缺省网络

将一个主类网络设置为默认网络并通告到RIP当中

R3(config)#int loopback 100
R3(config-if)#ip address 192.168.1.1 255.255.255.0
R3(config-if)#exi
R3(config)#ip default-network 192.168.1.0 
R3(config)#router rip 
R3(config-router)#network 192.168.1.0

测试

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:01, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:01, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:01, Serial1/0
R    192.168.1.0/24 [120/2] via 12.1.1.2, 00:00:01, Serial1/0
R*   0.0.0.0/0 [120/2] via 12.1.1.2, 00:00:01, Serial1/0
R1#ping 200.1.1.1

Type escape sequence to abort.
Sending 5, 100-byte ICMP Echos to 200.1.1.1, timeout is 2 seconds:
!!!!!
Success rate is 100 percent (5/5), round-trip min/avg/max = 12/40/72 ms

注意:出现环路

前边我们将10.1.1.0/24 10.1.2.0/24 10.1.3.0/24汇总为10.1.0.0/22,但实际上这个网段还包含了10.1.0.0/24网段
此时R2和R1的路由表为
R2

R2#sho ip route rip 
     1.0.0.0/24 is subnetted, 1 subnets
R       1.1.1.0 [120/1] via 12.1.1.1, 00:00:06, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/1] via 23.1.1.2, 00:00:07, FastEthernet0/0
     10.0.0.0/22 is subnetted, 1 subnets
R       10.1.0.0 [120/1] via 12.1.1.1, 00:00:06, Serial1/0
R    192.168.1.0/24 [120/1] via 23.1.1.2, 00:00:07, FastEthernet0/0
R*   0.0.0.0/0 [120/1] via 23.1.1.2, 00:00:07, FastEthernet0/0

R1

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:05, Serial1/0
     3.0.0.0/24 is subnetted, 1 subnets
R       3.3.3.0 [120/2] via 12.1.1.2, 00:00:05, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:05, Serial1/0
R    192.168.1.0/24 [120/2] via 12.1.1.2, 00:00:05, Serial1/0
R*   0.0.0.0/0 [120/2] via 12.1.1.2, 00:00:05, Serial1/0

如果R2要去10.1.0.0/24网段,因为有去10.1.0.0/22的路由,出接口指向R1,而R1没有去10.1.0.0/24的路由,但是R1有缺省,因此R1又会扔给R2,以此循环,形成环路

R2#traceroute 10.1.0.1

Type escape sequence to abort.
Tracing the route to 10.1.0.1

  1 12.1.1.1 32 msec 20 msec 24 msec
  2 12.1.1.2 40 msec 44 msec 40 msec
  3 12.1.1.1 44 msec 40 msec 44 msec
  4 12.1.1.2 64 msec 64 msec 64 msec
  5 12.1.1.1 64 msec 60 msec 64 msec
  6 12.1.1.2 84 msec 84 msec 84 msec
  7 12.1.1.1 84 msec 80 msec 84 msec

因此 汇总+缺省=环路
所以我们必须在R1向外汇总的时候写一条指向null 0的防环路由,当R2扔给R1的时候,R1不会去找缺省,而是会找这条防环路由(最长匹配),然后又是指向null 0 的,所以避免了环路
R1(config)#ip route 10.1.0.0 255.255.252.0 null 0
再次测试

 R2#traceroute 10.1.0.1

Type escape sequence to abort.
Tracing the route to 10.1.0.1

  1 12.1.1.1 32 msec 24 msec 16 msec
  2 12.1.1.1 !H  !H  !H 

RIP的路由调整

这里我们将R1和R3所有环回接口shutdown,各自创建一个新的环回lo 200,200.1.1.0/24 并通告到RIP
此时R1,R2,R3的路由表,即R2负载均衡,接下来我们进行路由调整

R1#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 12.1.1.2, 00:00:14, Serial1/0
     23.0.0.0/24 is subnetted, 1 subnets
R       23.1.1.0 [120/1] via 12.1.1.2, 00:00:14, Serial1/0

R2#sho ip route rip 
R    200.1.1.0/24 [120/1] via 23.1.1.2, 00:00:03, FastEthernet0/0
                  [120/1] via 12.1.1.1, 00:00:03, Serial1/0
                  
R3#sho ip route rip 
     2.0.0.0/24 is subnetted, 1 subnets
R       2.2.2.0 [120/1] via 23.1.1.1, 00:00:00, FastEthernet0/0
     12.0.0.0/24 is subnetted, 1 subnets
R       12.1.1.0 [120/1] via 23.1.1.1, 00:00:00, FastEthernet0/0

1.修改AD值,小优

R2(config)#router rip 
R2(config-router)#distance 100
R2#sho ip route rip 
R    200.1.1.0/24 [100/1] via 23.1.1.2, 00:00:09, FastEthernet0/0
                  [100/1] via 12.1.1.1, 00:00:05, Serial1/0

这种方式会把RIP学习到的路由的AD值全都改为100,适用于运行多种路由协议,将RIP学习到的路由AD改为100,其他路由协议学习到的路由不修改。
2.只把12.1.1.1发来的路由AD值改为100

R2(config)#router rip 
R2(config-router)#no distance 100
R2(config-router)#distance 100 12.1.1.1 0.0.0.0
R2#sho ip route rip 
R    200.1.1.0/24 [100/1] via 12.1.1.1, 00:00:13, Serial1/0

此时R2优选了较小AD值为100的路由
3.若此时又敲了一条命令,即此时即把所有的AD改为99,又把R1发来的改为100
R2(config-router)#distance 99
结果是

R2#sho ip route rip 
R    200.1.1.0/24 [99/1] via 23.1.1.2, 00:00:00, FastEthernet0/0

这是因为按最精确的执行,即把R3发来的路由按99修改,把R1发来的路由按更精确的100修改,而非99,故路由优选R3的99

2.修改metric值,小优

metric值用来放环,只能增加,不能减小
若此时只想学习R1发来的路由,则需要把R3发来的路由metric增加,可以在R3出或者R2入方向实施,in影响自己,out影响别人
在R3出方向做
第一步:在R3上抓取需要修改的路由,使用acl抓取
R3(config)#access-list 1 permit 200.1.1.0
第二步:在R3的RIP上实施偏移列表,(metric增加3,出方向,接口f0/0,若不跟接口,则为所有出接口全部metric增加3)
R3(config)#router rip
R3(config-router)#offset-list 1 out 3 fastEthernet 0/0
再次查看R2路由表,优选了metric较小的R1发来的路由

R2#sho ip route rip 
R    200.1.1.0/24 [120/1] via 12.1.1.1, 00:00:16, Serial1/0
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值