1、实验拓扑
2、基础配置
R1配置
interface Loopback0
ip address 1.1.1.1 255.255.255.0
interface Serial0/0
ip address 13.1.1.1 255.255.255.0
interface FastEthernet1/0
ip address 124.1.1.1 255.255.255.0
router ospf 110
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 124.1.1.0 0.0.0.255 area 0
router bgp 1
no synchronization
bgp router-id 1.1.1.1
neighbor 2.2.2.2 remote-as 1
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 13.1.1.3 remote-as 3
no auto-summary
R2配置
interface Loopback0
ip address 2.2.2.2 255.255.255.0
interface FastEthernet1/0
ip address 124.1.1.2 255.255.255.0
router ospf 110
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 0
network 124.1.1.0 0.0.0.255 area 0
router bgp 1
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Loopback0
neighbor 124.1.1.4 remote-as 4
no auto-summary
R3配置
interface Loopback0
ip address 3.3.3.3 255.255.255.0
interface Loopback16
ip address 202.1.16.3 255.255.255.0
interface Loopback17
ip address 202.1.17.3 255.255.255.0
interface Loopback18
ip address 202.1.18.3 255.255.255.0
interface Loopback19
ip address 202.1.19.3 255.255.255.0
interface Serial0/0
ip address 13.1.1.3 255.255.255.0
router bgp 3
no synchronization
bgp router-id 3.3.3.3
bgp log-neighbor-changes
network 3.3.3.0 mask 255.255.255.0
network 202.1.16.0
network 202.1.17.0
network 202.1.18.0
network 202.1.19.0
neighbor 13.1.1.1 remote-as 1
no auto-summary
R4配置
interface Loopback0
ip address 4.4.4.4 255.255.255.0
interface FastEthernet1/0
ip address 124.1.1.4 255.255.255.0
router bgp 4
no synchronization
bgp router-id 4.4.4.4
bgp log-neighbor-changes
network 4.4.4.0 mask 255.255.255.0
neighbor 124.1.1.2 remote-as 1
no auto-summary
3、配置聚合
BGP聚合可以使用两种方法:
方法一:手动写一条指向空接口的静态汇总路由,再在BGP路由进程汇总发布该汇总路由
方法二:先在BGP路由进程中network所有的明细路由,在用aggregate-address 202.1.16.0 255.255.252.0 做聚合,此时会将聚合路由和明细路由都通告出去,aggregate-address 202.1.16.0 255.255.252.0 summary-only将会抑制明细路由,标识为s,且不发给其他BGP邻居。
此外我们也可以指定不通告特定路由,基本步骤如下:
ip prefix-list 1 permit 202.1.16.0/23 ge 24 le 24
route-map YZ permit 10
match ip address prefix-list 1
router bgp 3
aggregate-address 202.1.16.0 255.255.252.0 suppress-map YZ
方法二是在发送方做聚合,如果在接收方做聚合,接收方生成聚合路由后会反传给发送方,此时将会产生丢包现象,所以不应该让聚合路由回传。为达到不会传的目的,我们采用BGP的水平分割技术,在聚合路由上加入明细路由的属性,这样当发送方收到聚合路由后,由于聚合路由携带有自身的AS号而不接受该路由,aggregate-address 202.1.16.0 255.255.252.0 summary-only as-set。
方法一:
R3配置
ip route 202.1.16.0 255.255.252.0 null0
router bgp 3
no network 202.1.16.0
no network 202.1.17.0
no network 202.1.18.0
no network 202.1.19.0
network 202.1.16.0 mask 255.255.252.0
方法二:
R3配置
noip route 202.1.16.0 255.255.252.0 null0
router bgp 3
nonetwork 202.1.16.0 mask 255.255.252.0
network 202.1.16.0
network 202.1.17.0
network 202.1.18.0
network 202.1.19.0
aggregate-address 202.1.16.0 255.255.252.0
aggregate-address 202.1.16.0 255.255.252.0 summary-only将会抑制明细路由,标识为s,且不发给其他BGP邻居。
router bgp 3
aggregate-address 202.1.16.0 255.255.252.0 summary-only
清除R3上的聚合,将聚合做在R1上。
router bgp 3
no aggregate-address 202.1.16.0 255.255.252.0 summary-only
router bgp 1
no aggregate-address 202.1.16.0 255.255.252.0 summary-only
router bgp 1
no aggregate-address 202.1.16.0 255.255.252.0 summary-only as-set
R1不再将聚合路由通告给R3。