rip2的路由汇总实验:

CCNA之旅-rip协议3_休闲

拓扑如上图:

R1基本配置:

Router#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
Router(config)#hostname r1
r1(config)#no ip domain-lookup       
r1(config)#line console 0
r1(config-line)#no exec-timeout
r1(config-line)#logging synchronous
r1(config-line)#exit
r1(config)#int f0/0
r1(config-if)#ip add 192.168.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#int lo0:
00:01:30: %LINK-3-UPDOWN: Interface FastEthernet0/0, changed state to up
00:01:31: %LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
r1(config-if)#int lo0
r1(config-if)#ip add 1.1.1.1 255.255.255.0
r1(config-if)#no shut
r1(config-if)#end
r1#show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            192.168.1.1     YES manual up                    up     
Serial1/0                  unassigned      YES unset  administratively down down   
Serial1/1                  unassigned      YES unset  administratively down down   
Serial1/2                  unassigned      YES unset  administratively down down   
Serial1/3                  unassigned      YES unset  administratively down down   
Loopback0                  1.1.1.1         YES manual up                    up    

R2、R3都做以上配置,IP地址如图中所示。

r2#show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down   
Serial1/0                  192.168.1.2     YES manual up                    up     
Serial1/1                  192.168.2.1     YES manual up                    up     
Serial1/2                  unassigned      YES unset  administratively down down   
Serial1/3                  unassigned      YES unset  administratively down down   

r3#show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down   
Serial1/0                  unassigned      YES unset  administratively down down   
Serial1/1                  192.168.2.2     YES manual up                    up     
Serial1/2                  unassigned      YES unset  administratively down down   
Serial1/3                  unassigned      YES unset  administratively down down   
Loopback0                  2.2.0.2         YES manual up                    up     
Loopback1                  2.2.1.2         YES manual up                    up     
Loopback2                  2.2.2.2         YES manual up                    up     
Loopback3                  2.2.3.2         YES manual up                    up     
r3#

现在配置RIP2协议:

 r1(config)#router rip
r1(config-router)#version 2
r1(config-router)#no auto
r1(config-router)#no auto-summary
r1(config-router)#network 1.0.0.0
r1(config-router)#network 192.168.1.0
r1(config-router)#end

r2(config)#router rip
r2(config-router)#version 2
r2(config-router)#no auto
r2(config-router)#no auto-summary
r2(config-router)#network 192.168.1.0
r2(config-router)#network 192.168.2.0
r2(config-router)#end

 

r3(config)#router rip
r3(config-router)#version 2
r3(config-router)#no auto
r3(config-router)#no auto-summary
r3(config-router)#network 192.168.2.0
r3(config-router)#network 2.0.0.0
r3(config-router)#end

现在我们查看路由表

r1#show ip route
Codes: C - connected, 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, 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

     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, 4 subnets     rip2无类别路由协议,在更新中携带子网信息

R       2.2.0.0 [120/2] via 192.168.1.2, 00:00:20, Serial1/0
R       2.2.1.0 [120/2] via 192.168.1.2, 00:00:20, Serial1/0
R       2.2.2.0 [120/2] via 192.168.1.2, 00:00:20, Serial1/0
R       2.2.3.0 [120/2] via 192.168.1.2, 00:00:20, Serial1/0 这是我们关闭了rip2的自动汇总功能,并且没有手工汇总时的路由表
C    192.168.1.0/24 is directly connected, Serial1/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:20, Serial1/0

我们把rip2的自动汇总功能打开,会看到如下结果的路由表:

r1#show ip route
Codes: C - connected, 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, 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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
R    2.0.0.0/8 [120/2] via 192.168.1.2, 00:00:06, Serial1/0 这时已进行自动主类掩码汇总了和之前的路由表大有不同了吧!
C    192.168.1.0/24 is directly connected, Serial1/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:06, Serial1/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:
!!!!!

 

这里rip2进行的是自动汇总,汇总的掩码是ip的默认主类掩码,有时候我们并不希望它进行这样的汇总,因为它太笼统了,、本实验中,router3,中模拟回环接口的ip分别为:2.2.0.2/24  2.2.1.2/24  2.2.2.2/24 2.2.3.2/24 我们完全可以把这些网段汇总成2.2.0.0/22,这样看起来,网络层次比较清晰一些.......

我们在路由器3上做路由手动汇总,同时关闭三个路由器的RIP进程的自动汇总功能,

