R1#conf t
R1(config)#inter loop 0
R1(config-if)#no shut
R1(config-if)#ip add 172.34.0.1 255.255.255.0
R1(config-if)#exit
R1(config)#inter loop 1
R1(config-if)#no shut
R1(config-if)#ip add 172.34.1.1 255.255.255.0
R1(config-if)#exit
R1(config)#inter loop 2
R1(config-if)#no shut
R1(config-if)#ip add 172.34.2.1 255.255.255.0
R1(config-if)#exit
R1(config)#inter loop 3
R1(config-if)#no shut
R1(config-if)#ip add 10.34.0.1 255.255.0.0
R1(config-if)#exit
R1(config)#inter loop 4
R1(config-if)#no shut
R1(config-if)#ip add 10.134.0.1 255.255.0.0
R1(config-if)#exit
R1(config)#inter f0/0
R1(config-if)#ip add 192.168.34.1 255.255.255.0
R1(config-if)#no shut
R1(config-if)#exit
R1(config)#router rip
R1(config-router)#network 172.34.0.0
R1(config-router)#network 172.34.1.0
R1(config-router)#network 172.34.2.0
R1(config-router)#network 10.34.0.0
R1(config-router)#network 10.134.0.0
R1(config-router)#network 192.168.34.0
R1(config-router)#end
R2#conf t
R2(config)#inter loop 0
R2(config-if)#no shut
R2(config-if)#ip add 202.34.0.1 255.255.255.0
R2(config-if)#exit
R2(config)#inter loop 1
R2(config-if)#no shut
R2(config-if)#ip add 202.134.0.1 255.255.255.0
R2(config-if)#exit
R2(config)#inter f0/0
R2(config-if)#ip add 192.168.34.2 255.255.255.0
R2(config-if)#no shut
R2(config-if)#exit
R2(config)#router rip
R2(config-router)#network 202.34.0.0
R2(config-router)#network 202.134.0.0
R2(config-router)#network 192.168.34.0
R2(config-router)#end
配置完,show ip route看一看:
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
R 202.134.0.0/24 [120/1] via 192.168.34.2, 00:00:04, FastEthernet0/0
R 202.34.0.0/24 [120/1] via 192.168.34.2, 00:00:05, FastEthernet0/0
172.34.0.0/24 is subnetted, 3 subnets
C 172.34.2.0 is directly connected, Loopback2
C 172.34.0.0 is directly connected, Loopback0
C 172.34.1.0 is directly connected, Loopback1
10.0.0.0/16 is subnetted, 2 subnets
C 10.34.0.0 is directly connected, Loopback3
C 10.134.0.0 is directly connected, Loopback4
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R1#
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 202.134.0.0/24 is directly connected, Loopback1
C 202.34.0.0/24 is directly connected, Loopback0
R 172.34.0.0/16 [120/1] via 192.168.34.1, 00:00:06, FastEthernet0/0
R 10.0.0.0/8 [120/1] via 192.168.34.1, 00:00:06, FastEthernet0/0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R2#
在上面的路由表中,路由表被自动汇总了:
R1#show ip route
. ....
. ....
172.34.0.0/24 is subnetted, 3 subnets
. ....
. ....
C 172.34.0.0 is directly connected, Loopback0
. ....
. ....
可以看到已经有一条172.34.0.0
,却还是出现了172.34.0.0/24
。
RIP的自动汇总很强大 ,不但可以汇总本地产生的路由, 邻居传递也给汇总了,所以不是很好 ,而且容易出现环路。
若我们网络中再有 [172.34.2.0/24],[172.34.3.0/24] 网段,没有关闭自动汇总的网络根本看不到明细路由。
因此当一个网路中子网不是很多的时候,自动汇总是个很好的解决办法。
但是后续子网开始多起来的时候,自动汇总的缺点就开始显露了。
R1#conf t
R1(config)#router rip
R1(config-router)#version 2 //V2版本才支持关闭自动汇总
R1(config-router)#no auto-summary
====================================
R2#conf t
R2(config)#router rip
R2(config-router)#version 2 //V2版本才支持关闭自动汇总
R2(config-router)#no auto-summary
若要在本实验中查看到关闭自动汇总后路由表的变化,需要在R2上看,因为R1上是直连。

