一、拓扑图:
二、用静态路由下一跳指向null 0来手动的配置汇总:
1、配置各路由器的IP地址,以及配置BGP协议,并把各路由器直连网络通告进BGP当中。配置完之后我们在R3上查看一下路由表:
1、配置各路由器的IP地址,以及配置BGP协议,并把各路由器直连网络通告进BGP当中。配置完之后我们在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
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, Serial1/0
R3#
|
2、从上图我们看到了R3学到了5条BGP的路由,但是如果在实际的工作环境当中,我们应该尽量地减少路由表,这样有利于提高路由器的稳定性。但是我们应该怎么去做呢?之前的实验已经让我们明白,在向BGP对等体通告某一路由时,这台路由器上必须要有需通告的此路由条目。也就是说如果我把这些网段汇总成172.16.0.0/22 并通告的话,那么在R1上必须存在这条路由条目,怎么去满足它呢?上一个实验我们是在R1上开启自动汇总,让R1自己汇总成16位有类地址172.16.0.1/16存在于R1当中,这一次不在R1上开启自动汇总,用别的方法去做,让它汇总的范围更小,把它汇总成无类的22位地址,我们可以新建一条静态路由指向空接口让它存在于R1中,这样就能满足要求了:
R1(config)#ip route 172.16.0.0 255.255.252.0 null 0
|
3、我们现在再来宣告172.16.0.0/22的地址进BGP:
R1(config)#router bgp 64512
R1(config-router)#net 172.16.0.0 mask 255.255.252.0
|
4、现在再到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, 6 subnets, 3 masks
B 172.16.255.0/30 [20/0] via 10.1.255.1, 01:04:31
B 172.16.0.0/24 [20/0] via 10.1.255.1, 01:04:31
B 172.16.0.0/22 [20/0] via 10.1.255.1, 00:00:47 (发现有一条汇总的/22的路由条目)
B 172.16.1.0/24 [20/0] via 10.1.255.1, 01:04:31
B 172.16.2.0/24 [20/0] via 10.1.255.1, 01:04:31
B 172.16.3.0/24 [20/0] via 10.1.255.1, 01:04:31
10.0.0.0/30 is subnetted, 1 subnets
C 10.1.255.0 is directly connected, Serial1/0
|
5、通过上面的路由表看到了其它之前宣告的/24位的路由还存在,那么现在我们把R1上的这些路由条目都no掉:
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
|
6、通过上述的配置,再来看一下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, 01:14:10
B 172.16.0.0/22 [20/0] via 10.1.255.1, 00:10:27(现在只有一条/22的汇总路由条目了)
10.0.0.0/30 is subnetted, 1 subnets
C 10.1.255.0 is directly connected, Serial1/0
|
7、虽然我们把172.16.0.1 这条路由表目no 掉了,但现在我们在R3上ping 一下这个地址还是通的,原因是有汇总的地址存在:
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 = 12/32/92 ms
R3#
|
三、通过用静态路由指一条汇总地址到null0 当中去,让这条路由条目存在于路由表中再去通告一个汇总地址这样的方式去做汇总。配置非常简单,但是真的不好排错,其它的BGP路由器不知道是在哪里汇总的。你想一想:当通告的路由条目一多的话,172.16.0.0/22这个地址我们可能认为它是哪个接口的地址。不能想到它是汇总的地址。所以说事物都有双面性:有利也有弊。
本文转自wxs-163 51CTO博客,原文链接:http://blog.51cto.com/supercisco/267241