31. Configuring BGP Summarization

1、掌握使用指向NULL0接口的静态路由的汇总配置方法。 
2、掌握使用聚合属性的路由汇总配置方法。
 
按惯例,先上图:

image.png


配置各路由器IP地址等基本信息,测试互连可达。

配置各路由器的BGP协议,并宣告正确的网络。

 

查看R3的路由表:

R3#clear ip bgp * so
R3#show ip 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, 00:00:06
B       172.16.0.0/24 [20/0] via 10.1.255.1, 00:00:06
B       172.16.1.0/24 [20/0] via 10.1.255.1, 00:00:06
B       172.16.2.0/24 [20/0] via 10.1.255.1, 00:00:06
B       172.16.3.0/24 [20/0] via 10.1.255.1, 00:00:06
     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.255.0 is directly connected, Serial0/0

 

通过配置汇总,可以有效减小路由表的大小,提高路由效率。

在R1上按如下配置:

R1(config)#ip route 172.16.0.0 255.255.252.0 null 0   ---->先配置一条前往黑洞的路由
R1(config)#router bgp 64512                 此条路由为汇总的网络号
R1(config-router)#network 172.16.0.0 mask 255.255.252.0 ---->使用network命令把指向黑洞的路由宣告给BGP对等体
R1(config-router)#exit
   

 

再查看R3的路由表:

R3#show ip route
Gateway of last resort is not set

     172.16.0.0/16 is variably subnetted, 6 subnets, 3 masks
B       172.16.255.0/30 [20/0] via 10.1.255.1, 00:06:04
B       172.16.0.0/24 [20/0] via 10.1.255.1, 00:06:04
B       172.16.0.0/22 [20/0] via 10.1.255.1, 00:03:12  ---->已经学习到被汇总的路由条目
B       172.16.1.0/24 [20/0] via 10.1.255.1, 00:06:04
B       172.16.2.0/24 [20/0] via 10.1.255.1, 00:06:04
B       172.16.3.0/24 [20/0] via 10.1.255.1, 00:06:04
     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.255.0 is directly connected, Serial0/0

 

BGP的network命令和其它IGP动态路由协议不同,BGP当检测到本地有network命令,首先会检查本地路由表,看是否有此条目存在,如果有则把此条路由通告给对等体,否则忽略此条network命令。

 

要注意的是,虽然R3学习到了22位的子网汇总路由,但是24位的具体条目还留在路由表中,因此还要在R1上做如下配置:

R1(config)#router bgp 64512
R1(config-router)#no network 172.16.0.0 mask 255.255.255.0
R1(config-router)#no network 172.16.1.0 mask 255.255.255.0
R1(config-router)#no network 172.16.2.0 mask 255.255.255.0
R1(config-router)#no network 172.16.3.0 mask 255.255.255.0
R1(config-router)#end

删除之前通告的。

 

再查看R3的路由表:

R3#show ip 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, 00:02:01
B       172.16.0.0/22 [20/0] via 10.1.255.1, 00:02:01   ----->有效果
     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.255.0 is directly connected, Serial0/0

 

测试:

R3#ping 172.16.0.1

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

 

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

- * - * - * - * - * - * - * - *         解释分隔线       * - * - * - * - * - * - * - * - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

 

虽然通过指向NULL 0口的路由进行配置汇总很简单,并且容易理解,但是不利于排错,因为其它BGP路由器不知道

在哪里汇总的,因此,建议使用BGP聚合方法进行配置汇总。

 

在R1上删除指向NULL 0的路由,在BGP中删除宣告指向NULL 0的条目,重新宣告四个环回口地址。

 

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *

- * - * - * - * - * - * - * - *         解释分隔线       * - * - * - * - * - * - * - * - *

- * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - * - *


 

在R1路由器实施聚合的配置:

R1(config)#router bgp 64512

R1(config-router)#aggregate-add 172.16.0.0 255.255.252.0 summary-only  --->把24位汇总成22位

R1(config-router)#exit                       summary-only表示只发送汇总不发送具体条目

 

再看R3上路由表:

R3#show ip 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, 00:14:48
B       172.16.0.0/22 [20/0] via 10.1.255.1, 00:01:59  ---->一样的效果
     10.0.0.0/30 is subnetted, 1 subnets
C       10.1.255.0 is directly connected, Serial0/0

 

查看汇总路由的属性:

R3#show ip bgp 172.16.0.0
BGP routing table entry for 172.16.0.0/22, version 20
Paths: (1 available, best #1, table Default-IP-Routing-Table)
  Not advertised to any peer
  64512, (aggregated by 64512 172.16.3.1)

    --->表明是谁聚合了此路由,此处是64512中的172.16.3.1聚合此路由,172.16.3.1是路由ID
    10.1.255.1 from 10.1.255.1 (172.16.255.2)
      Origin IGP, localpref 100, valid, external, atomic-aggregate, best

 

测试:

R3#p 172.16.0.1

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

 

一切正常。


发表评论:

◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。

桂ICP备19000498号-3