BGP团体属性控制路由传递方法

1 背景
R1属于AS 100,R2、R3和R4属于AS编号为200的一个联盟,R5属于AS300.在联盟AS200中,R2和R4属于成员AS 2001,R3 属于成员AS2002。全网路由器使用直连接口建立BGP邻居关系。需要实现BGP团体属性来实现下面的需求:
10.0.100.2/32这条路由只能够被AS200的路由器接收到,不能被AS300中的路由器接收;10.0.100.3/32这条路由信息只能被成员AS2001的路由器接收到,不能被成员AS2002以及AS 300的路由器接收到;10.0.100.4/32这条路由信息只能被R2接收到,不能被其他路由器接收;10.0.100.5/32这条路由只能够被R2和R3接收到,不能被其他路由器接收。
2 试验拓扑如下
这里写图片描述
3 配置如下
R1关键配置:
bgp 100
peer 10.0.12.2 as-number 200
#
ipv4-family unicast
undo synchronization
network 10.0.100.1 255.255.255.255
network 10.0.100.2 255.255.255.255
network 10.0.100.3 255.255.255.255
network 10.0.100.4 255.255.255.255
network 10.0.100.5 255.255.255.255
peer 10.0.12.2 enable
peer 10.0.12.2 route-policy xk export
peer 10.0.12.2 advertise-community
#
route-policy xk permit node 10
if-match ip-prefix 2
apply community no-export-subconfed
#
route-policy xk permit node 15
if-match ip-prefix 1
apply community no-export
#
route-policy xk permit node 20
if-match ip-prefix 3
apply community no-advertise
#
route-policy xk permit node 25
if-match ip-prefix 4
apply community 100:11 // 针对该路由新加的团体属性
#
route-policy xk permit node 30
#
ip ip-prefix 1 index 10 permit 10.0.100.2 32
ip ip-prefix 2 index 10 permit 10.0.100.3 32
ip ip-prefix 3 index 10 permit 10.0.100.4 32
ip ip-prefix 4 index 10 permit 10.0.100.5 32
#
R2关键配置:
bgp 2001
confederation id 200
confederation peer-as 2002
peer 10.0.12.1 as-number 100
peer 10.0.23.3 as-number 2002
peer 10.0.24.4 as-number 2001
#
ipv4-family unicast
undo synchronization
peer 10.0.12.1 enable
peer 10.0.23.3 enable
peer 10.0.23.3 next-hop-local
peer 10.0.23.3 advertise-community// 必须配置,不然团体属性不会传给邻居
peer 10.0.24.4 enable
peer 10.0.24.4 route-policy xukai export // 也可以在R4上 import
peer 10.0.24.4 next-hop-local
peer 10.0.24.4 advertise-community
#
route-policy xukai deny node 5
if-match community-filter 11 // community-filter 编号
#
route-policy xukai permit node 10
#
ip community-filter 11 permit 100:11
#
R3关键配置:
bgp 2002
confederation id 200
confederation peer-as 2001
peer 10.0.23.2 as-number 2001
#
ipv4-family unicast
undo synchronization
peer 10.0.23.2 enable
#
R4关键配置:
bgp 2001
confederation id 200
peer 10.0.24.2 as-number 2001
peer 10.0.45.5 as-number 300
#
ipv4-family unicast
undo synchronization
peer 10.0.24.2 enable
peer 10.0.24.2 next-hop-local
peer 10.0.45.5 enable

R5关键配置: bgp 300 peer 10.0.45.4 as-number 200 # ipv4-family unicast undo synchronization peer 10.0.45.4 enable