RIPv2实验(思科Cisco)

在这里插入图片描述

1、先根据拓扑配置ip及其网关

R1

R1(config)#interface fastEthernet 0/0
R1(config-if)#ip address 176.16.1.254 255.255.255.0
R1(config-if)#no shutdown 
R1(config-if)#exit 
R1(config)#interface serial 2/0
R1(config-if)#clock rate 64000    
R1(config-if)#ip address 192.168.12.1 255.255.255.0
R1(config-if)#no shutdown 

R2

R2(config)#interface serial 0/1
R2(config-if)#clock rate 64000
R2(config-if)#ip address 192.168.12.2 255.255.255.0
R2(config-if)#no shutdown 
R2(config-if)#exit 
R2(config)#interface serial 0/2
R2(config-if)#clock rate 64000
R2(config-if)#ip address 192.168.23.2 255.255.255.0
R2(config-if)#no shutdown 

R3

R3(config)#interface serial 2/0
R3(config-if)#clock rate 64000
R3(config-if)#ip address 192.168.23.3 255.255.255.0
R3(config-if)#no shutdown 
R3(config-if)#exit 
R3(config)#interface loopback 1
R3(config-if)#ip address 172.16.32.1 255.255.255.0
R3(config-if)#exit
R3(config)#interface loopback 2
R3(config-if)#ip address 172.16.33.1 255.255.255.0
R3(config-if)#exit
R3(config)#interface loopback 3
R3(config-if)#ip address 172.16.34.1 255.255.255.0

R4(模拟PC)

R4#configure terminal 
R4(config)#no ip routing
R4(config)#ip default-gateway 172.16.1.254
R4(config)#interface fastEthernet 0/0
R4(config-if)#ip address 172.16.1.1 255.255.255.0
R4(config-if)#no shutdown 
R4#show ip route 
Default gateway is 172.16.1.254
Host               Gateway           Last Use    Total Uses  Interface
ICMP redirect cache is empty
R4#show ip interface brief 
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            172.16.1.1      YES NVRAM  up                    up      
FastEthernet1/0            unassigned      YES NVRAM  administratively down down    
Ethernet2/0                unassigned      YES NVRAM  administratively down down    
Ethernet2/1                unassigned      YES NVRAM  administratively down down    
Ethernet2/2                unassigned      YES NVRAM  administratively down down    
Ethernet2/3                unassigned      YES NVRAM  administratively down down    
然后连通性测试,保证直链链路都是正常的

2、R1、R2、R3运行RIP

出现等价负载均衡的现象

R1

R1(config)#router rip                     //创建 RIP 进程
R1(config-router)# version 2              //将 RIP 设置为版本 2即RIPv2
R1(config-router)# network 192.168.12.0   //在 S0/0 口上激活 RIPv2
R1(config-router)# network 172.16.0.0     //在 F1/0 口上激活 RIPv2

R2

R2(config)# router rip
R2(config-router)# version 2
R2(config-router)# network 192.168.12.0
R2(config-router)# network 192.168.23.0

R3

R3(config)# router rip
R3(config-router)# version 2
R3(config-router)# network 192.168.23.0
R3(config-router)# network 172.16.0.0

注意:
RIP 在使用 network 命令指定网段时,只支持通告主类网络。R3 有三个Loopback 接口,将这三个接口激活 RIP 时,只需 network 172.16.0.0 即可,实际上即使你输入诸如 network 172.16.32.0 这样的命令,系统也会按 network 172.16.0.0 生效。

R1#show
*Mar  1 00:40:09.639: %SYS-5-CONFIG_I: Configured from console by console
R1#show ip p
R1#show ip pr
R1#show ip pro
R1#show ip protocols 
Routing Protocol is "rip"
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Sending updates every 30 seconds, next due in 3 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Redistributing: rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    FastEthernet0/0       2     2                                    
    Serial2/0             2     2                       //2个接口激活了RIP             
  Automatic network summarization is in effect    //自动汇总功能默认开启
  Maximum path: 4
  Routing for Networks:
    172.16.0.0
    192.168.12.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.12.2         120      00:00:11
  Distance: (default is 120)   //管理距离 120

现在,我们尝试让PC1ping一下R3的loopback接口,发现ping不通。那么为什么不通呢?
此刻我们需要做的就是保证沿途的每一跳路由器上,都有到达目的地的路由,并且回程的数据也要能顺利的返回到PC1。
R1上查看路由表:

R1#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.12.0/24 is directly connected, Serial2/0
     172.16.0.0/24 is subnetted, 1 subnets
C       172.16.1.0 is directly connected, FastEthernet0/0
R    192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:07, Serial2/0

现象:
R1已经学习到R2-R3互联网段的路由192.168.23.0/24,奇怪的是并没有看到R3Loopback
就是说R1ping不通R4,但是拼的通R3的几个回环口

R2上查看路由表:

R2#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.12.0/24 is directly connected, Serial0/1
R    172.16.0.0/16 [120/1] via 192.168.23.3, 00:00:17, Serial0/2
                   [120/1] via 192.168.12.1, 00:00:20, Serial0/1
C    192.168.23.0/24 is directly connected, Serial0/2

