BGPcommunity是一种路由标记方法,用于确保路由过滤和选择的连续性,并且具有可传递性。

实验拓扑:

wKiom1R6iU3ASudQAADAniUjDek733.jpg

 

实验需求:

 1.R1上设置11.0/24 community属性值100:11,将属性传递给R3 

 2.   11.11.11.0/24再添加一条属性值no-export

 3.   R1network 12.0/24网段,根据严格匹配原则,在R3上将到达12.0/24网段的metric设置为1111,11.0/24metric不变。

 4.   R3上删除11.0/24路由的no-export属性,12.0/24的属性不变。

 

实验步骤:

1)完成基本配置

R1

router bgp 100
  neighbor 12.0.0.2 remote-as 200

 

R2

router bgp 200
 neighbor 12.0.0.1 remote-as 100
 neighbor 23.0.0.3 remote-as 300

 

R3

router bgp 300
 neighbor 23.0.0.2 remote-as 200

 

等待邻居关系建立完毕,R1network11.11.11.0/24

R1

router bgp 100
  network 11.11.11.0 mask 255.255.255.0

 

R2,R3都学习到了

wKioL1R6ifuAoXeRAAEQfaAvSpQ872.jpg

wKiom1R6iX-iwEbgAAEcqyHJ64U607.jpg

 

R1上为11.11.11.0/24这条路由添加community属性值100:11 ,并使R2,R3都学习到。

R1

ip prefix-list 11  permit 11.11.11.0/24  //前缀列表匹配此条路由

route-map test permit 10
 match ip address prefix-list 11
 set community 100:11

route-map test per 20

 

router bgp 100
  neighbor 12.0.0.2 send-community
 neighbor 12.0.0.2 route-map test out    //应用于出方向

 

R2

router bgp 200

neighbor 23.0.0.3 send-community   //默认不传递community属性,加上这条就可以传递了

 

R2,R3上查看前要使用转换格式命令

R2

ip bgp-community new-format    
!

R3

ip bgp-community new-format
!

然后可以看到此条属性值了。

R2/R3

clear ip b * s

wKioL1R6ihWAR8soAAEyG3Idz_o940.jpg

 

2)下面在R2上为11.11.11.0/24添加一条属性no-export(此属性意思:不向EBGP邻居传递此条路由)

R2

ip community-list 11 permit 100:11

 

route-map test permit 10
 match community 11
 set community no-export additive    //表示添加,不加此关键字则覆盖原属性
!

route-map test permit 20

router bgp 200
 neighbor 23.0.0.3 route-map test out

可以在R3上查看了

R3

clear ip b * s

wKiom1R6ihSzHznsAAE4dspIHsA013.jpg

 

(3)R1network 12.0/24网段,在R3上将到达12.0/24网段的metric设置为1111.

R1

router bgp 100
  network 12.12.12.0 mask 255.255.255.0

 

R2

no ip community-list 11

ip community-list 11 permit internet     //全部匹配
!

 

R3

ip community-list 11 permit no-export

route-map test permit 10
 match community 11 exact-match     //严格匹配no-export ,多一点少一点都不行
 set metric 1111
!
route-map test permit 20
!        

router bgp 300
 neighbor 23.0.0.2 route-map test in

 

clear ip b * s

查看结果

12.0/24metric值已经变了,而11.0/24的仍然为空。

wKiom1R6iiDBAC1eAAFJIxcFUAU911.jpg

 

 

4)首先查看一下11.0/2412.0/24的属性情况

wKioL1R6irLg5nLGAAJhwI-YwX4891.jpg

 

11.11.11.0/24  属性:100:1     no-export

12.12.12.0/24  属性:no-export

现在需求是删除11.11.11.0/24no-export属性,其他不变。

 

R3

no ip community-list 11

ip community-list 11 permit 100:11

 

ip community-list standard del permit no-export   //重新定义一条属性列表匹配no-export属性

 

 route-map test permit 10

 no match community 11 exact-match

 match community 11
 set metric 1111
 set comm-list del delete

 

查看结果

R3:clear ip b * s

  wKioL1R6isWBPRWvAAJu46Mp4f4112.jpg

 

 已删除11.11.11.0/24的no-export 属性,其他没变,实验结束。