Technorati 标签: ,,,,

实例1主要是要解释清楚一条聚合路在R2上面为什么下一跳是Null0的意义。

拓扑如下:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_实验

两个设备的配置如下:

Router-1:

interface FastEthernet1/0

ip address 10.1.1.1 255.255.255.0

duplex full

speed auto

router bgp 1

no synchronization

bgp log-neighbor-changes

neighbor 10.1.1.2 remote-as 2

no auto-summary

Router-2:

!

interface Loopback0

ip address 172.16.0.1 255.255.255.0

interface Loopback1

ip address 172.16.1.1 255.255.255.0

interface Loopback2

ip address 172.16.3.1 255.255.255.0

interface Loopback3

ip address 172.16.2.1 255.255.255.0

interface FastEthernet1/0

ip address 10.1.1.2 255.255.255.0

duplex full

speed auto

router bgp 2

no synchronization

bgp log-neighbor-changes

network 172.16.0.0 mask 255.255.255.0

network 172.16.1.0 mask 255.255.255.0

network 172.16.2.0 mask 255.255.255.0

network 172.16.3.0 mask 255.255.255.0

aggregate-address 172.16.0.0 255.255.252.0

neighbor 10.1.1.1 remote-as 1

no auto-summary

ip route 0.0.0.0 0.0.0.0 10.0.0.1

CISCO:

在路由器1和路由器2上面.

router-1:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_案例_02

Router-2:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_实验_03

注意这里cisco在路由器2上面是一条 172.16.0.0/22 下一跳是Null0口的路由。

为什么cisco要开发这个功能呢?

在CISCO 命令与配置手册第五页,资料是这样记载的。

在这种情况下.

假设router-2 172.16.2.0/24发生了故障(shutdown interface或者链路断开),路由器b将会从bgp路由表里面把明细路由删除掉。但是仍然会通告聚合路由,假设router-b设有一个默认路由指向路由器A, 但是如果没有设置下一跳为Null 0的bgp聚合路由172.16.0.0/22,假设A 收到数据要转发到172.16.2.0,在A上面因为有路由到172.16.0.0/22 下一跳是10.0.0.2,于是转给router-b.

因为172.16.2.0在路由器b上面明细路由已经没有在核心路由表了,如果没有一个172.16.0.0/22 null 0的路由,那么因为有ip route 0.0.0.0 0.0.0.0 10.0.0.1,所以路由器b就要再转给A,A收到了又重新发给B,造成网络风暴,一个数据包就这样被两个路由器无情的抛绣球,直到TTL 255被一跳一跳的耗尽,最后被路由器丢包。

但是如果有了172.16.0.0/22 null 0这个路由器在router-b上面,router-b收到路由后就会丢包.

配置案例2:聚合经过重分发的路由.

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_BGP_04

拓扑图依然不变,但是这里不再使用network命令在R2上面将明细路由导入bgp表,而是先重分发直连路由,然后再将路由聚合.

设备配置:

R1:

hostname R1

!

interface FastEthernet0/0

ip address 10.1.1.1 255.255.255.0

duplex full

!

router bgp 1

no synchronization

bgp log-neighbor-changes

neighbor 10.1.1.2 remote-as 2

no auto-summary

!

R2:

hostname R2

interface Loopback0

ip address 172.16.0.1 255.255.255.0

!

interface Loopback1

ip address 172.16.1.1 255.255.255.0

!

interface Loopback2

ip address 172.16.2.1 255.255.255.0

!

interface Loopback3

ip address 172.16.3.1 255.255.255.0

!

interface FastEthernet0/0

ip address 10.1.1.2 255.255.255.0

duplex full

!

router bgp 2

no synchronization

bgp log-neighbor-changes

aggregate-address 172.16.0.0 255.255.252.0

redistribute connected metric 20

neighbor 10.1.1.1 remote-as 1

no auto-summary

!

ip route 0.0.0.0 0.0.0.0 10.0.0.1

最后得到了一样的结果,在R1上面,R2的4条重分发的路由:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_案例_05

在R2上面:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_BGP_06

配置案例3:聚合学得的BGP路由.

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_路由_07

路由器R2从路由器R3学得前缀172.16.0.0/24--172.16.3.0/24,由于这4条路由现在已经在R2的BGP表中,因此路由器A可以直接将他们聚合为前缀172.16.0.0/22.

配置:

router-R1:

hostname R1

interface FastEthernet0/0

ip address 172.17.1.2 255.255.255.0

duplex full

speed auto

!

router bgp 65530

no synchronization

bgp log-neighbor-changes

neighbor 172.17.1.1 remote-as 1

no auto-summary

!

Router-R2:

hostname R2

!

interface FastEthernet0/0

ip address 172.17.1.1 255.255.255.0

duplex full

speed auto

!

interface FastEthernet1/0

ip address 10.1.1.1 255.255.255.0

duplex full

speed auto

!

router bgp 1

no synchronization

bgp log-neighbor-changes

aggregate-address 172.16.0.0 255.255.252.0

neighbor 10.1.1.2 remote-as 2

neighbor 172.17.1.2 remote-as 65530

no auto-summary

!

Router-R3:

hostname R3

!

interface Loopback0

ip address 172.16.0.1 255.255.255.0

!

interface Loopback1

ip address 172.16.1.1 255.255.255.0

!

interface Loopback2

ip address 172.16.2.1 255.255.255.0

!

interface Loopback3

ip address 172.16.3.1 255.255.255.0

!

interface FastEthernet1/0

ip address 10.1.1.2 255.255.255.0

duplex full

speed auto

!

router bgp 2

no synchronization

bgp log-neighbor-changes

network 172.16.0.0 mask 255.255.255.0

network 172.16.1.0 mask 255.255.255.0

network 172.16.2.0 mask 255.255.255.0

network 172.16.3.0 mask 255.255.255.0

neighbor 10.1.1.1 remote-as 1

no auto-summary

!

在路由器R1和R2上面都应该有一条聚合路由。

R1:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_实验_08

R2:

01-01-BGP Aggregate-address address mask -----CISCO BGP4 命令与配置手册_案例_09

最后就是相关的故障排除:

○使用show ip bgp neighbors,检查邻居的状态是否是established的状态。也可以用show ip bgp summary进行检查,看状态是一个时间定时器(up),还是处于never的状态。

○执行show ip bgp命令,看bgp表中是否有至少一条明细路由待聚合。

○如果bgp表中没有这条聚合路由,看是否过滤器阻挡了聚合路由的通告。

○如果bgp表中没有明细路由,需要检查bgp network命令的地址和掩码是否一致。

我就做过实验,如果loopback接口下面配置24位的掩码,而在bgp中network的时候用32位的掩码通告出去,由于掩码不匹配,bgp根本就不会通告出去。

如果是以重分发的方式注入bgp路由(直连,静态,或者igp路由),需要执行no auto-summary,关闭自动汇总的特性。