BGP联邦用于将AS分成多个子AS。这是处理完全IBGP互连需求的另一种方式。在子AS内,所有的IBGP都是适用的。但是,因为每个子AS具有不同的AS号,所以在它们之间适用EBGP。这降低了域内的IBGP连通。
即使在子AS之间使用的是EBGP,但一些IBGP信息(比如下一跳、MED以及本地一些首选设置)都保留在联邦内。对于外面的世界,联邦看起来是一个AS----子AS被隐藏起来了。
所有路由器都必须配置为BGP。OSPF将在子AS的内部作为IGP使用。路由器A和路由器B在子AS65050中,C和D在子AS65051中,b--c之间运行EBGP,在同AS100的路由器E之间也运行EBGP。
子AS号在专用地址池中进行选择,其范围为64512-65535。OSPF进程64运行在2个子AS中。它们之间是互相独立的。联邦还有另外的一主要的好处。IGP是独立的,因此一个子AS的变化将不会影响到另一个子AS。
B--C----E之间运行的都是EBGP,使用BGP confederation identifier 200 将阻止它们成为AS200的一部分。E运行普通EBGP,它对联邦200中的子AS是不可见的。
////////// router a ///////////////
int lo0
ip addr 152.1.1.1 255.255.255.255
int s0
ip addr 152.1.1.5 255.255.255.252
router ospf 64
netw 152.1.1.0 0.0.0.255 area 0
router bgp 65050
no synchronization
netw 152.1.1.1 mask 255.255.255.255
neighbor 152.1.1.6 remote-as 65050
//////////// router b //////////////////
int o0
ip addr 152.1.1.2 255.255.255.255
int e0/0
ip addr 152.1.1.66 255.255.255.192
int s0/0
ip addr 152.1.1.6 25.255.255.252
int s0/1
ip addr 152.1.1.9 25.255.255.252
router ospf 64
redistribute connected subnets
netw 152.1.1.6 0.0.0.0 area 0
router bgp 65050
no synchronization
neighbor 152.1.1.5 remote-as 65050
neighbor 152.1.1.10 remote-as 100
neighbor 152.1.1.65 remote-as 65051
neighbor 152.1.1.65 next-hop-self
bgp confederation identifier 200
bgp confederation peers 65051
////////// router c //////////////
int lo0
ip addr 152.1.2.1 255.255.255.255
int e0/0
ip addr 152.1.1.65 255.255.255.192
int s0/0
ip addr 152.1.2.5 255.255.255.252
int e0/1
ip addr 152.1.2.129 255.255.255.128
router ospf 64
redistribute connected subnets
netw 152.1.2.129 0.0.0.0 area 0
router bgp 65051
no synchronization
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.130 remote-as 65051
network 152.1.2.1 mask 255.255.255.255
bgp confederation identifier 200
bgp confederation peer 65050
///////// router d /////////////
int lo0
ip addr 152.1.2.2 255.255.255.252
int e0
ip addr 152.1.2.130 255.255.255.128
router ospf 64
netw 152.1.2.0 0.0.0.255 area 0
router bgp 65051
no synchronization
netw 152.1.2.2 mask 255.255.255.255
neighbor 152.1.2.129 remote-as 65051
/////////// router e //////////////////
int lo0
ip addr 1.1.1.1 255.255.255.255
int s0
ip addr 152.1.1.10 255.255.255.252
int s1
ip addr 152.1.2.6 255.255.255.252
router bgp 100
neighbor 152.1.1.9 remote-as 200
neighbor 152.1.2.5 remote-as 200
netw 1.1.1.1 mask 255.255.255.255
在E上做设置,将网络1.1.1.1的MED设置为50。
route-map medxxxx permit 10
match ip address 1
set metric 50
access-list 1 permit 1.1.1.1 255.255.255.255
router bgp 100
neighbor 152.1.2.5 route-map med out