现在讲另一种方法联盟(confederation ):联盟将一个自治系统划分为若干个子自治系统,每个子自治系统内部的IBGP对等体建立全连接关系,子自治系统之间建立EBGP连接关系。在不属于联盟的BGP发言者看来,属于同一个联盟的多个子自治系统是一个整体,外界不需要了解内部的子自治系统情况 。
还是上面那个拓扑图,满足上面的需求,现在我们用BGP联盟来解决它,将AS10划分为几个小的AS(私有AS号64512-65535),将R1、R2、R3划分AS65000,R4、R5划分为65001,R6、R7划分为65002,然后AS10与R8、R9建立EBGP。
主要配置如下(AS10的IGP见前面):
R1:
router bgp 65000
no synchronization
bgp confederation identifier 10 //BGP联盟AS为10(不指定将报错)
bgp confederation peers 65001 65002 //BGP联盟内的EBGP邻居AS(不指定将报错)
network 10.0.0.0 mask 255.255.0.0
neighbor 10.0.0.2 remote-as 65000 //建立IBGP
neighbor 10.0.0.2 update-source Loopback0
neighbor 10.0.0.2 next-hop-self
neighbor 10.0.0.3 remote-as 65000 //建立IBGP
neighbor 10.0.0.3 update-source Loopback0
neighbor 10.0.0.3 next-hop-self
neighbor 10.0.0.4 remote-as 65001 //建立内的联盟EBGP
neighbor 10.0.0.4 ebgp-multihop 255 //因为EBGP跳数默认为1,用LOOPBACK建邻居需修改
neighbor 10.0.0.4 update-source Loopback0
neighbor 10.0.0.6 remote-as 65002
neighbor 10.0.0.6 ebgp-multihop 255
neighbor 10.0.0.6 update-source Loopback0
neighbor 10.0.18.2 remote-as 30 //建立EBGP
no auto-summary
ip route 10.0.0.0 255.255.0.0 Null0
R2:
router bgp 65000
no synchronization
bgp confederation identifier 10 //联盟内的每个路由器都需配置
neighbor 10.0.0.1 remote-as 65000
neighbor 10.0.0.1 update-source Loopback0
neighbor 10.0.0.1 next-hop-self
neighbor 10.0.29.2 remote-as 20
no auto-summary
R3:
router bgp 65000
no synchronization
bgp confederation identifier 10 //联盟内的每个路由器都需配置
neighbor 10.0.0.1 remote-as 65000
neighbor 10.0.0.1 update-source Loopback0
neighbor 10.0.0.1 next-hop-self
no auto-summary
R4:
router bgp 65001
no synchronization
bgp confederation identifier 10 //联盟内的每个路由器都需配置
bgp confederation peers 65000 //只需在联盟内的EBGP配置
neighbor 10.0.0.1 remote-as 65000
neighbor 10.0.0.1 ebgp-multihop 255
neighbor 10.0.0.1 update-source Loopback0
neighbor 10.0.0.5 remote-as 65001
neighbor 10.0.0.5 update-source Loopback0
neighbor 10.0.0.5 next-hop-self
no auto-summary
R5:
router bgp 65001
no synchronization
bgp confederation identifier 10
network 10.5.0.0 mask 255.255.0.0
neighbor 10.0.0.4 remote-as 65001
neighbor 10.0.0.4 update-source Loopback0
neighbor 10.0.0.4 next-hop-self
no auto-summary
ip route 10.5.0.0 255.255.0.0 Null0
R6:
router bgp 65002
no synchronization
bgp confederation identifier 10 //联盟内的每个路由器都需配置
bgp confederation peers 65000 //只需在联盟内的EBGP配置
neighbor 10.0.0.1 remote-as 65000
neighbor 10.0.0.1 ebgp-multihop 255
neighbor 10.0.0.1 update-source Loopback0
neighbor 10.0.0.7 remote-as 65002
neighbor 10.0.0.7 update-source Loopback0
neighbor 10.0.0.7 next-hop-self
no auto-summary
R7:
router bgp 65002
no synchronization
bgp confederation identifier 10 //联盟内的每个路由器都需配置
network 10.7.0.0 mask 255.255.0.0
neighbor 10.0.0.6 remote-as 65002
neighbor 10.0.0.6 update-source Loopback0
neighbor 10.0.0.6 next-hop-self
no auto-summary
ip route 10.7.0.0 255.255.0.0 Null0
R8:
router bgp 30
no synchronization
network 10.8.0.0 mask 255.255.0.0
neighbor 10.0.18.1 remote-as 10 //只需和公有的AS建立邻居
no auto-summary
ip route 10.8.0.0 255.255.0.0 Null0
R9:
router bgp 20
no synchronization
network 10.9.0.0 mask 255.255.0.0
neighbor 10.0.29.1 remote-as 10
no auto-summary
ip route 10.9.0.0 255.255.0.0 Null0
现在我们来看下R9和R7的路由表是否都学到全部路由:
从后面的AS号可以看出,私有AS对外是不可见的,也不计算在AS_PATH里
括号内的AS外联盟内的小AS号(私有)
confed-internal,可以看出是联盟内的内部路由
解决IBGP之间不能传播路由的方法:RR和联盟(联盟+RR常用于大型网络中)