r3(config)#router rip
r3(config-router)#version 2
r3(config-router)#no auto-summary
r3(config-router)#end

r3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
r3(config)#interface s1/1

r3(config-if)#ip summary-address rip 2.2.0.0 255.255.252.0
r3(config-if)#end

 

等待片刻.........

再查看路由1上的路由表.........

r1#show ip route
Codes: C - connected, 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, 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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
     2.0.0.0/22 is subnetted, 1 subnets
R       2.2.0.0 [120/2] via 192.168.1.2, 00:00:08, Serial1/0  
效果出来了!
C    192.168.1.0/24 is directly connected, Serial1/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:08, Serial1/0

 

同时路由器2上的路由也会收到这样的手工汇总路由条目......

在做手工汇总的时候要注意:汇总后的掩码长度必须要大于或等于主类网络的掩码长度,比如要汇总一个C类地址,汇总后的掩码必须大于24,b类的必须大于16,a类的必须大于8......

从这一点可以看出,rip2是不支持CIDR的,但是可以传递CIDR.......

例如本实验中,把路由器3总的四个回环接口改为:192.168.96.2/24 192.168.97.2/24 192.168.98.2/24 192.168.99.2/24

r3#show ip int brief
Interface                  IP-Address      OK? Method Status                Protocol
FastEthernet0/0            unassigned      YES unset  administratively down down   
Serial1/0                  unassigned      YES unset  administratively down down   
Serial1/1                  192.168.2.2     YES manual up                    up     
Serial1/2                  unassigned      YES unset  administratively down down   
Serial1/3                  unassigned      YES unset  administratively down down   
Loopback0                  192.168.96.2    YES manual up                    up     
Loopback1                  192.168.97.2    YES manual up                    up     
Loopback2                  192.168.98.2    YES manual up                    up     
Loopback3                  192.168.99.2    YES manual up                    up     
r3#

r3#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
r3(config)#router rip
r3(config-router)#version 2
r3(config-router)#no network 2.0.0.0
r3(config-router)#network 192.168.96.0
r3(config-router)#network 192.168.97.0
r3(config-router)#network 192.168.98.0
r3(config-router)#network 192.168.99.0
r3(config-router)#end

 

r3(config)#int s1/1
r3(config-if)#no ip summary-address rip 2.2.0.0 255.255.252.0

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

这个提示就说明了:汇总后的掩码长度必须要大于或等于主类网络的掩码长度,因为汇总后的掩码为22小于C类默认掩码24那怎么办呢?
r3(config-if)#

我们可以用静态路由发布汇总的路由然后,然后把这路由重分布到RIP2中,

r3(config)#ip route 192.168.96.0 255.255.252.0 null0 
r3(config)#router rip
r3(config-router)#redistribute static
r3(config-router)#no network 192.168.96.0
r3(config-router)#no network 192.168.97.0
r3(config-router)#no network 192.168.98.0
r3(config-router)#no network 192.168.99.0
r3(config-router)#end

r3#show ip protocols
Routing Protocol is "rip"
  Sending updates every 30 seconds, next due in 6 seconds
  Invalid after 180 seconds, hold down 180, flushed after 240
  Outgoing update filter list for all interfaces is not set
  Incoming update filter list for all interfaces is not set
  Redistributing: static, rip
  Default version control: send version 2, receive version 2
    Interface             Send  Recv  Triggered RIP  Key-chain
    Serial1/1             2     2                                   
  Automatic network summarization is not in effect
  Maximum path: 4
  Routing for Networks:
    192.168.2.0
  Routing Information Sources:
    Gateway         Distance      Last Update
    192.168.2.1          120      00:00:02
  Distance: (default is 120)

这时我们去看路由1和路由2上的路由表:

r1#show ip route   
Codes: C - connected, 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, 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

     1.0.0.0/24 is subnetted, 1 subnets
C       1.1.1.0 is directly connected, Loopback0
C    192.168.1.0/24 is directly connected, Serial1/0
R    192.168.2.0/24 [120/1] via 192.168.1.2, 00:00:09, Serial1/0
R    192.168.96.0/22 [120/2] via 192.168.1.2, 00:00:09, Serial1/0

我们去ping192.168.97.2 98.2 99.2
r1#ping 192.168.97.2

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

都是OK的了!

同时说明rip2是可以传递CIDR汇总信息的.........