一、拓扑图:
通过bgp聚合命令来做汇总通告_第1张图片
二、配置各路由器的 IP地址使各直连链路互通。并配置 BGP协议,把直连网络宣告进 BGP,配置完之后,来看一下 R3的路由表:
R3#sh 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
 
     172.16.0.0/16 is variably subnetted, 5 subnets, 2 masks
B       172.16.255.0/30 [20/0] via 10.1.255.1, 02:28:27
B       172.16.0.0/24 [20/0] via 10.1.255.1, 00:05:55
B       172.16.1.0/24 [20/0] via 10.1.255.1, 00:05:25
B       172.16.2.0/24 [20/0] via 10.1.255.1, 00:04:54
B       172.16.3.0/24 [20/0] via 10.1.255.1, 00:04:54
     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.255.0 is directly connected, Serial1/0
 
三、在上一个实验中,因为使用静态路由指向空接口手动配置BGP汇总有不利于排错等弊端,现在换一种方式,我们在R1上用bgp聚合方法来配置汇总。但需要注意的是:如果只用aggregate-address通告聚合地址,那么聚合路由和详细路由都通告给对等体,如果在aggregate-address后加上关键字summary-only,那么将只通告聚合路由,不再通告具体的路由。
1、下面在R1上使用bgp聚合配置汇总路由:
 
R1(config)#router bgp 64512
R1(config-router)#aggregate-address 172.16.0.0 255.255.252.0 summary-only
 
2、通过对R1的配置,再来看一下R3的路由表:
 
R3#sh 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
 
     172.16.0.0/16 is variably subnetted, 2 subnets, 2 masks
B       172.16.255.0/30 [20/0] via 10.1.255.1, 02:56:36
B       172.16.0.0/22 [20/0] via 10.1.255.1, 00:02:34  (也能汇总成/22的汇总地址)
     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.255.0 is directly connected, Serial1/0
R3#
 
四、通过上一个和这一个实验,我们明白了,BGP有两种方法去汇总地址:第一种方法是通过建立静态路由把汇总地址指向 null 地址让它存在于路由表当中,之后再通告汇总地址。第二种方法是:通过使用aggregate-address命令来做汇总,但需要注意summary-only 只通告汇总地址,不加的话则具体路由条目也会通告。