下面在R2上对比一下关闭自动汇总前后:
//关闭前
R2#show ip route
......
......
......
Gateway of last resort is not set
C 202.134.0.0/24 is directly connected, Loopback1
C 202.34.0.0/24 is directly connected, Loopback0
R 172.34.0.0/16 [120/1] via 192.168.34.1, 00:00:06, FastEthernet0/0
R 10.0.0.0/8 [120/1] via 192.168.34.1, 00:00:06, FastEthernet0/0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R2#
//关闭后
R2#show ip route
......
......
......
Gateway of last resort is not set
C 202.134.0.0/24 is directly connected, Loopback1
C 202.34.0.0/24 is directly connected, Loopback0
172.34.0.0/24 is subnetted, 3 subnets
R 172.34.2.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
R 172.34.0.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
R 172.34.1.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
10.0.0.0/16 is subnetted, 2 subnets
R 10.34.0.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
R 10.134.0.0 [120/1] via 192.168.34.1, 00:00:00, FastEthernet0/0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R2#
虽然关闭了自动汇总,但在路由表中还保留了两条自动汇总后的路由
172.34.0.0/24 is subnetted, 3 subnets
10.0.0.0/16 is subnetted, 2 subnets
但是全部子网都在路由表中显示出来了,后续添加新子网时,就不会出现子网不显示的情况了。
如果一条网路中有很多子网,如果开启自动汇总,前面已经说到这个情况是不太好的。关闭自动汇总后在路由表中又有很多条路由表,七八条还好,如果是100条的话,这会很令人头大。
于是手动汇总是比较好的解决办法—-应对大量的路由表。
开启路由器R1的手动汇总(开启子网段172.34.0.0的手动汇总,因为目前该子网段数量“较多”):
R2(config)#inter f0/0
R2(config-if)#ip summary-address rip 172.34.0.0 255.255.0.0
这个时候在哪里看路由表变化呢?当然还是路由器R2。如果R2上没看到,需要刷新路由表:clear ip route
下面查看R2的路由表:
//关闭自动汇总,开启手动汇总后的路由器R2的路由表
R2#show ip route
......
......
......
Gateway of last resort is not set
C 202.134.0.0/24 is directly connected, Loopback1
C 202.34.0.0/24 is directly connected, Loopback0
172.34.0.0/24 is subnetted, 3 subnets
R 172.34.2.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
R 172.34.0.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
R 172.34.1.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
10.0.0.0/16 is subnetted, 2 subnets
R 10.34.0.0 [120/1] via 192.168.34.1, 00:00:27, FastEthernet0/0
R 10.134.0.0 [120/1] via 192.168.34.1, 00:00:00, FastEthernet0/0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
R2#
//开启手动汇总后的路由器R2的路由表
R2#show ip route
......
......
......
Gateway of last resort is not set
C 202.134.0.0/24 is directly connected, Loopback1
C 202.34.0.0/24 is directly connected, Loopback0
R 172.34.0.0/16 [120/1] via 192.168.34.1, 00:00:00, FastEthernet0/0
10.0.0.0/16 is subnetted, 2 subnets
R 10.34.0.0 [120/1] via 192.168.34.1, 00:00:00, FastEthernet0/0
R 10.134.0.0 [120/1] via 192.168.34.1, 00:00:00, FastEthernet0/0
C 192.168.34.0/24 is directly connected, FastEthernet0/0
可以看到172.34. *. */24
网段的所有子网都被汇总成172.34.0.0/16
R 172.34.0.0/16 [120/1] via 192.168.34.1, 00:00:00, FastEthernet0/0