现象:
R2出现了一个奇怪的现象,路由表显示它从R1及R3都学习到了172.16.0.0/16路由,而且
很显然,R2将这两条路由都装载进了路由表里,进行“等价负载均衡”。这个现象将造成什么问题呢?
R2会认为,到达172.16.0.0网络即可从R1走又可以从R3走,那么问题来了,R2要去往172.16.1.0/24,也就是R1下联的网段,如果从R3走就肯定无法走通了,这就是问题所在了。为什么会造成这样的问题呢?其实这是RIPv2的自动汇总机制使然。由于R1、R3都处于“主类网络边界”,拿R1来说,有直连网络192.168.12.0/24及172.16.1.0/24,因此R1就是两个主类网络的边界,RIPv2在将子网路由172.16.1.0/24通告给192.168.12.0/24网络时,会将其进行自动汇总,汇总成172.16.0.0/16,R3也是类似的动作,就造成了R2路由表的诡异现象。
其实自动汇总的本意是为了减小路由条目,优化路由表,减小设备资源的损耗,但是在这个拓扑中却带来了这个问题,因为172.16.0.0/16网络的子网分处R1、R3两个地方。那么怎么解决呢?办法很简单,就是关闭自动汇总。

关闭自动汇总
R1(config)#router rip
R1(config-router)#no auto-summary 
R2(config)#router rip
R2(config-router)#no auto-summary 
R3(config)#router rip
R3(config-router)#no auto-summary 

查看R1、R2、R3这个时候的路由表
R1:

R1#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
//R1学习到了全网的明细路由
C    192.168.12.0/24 is directly connected, Serial2/0
     172.16.0.0/24 is subnetted, 4 subnets  
R       172.16.32.0 [120/2] via 192.168.12.2, 00:00:27, Serial2/0
R       172.16.33.0 [120/2] via 192.168.12.2, 00:00:27, Serial2/0
R       172.16.34.0 [120/2] via 192.168.12.2, 00:00:27, Serial2/0
C       172.16.1.0 is directly connected, FastEthernet0/0
R    192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:27, Serial2/0

R2:

R2#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.12.0/24 is directly connected, Serial0/1
     172.16.0.0/24 is subnetted, 4 subnets
R       172.16.32.0 [120/1] via 192.168.23.3, 00:00:26, Serial0/2
R       172.16.33.0 [120/1] via 192.168.23.3, 00:00:26, Serial0/2
R       172.16.34.0 [120/1] via 192.168.23.3, 00:00:26, Serial0/2
R       172.16.1.0 [120/1] via 192.168.12.1, 00:00:27, Serial0/1
C    192.168.23.0/24 is directly connected, Serial0/2

R3:

R3#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

R    192.168.12.0/24 [120/1] via 192.168.23.2, 00:00:10, Serial2/0
     172.16.0.0/24 is subnetted, 4 subnets
C       172.16.32.0 is directly connected, Loopback1
C       172.16.33.0 is directly connected, Loopback2
C       172.16.34.0 is directly connected, Loopback3
R       172.16.1.0 [120/2] via 192.168.23.2, 00:00:10, Serial2/0
C    192.168.23.0/24 is directly connected, Serial2/0

3、优化路由(手工汇总)

我们在R1、R2、R3上关闭自动汇总后,每台路由器就能学习到全网明细路由,满足前面提到的数据访问的需求。但是这也带来了一个新的问题

在关闭自动汇总后,R3将下联的所有Loopback明细路由都放出来了,这对网络中的其他设备而言是一种负担,这个动作丢失了路由汇总原有的利好。怎么办?

我们可以用手工汇总,将172.16.32.0/24、172.16.33.0/24、172.16.34.0/24这三个子网进行精确汇总,根据我们的计算,得到汇总路由:172.16.32.0/22,这个汇总地址刚好将三个明细子网囊括。在R3上增加的配置如下(注意RIP的手工汇总,是配置在接口上的):

R3(config)#interface Serial0/0
R3(config-if)#ip summary-addressrip 172.16.32.0255.255.252.0

RIP收敛特别慢,所以敲完这条命令要等一会

注意:

需要注意的是,RIP的手工汇总不支持CIDR,就是V1不支持手工汇总,V1是无类路由

查看R1路由表:

R1#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.12.0/24 is directly connected, Serial2/0
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
     //已经汇总成一条
R       172.16.32.0/22 [120/2] via 192.168.12.2, 00:00:01, Serial2/0 
C       172.16.1.0/24 is directly connected, FastEthernet0/0
R    192.168.23.0/24 [120/1] via 192.168.12.2, 00:00:01, Serial2/0
结果:

R1从R2学习到了192.168.23.0/24路由,也学到了R3发布的手工汇总的路由。
再强调一下,RIP的手工汇总,需要RIP版本2的支持,另外需要先在RIP进程中noauto-summary关闭自动汇总功能,然后再在接口上配置手工汇总命令,注意,该命令配置在汇总路由欲对外发布的那个接口上。

查看R2的路由表

R3#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

R    192.168.12.0/24 [120/1] via 192.168.23.2, 00:00:12, Serial2/0
     172.16.0.0/24 is subnetted, 4 subnets
C       172.16.32.0 is directly connected, Loopback1    //路由表选取直链路由
C       172.16.33.0 is directly connected, Loopback2
C       172.16.34.0 is directly connected, Loopback3
R       172.16.1.0 [120/2] via 192.168.23.2, 00:00:12, Serial2/0
C    192.168.23.0/24 is directly connected, Serial2/0
思考:

为什么R3路由表选取直链路由?

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

JoyceLai

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值