涉及到的概念:BGP联邦即BGP Confederation。一般用在一个AS的内部,在一个大的AS内部可以拆分成数个小的AS,这样只要保证小的AS之间可以通过EBGP方式进行互联即可,不必每台路由器都互相建立IBGP连接。
BGP联邦和RR的对比:BGP联邦建立之后在联邦内跨越内部的AS的时候AS_PATH仍然会发生变化,可以针对AS_PATH的变化做出更精确的控制。
配置如下:
routerE:
router bgp 100
no synchronization
bgp log-neighbor-changes
network 1.1.1.1 mask 255.255.255.255
neighbor 152.1.1.9 remote-as 200
neighbor 152.1.2.5 remote-as 200
no auto-summary
routerB:
router ospf 1
log-adjacency-changes
redistribute connected subnets
network 152.1.1.6 0.0.0.0 area 0
!
router bgp 65050
no synchronization
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65051
neighbor 152.1.1.5 remote-as 65050
neighbor 152.1.1.5 next-hop-self
neighbor 152.1.1.10 remote-as 100
neighbor 152.1.1.65 remote-as 65051
no auto-summary
!
routerA:
router ospf 1
log-adjacency-changes
network 152.1.1.0 0.0.0.255 area 0
!
router bgp 65050
no synchronization
bgp log-neighbor-changes
network 152.1.1.1 mask 255.255.255.255
neighbor 152.1.1.6 remote-as 65050
no auto-summary
!
routerC:
router bgp 65051
no synchronization
bgp log-neighbor-changes
bgp confederation identifier 200
bgp confederation peers 65050
network 152.1.2.1 mask 255.255.255.255
neighbor 152.1.1.66 remote-as 65050
neighbor 152.1.1.66 next-hop-self
neighbor 152.1.2.6 remote-as 100
neighbor 152.1.2.129 remote-as 65051
no auto-summary
!
routerD:
router ospf 1
log-adjacency-changes
network 152.1.2.0 0.0.0.255 area 0
!
router bgp 65051
no synchronization
bgp log-neighbor-changes
network 152.1.2.2 mask 255.255.255.255
neighbor 152.1.2.130 remote-as 65051
no auto-summary
!
配置完毕后,在router E上show ip bgp可以看到:
E#sh ip bgp
BGP table version is 7, local router ID is 1.1.1.1
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
*> 1.1.1.1/32 0.0.0.0 0 32768 i
*> 152.1.1.1/32 152.1.1.9 0 200 i
* 152.1.2.1/32 152.1.1.9 0 200 i
*> 152.1.2.5 0 0 200 i
* 152.1.2.2/32 152.1.1.9 0 200 i
*> 152.1.2.5 0 200 i
由此可知,联邦对外的表现是一个整体,AS100看到的都是AS200,而不是内部的AS65050或65051。但是在联邦的内部执行show ip bgp仍然会看到联邦内的AS的信息:
b#sh ip bgp
BGP table version is 12, local router ID is 152.1.1.2
Status codes: s suppressed, d damped, h history, * valid, > best, i - internal,
r RIB-failure, S Stale
Origin codes: i - IGP, e - EGP, ? - incomplete
Network Next Hop Metric LocPrf Weight Path
* 1.1.1.1/32 152.1.1.65 0 100 0 (65051) 100 i
*> 152.1.1.10 0 0 100 i
r>i152.1.1.1/32 152.1.1.5 0 100 0 i
*> 152.1.2.1/32 152.1.1.65 0 100 0 (65051) i
*> 152.1.2.2/32 152.1.1.65 0 100 0 (65051) i